program 2 due 02/01 be sure to document your program program level doc your name what the...
TRANSCRIPT
Program 2 due 02/01Program 2 due 02/01
Be sure to document your programBe sure to document your program program level docprogram level doc
your nameyour name what the program doeswhat the program does
each functioneach function describe the argumentsdescribe the arguments describe what the function doesdescribe what the function does
document anything you may forget in a weekdocument anything you may forget in a week
Indexed ColorIndexed Color
Needed for frame buffers with a limited Needed for frame buffers with a limited depth depth 8 bits of color = 2**8 colors = 256 colors8 bits of color = 2**8 colors = 256 colors default is dividing bits into rbg assignmentsdefault is dividing bits into rbg assignments
load color map with a pallette of 256 load color map with a pallette of 256 colorscolors
LUTLUT
ViewingViewing
Camera and objects are specified Camera and objects are specified independently.independently.
For a 2D world - define viewing or clipping For a 2D world - define viewing or clipping rectangle.rectangle. Objects inside will be seen.Objects inside will be seen. Objects outside will not be seen.Objects outside will not be seen.
For a 3D world - define a viewing volume.For a 3D world - define a viewing volume. Orthographic projection.Orthographic projection.
Matrix ModesMatrix Modes
Pipeline graphics dependent on Pipeline graphics dependent on concatenating a number of concatenating a number of transformation matrices.transformation matrices.Vertices Transformer Clipper Projector Rasterizer PixelsVertices Transformer Clipper Projector Rasterizer Pixels
Matrices Matrices model-viewmodel-view projectionprojection
Clients and ServersClients and Servers
Graphics server Graphics server Workstation with raster display , keyboard, Workstation with raster display , keyboard,
and pointing deviceand pointing device Provides input and output services for Provides input and output services for
networknetwork
Client Client OpenGL application programsOpenGL application programs
Display ListsDisplay Lists
From display processor From display processor A special purpose computerA special purpose computer
Host computer sent instructions to the display processorHost computer sent instructions to the display processor Instructions stored in display memory as a display file or a Instructions stored in display memory as a display file or a
display listdisplay list
Immediate modeImmediate mode Program defines a primitiveProgram defines a primitive Primitive sent to server for displayPrimitive sent to server for display No memory of primitive existsNo memory of primitive exists
Display ListsDisplay Lists Retained mode graphicsRetained mode graphics
Define object onceDefine object once Put description in a display listPut description in a display list Display list stored on the serverDisplay list stored on the server Redisplayed by a single function callRedisplayed by a single function call AdvantageAdvantage
Reduced network trafficReduced network traffic DisadvantageDisadvantage
Memory required on the serverMemory required on the server Creating the display list has overheadCreating the display list has overhead
Display ListsDisplay Lists
Creation of a display list - use glNewList, Creation of a display list - use glNewList, glEndList to encapsulate the list.glEndList to encapsulate the list.
Each list has an int identifier which can be Each list has an int identifier which can be invoked with the command glCallList(identifier);invoked with the command glCallList(identifier);
Save attributes with the matrix and attribute Save attributes with the matrix and attribute stacks (remember from 202: push onto a stack stacks (remember from 202: push onto a stack and pop off of a stack).and pop off of a stack).
InteractionInteraction
According to Webster’sAccording to Webster’s To act upon each otherTo act upon each other
Two way communicationTwo way communication GLUT toolkit for windowingGLUT toolkit for windowing GLUT recognizes only a small subset of GLUT recognizes only a small subset of
the events recognized by X the events recognized by X
InputInput
Input devicesInput devices Logical devicesLogical devices
From the perspective of the application programFrom the perspective of the application program
Physical devicesPhysical devices Hardware and how it worksHardware and how it works
Input ModesInput Modes
Mode defined by the relationship between the Mode defined by the relationship between the trigger and the measuring process.trigger and the measuring process. Trigger (physical input that user signals computer).Trigger (physical input that user signals computer). Measure (what is returned to the program).Measure (what is returned to the program).
Request mode.Request mode. Measure returned when triggered.Measure returned when triggered.Trigger Trigger measuremeasure request request program.program.
Process triggerProcess trigger process measure.process measure.
Input ModesInput Modes
Sample modeSample mode Measure returned when triggeredMeasure returned when triggered
MeasureMeasure samplesample programprogramProcess Process measuremeasure
Event modeEvent mode Device triggeredDevice triggered Event generatedEvent generated Device measure placed on the event queueDevice measure placed on the event queue Event type tied to function called CALLBACK Event type tied to function called CALLBACK
Input ModesInput Modes
Trigger Trigger measure measure event event await program.await program.
Process trigger process measure queue Process trigger process measure queue event.event.
Event mode.Event mode. Device triggered.Device triggered. Event generated.Event generated. Device measure placed on the event queue.Device measure placed on the event queue. CALLBACK registered with the windowing system. CALLBACK registered with the windowing system.
Event type tied to function called a callback.Event type tied to function called a callback.
Using the Pointing Device Using the Pointing Device MMouse Triggered Eventsouse Triggered Events
Move eventMove event Move the mouse with the buttons depressedMove the mouse with the buttons depressed
Passive move eventPassive move event Move the mouse without pressing a buttonMove the mouse without pressing a button
Mouse eventMouse event When one of the buttons is either released When one of the buttons is either released
or pressedor pressed
Specify the Mouse Specify the Mouse Callback FunctionCallback Function
InIn main()main()
With With glutMouseFunc(mouse_callback_func)glutMouseFunc(mouse_callback_func) void mouse_callback_func(int button, int void mouse_callback_func(int button, int state, int x, int, y)state, int x, int, y)
The callback function specifies what actions The callback function specifies what actions are related to the specified eventare related to the specified event
Window EventWindow Event
Generated when the window is resized Generated when the window is resized Redraw all the objects in the windowRedraw all the objects in the window How to handle the aspect ratioHow to handle the aspect ratio Do we change the sizes or attributes of the Do we change the sizes or attributes of the
new primitives if the size of the new window new primitives if the size of the new window is different from that of the oldis different from that of the old
Keyboard EventsKeyboard Events
Generated when the mouse is in the Generated when the mouse is in the window and one of the keys is depressedwindow and one of the keys is depressed
Returns the ascii code for the key and Returns the ascii code for the key and the x and y coordinates of thethe x and y coordinates of the mouse mouse
void keyboard(unsigned char key, int x, void keyboard(unsigned char key, int x, imt y)imt y)
Display CallbackDisplay Callback
Invoked when GLUT determines the Invoked when GLUT determines the window should be redisplayedwindow should be redisplayed Upon opening it initiallyUpon opening it initially
Idle FunctionIdle Function
Idle callback invoked when there are no other Idle callback invoked when there are no other events.events. Generates graphical primitives through a display Generates graphical primitives through a display
function while nothing else is happening.function while nothing else is happening. Event processing happens between calls to the idle Event processing happens between calls to the idle
function.function. Do not spend too much time in the idle function.Do not spend too much time in the idle function.
Idle does not actually rerender the frame.Idle does not actually rerender the frame. To rerender callTo rerender call glutPostRedisplay();glutPostRedisplay(); from from
within the idle callback.within the idle callback.
MenusMenus
GLUT provides popup menusGLUT provides popup menus glutCreateMenu(menu_callback_name);glutCreateMenu(menu_callback_name);
Menu_callback_name is the name of the Menu_callback_name is the name of the function. The argument to that function is the function. The argument to that function is the identifier passed to the callback when the entry isidentifier passed to the callback when the entry is selectedselected
Adding a MenuAdding a Menu
glutCreateMenuglutCreateMenu
(menu_callback_name);(menu_callback_name);
glutAddMenuEntry("quit",1);glutAddMenuEntry("quit",1);
glutAttachMenuglutAttachMenu
(GLUT_RIGHT_BUTTON);(GLUT_RIGHT_BUTTON);
Adding a menu callbackAdding a menu callback
menu_callback_name(int id)menu_callback_name(int id)
{{
if (id == .if (id == .
..
..
}}
AnimationAnimation
Double buffering eliminates flicker.Double buffering eliminates flicker.
Callback Advice From the Callback Advice From the Creator of GLUT, Mark Creator of GLUT, Mark KilgardKilgard
Don’t change state that will affect the way a Don’t change state that will affect the way a window will be drawn a display callback. window will be drawn a display callback.
If you need to redisplay a window, instead of If you need to redisplay a window, instead of rendering in whatever callback you happen to rendering in whatever callback you happen to be in, call glutPostRedisplay.be in, call glutPostRedisplay.
If you use an idle callback to control animation, If you use an idle callback to control animation, use a visibility callback to determine when the use a visibility callback to determine when the window is fully obscured or iconified.window is fully obscured or iconified.
More Callback AdviceMore Callback Advice
The backspace, Esc, and Del keys The backspace, Esc, and Del keys generate ASCII characters, so detect key generate ASCII characters, so detect key presses for these keys using the presses for these keys using the glutKeyboardFuncglutKeyboardFunc callback. callback.
Design of InteractiveDesign of Interactive ProgramsPrograms
A smooth display (no flicker or artifacts of the refresh A smooth display (no flicker or artifacts of the refresh process)process)
A variety of interactive devices on the displayA variety of interactive devices on the display A variety of methods for entering and displaying A variety of methods for entering and displaying
informationinformation An easy to use interface that does not require An easy to use interface that does not require
substantial effort to learnsubstantial effort to learn Feedback to the userFeedback to the user Tolerance for user errorsTolerance for user errors A design incorporation for consideration of both the A design incorporation for consideration of both the
visual and motor properties of the humanvisual and motor properties of the human
Limitations of Geometric RenderingLimitations of Geometric Rendering
Designing widgetsDesigning widgets example of popup menuexample of popup menu refreshing the display where the menu wasrefreshing the display where the menu was no primitives but uses scan line image datano primitives but uses scan line image data
operations described in terms of the frame buffer operations described in terms of the frame buffer or in terms of bit-block transferor in terms of bit-block transfer operationoperation
Limitations of GeometricLimitations of Geometric RenderingRendering
RubberbandingRubberbanding a technique for displaying line segments in a a technique for displaying line segments in a
changing manner. changing manner. Endpoint is selected Endpoint is selected Before second endpoint is selected a line Before second endpoint is selected a line
segment is drawn automatically to where the segment is drawn automatically to where the present position of the mouse ispresent position of the mouse is
As the mouse moves the old segment must be As the mouse moves the old segment must be erased and a new one drawn.erased and a new one drawn.
HomeworkHomework
Read chapter 4 Read chapter 4 Program 2 due 02/01/05Program 2 due 02/01/05