Java程序辅导

C C++ Java Python Processing编程在线培训 程序编写 软件开发 视频讲解

客服在线QQ:2653320439 微信:ittutor Email:itutor@qq.com
wx: cjtutor
QQ: 2653320439
CS 770/870 Lab 1: OpenGL Mouse work: rubberband rectangle 
September 18, 2015 
Due: Monday, 9/28 by 23:59:59 
Lateness: 9/29 -3, 9/30 -10 
The goal is to learn to implement basic input handling features related to the mouse/trackpad using GLUT 
(C++) or low level mouse/button/keyboard functionality of GLFW or Swing. Start with your solution to P0.  
Your new program should allow the user to add new shapes to the scene:   
1. Use a GLUT left button pulldown menu or a Java Swing radio button menu or GLFW key presses to select a 
triangle (“t”), rectangle (“r”), or polygon (“p”) object as the current object. Hard code specific instances of 
each of these objects as the one to be drawn for each selection. Use the GLUT right button pulldown menu 
or another Swing radio button menu for current color selection. For non-Swing Java, use capital letters for 
color selection: R, G, B, C, M, Y for red (1,0,0), green (0,1,0), blue (0,0,1), cyan (0,1,1), magenta (1,0,1), 
and yellow (1,1,0). 
2. Use GLUT or GLFW or Java Swing mouse handling facilities to implement the following options: 
• mouse down/up at the same location (within a few pixels): place an instance of the current object at this 
location at a default size. 
• mouse down/up at different locations: one corner of a shape to be added is the down position, the other 
corner is the mouse up position; the current shape using your default color should be added to the scene 
and located and scaled so it fits in the space specified by the mouse up/down positions. The order of the 
2 positions should be irrelevant. The object should be drawn continuously as the mouse is moving. 
 
The following demos are in tar files (for ease of unpacking) and are stored on agate in ~cs770/public/L1/ and 
on the course web site at http://cs.unh.edu/public/L1 .  
• glut.tar: a basic demonstration of the glut facilities for pop up menus for C++ users. 
• UIlwjgl.tar: an extension of the BasicLWJGL demo with some simple sliders (that you don’t need) and 
a Quit button and a radio button banel in a separate window. You’ll need to adapt this to put in one radio 
button panel for selecting the current object to add to the scene and to one radio button panel to pick the 
current color.   
• InputLWJGL.tar: provides examples of how to get cursor and keyboard events for the low level key-
based option. 
There is also a link on the course web site to GLUT documentation in order to get details for accessing the 
mouse/cursor position and button events and GLFW although this is C++ oriented so the names don’t match 
those used in LWJGL.  
 
Important note: I’ve decided to make this a short focused task and want to treat it like a lab rather than a 
formal assignment. Consequently, you may get more help from each other than would be allowed for a 
programming assignment. You must still submit your own labs and you should report the names of those you 
worked with as part of the web submission and as a comment in your main class/file. Even though it is ok to 
work very closely, please don’t hand in exactly the same code. I still expect each person to at least choose their 
own unique objects and create your own code. 
 
. Warning: I will be leaving town as soon as I get this posted and will be away all weekend at a remote 
location with only very marginal internet access – and I won’t have much time for logging in anyway. 
So, feel free to send email or post notes on Piazza, but be patient. I hope to be able to check at least once 
each evening.