Program 2 due 02/01 - PowerPoint PPT Presentation

About This Presentation
Title:

Program 2 due 02/01

Description:

Double buffering eliminates flicker. Callback Advice From the Creator of GLUT, Mark Kilgard ... A smooth display (no flicker or artifacts of the refresh process) ... – PowerPoint PPT presentation

Number of Views:18
Avg rating:3.0/5.0
Slides: 30
Provided by: rei6
Learn more at: https://www.cs.unca.edu
Category:
Tags: due | flicker | program

less

Transcript and Presenter's Notes

Title: Program 2 due 02/01


1
Program 2 due 02/01
  • Be sure to document your program
  • program level doc
  • your name
  • what the program does
  • each function
  • describe the arguments
  • describe what the function does
  • document anything you may forget in a week

2
Indexed Color
  • Needed for frame buffers with a limited depth
  • 8 bits of color 28 colors 256 colors
  • default is dividing bits into rbg assignments
  • load color map with a pallette of 256 colors
  • LUT

3
Viewing
  • Camera and objects are specified independently.
  • For a 2D world - define viewing or clipping
    rectangle.
  • Objects inside will be seen.
  • Objects outside will not be seen.
  • For a 3D world - define a viewing volume.
  • Orthographic projection.

4
Matrix Modes
  • Pipeline graphics dependent on concatenating a
    number of transformation matrices.
  • Vertices Transformer Clipper Projector
    Rasterizer Pixels
  • Matrices
  • model-view
  • projection

5
Clients and Servers
  • Graphics server
  • Workstation with raster display , keyboard, and
    pointing device
  • Provides input and output services for network
  • Client
  • OpenGL application programs

6
Display Lists
  • From display processor
  • A special purpose computer
  • Host computer sent instructions to the display
    processor
  • Instructions stored in display memory as a
    display file or a display list
  • Immediate mode
  • Program defines a primitive
  • Primitive sent to server for display
  • No memory of primitive exists

7
Display Lists
  • Retained mode graphics
  • Define object once
  • Put description in a display list
  • Display list stored on the server
  • Redisplayed by a single function call
  • Advantage
  • Reduced network traffic
  • Disadvantage
  • Memory required on the server
  • Creating the display list has overhead

8
Display Lists
  • Creation of a display list - use glNewList,
    glEndList to encapsulate the list.
  • Each list has an int identifier which can be
    invoked with the command glCallList(identifier)
  • Save attributes with the matrix and attribute
    stacks (remember from 202 push onto a stack and
    pop off of a stack).

9
Interaction
  • According to Websters
  • To act upon each other
  • Two way communication
  • GLUT toolkit for windowing
  • GLUT recognizes only a small subset of the events
    recognized by X

10
Input
  • Input devices
  • Logical devices
  • From the perspective of the application program
  • Physical devices
  • Hardware and how it works

11
Input Modes
  • Mode defined by the relationship between the
    trigger and the measuring process.
  • Trigger (physical input that user signals
    computer).
  • Measure (what is returned to the program).
  • Request mode.
  • Measure returned when triggered.
  • Trigger measure request program.
  • Process trigger process measure.

12
Input Modes
  • Sample mode
  • Measure returned when triggered
  • Measure sample program
  • Process measure
  • Event mode
  • Device triggered
  • Event generated
  • Device measure placed on the event queue
  • Event type tied to function called CALLBACK

13
Input Modes
  • Trigger measure event await
    program.
  • Process trigger process measure queue
    event.
  • Event mode.
  • Device triggered.
  • Event generated.
  • Device measure placed on the event queue.
  • CALLBACK registered with the windowing system.
    Event type tied to function called a callback.

14
Using the Pointing Device Mouse Triggered Events
  • Move event
  • Move the mouse with the buttons depressed
  • Passive move event
  • Move the mouse without pressing a button
  • Mouse event
  • When one of the buttons is either released or
    pressed

15
Specify the Mouse Callback Function
  • In main()
  • With glutMouseFunc(mouse_callback_func)
  • void mouse_callback_func(int button, int state,
    int x, int, y)
  • The callback function specifies what actions are
    related to the specified event

16
Window Event
  • Generated when the window is resized
  • Redraw all the objects in the window
  • How to handle the aspect ratio
  • Do we change the sizes or attributes of the new
    primitives if the size of the new window is
    different from that of the old

17
Keyboard Events
  • Generated when the mouse is in the window and one
    of the keys is depressed
  • Returns the ascii code for the key and the x and
    y coordinates of the mouse
  • void keyboard(unsigned char key, int x, imt y)

18
Display Callback
  • Invoked when GLUT determines the window should be
    redisplayed
  • Upon opening it initially

19
Idle Function
  • Idle callback invoked when there are no other
    events.
  • Generates graphical primitives through a display
    function while nothing else is happening.
  • Event processing happens between calls to the
    idle function.
  • Do not spend too much time in the idle function.
  • Idle does not actually rerender the frame.
  • To rerender call glutPostRedisplay() from within
    the idle callback.

20
Menus
  • GLUT provides popup menus
  • glutCreateMenu(menu_callback_name)
  • Menu_callback_name is the name of the function.
    The argument to that function is the identifier
    passed to the callback when the entry is selected

21
Adding a Menu
  • glutCreateMenu
  • (menu_callback_name)
  • glutAddMenuEntry("quit",1)
  • glutAttachMenu
  • (GLUT_RIGHT_BUTTON)

22
Adding a menu callback
  • menu_callback_name(int id)
  • if (id .
  • .
  • .

23
Animation
  • Double buffering eliminates flicker.

24
Callback Advice From the Creator of GLUT, Mark
Kilgard
  • Dont change state that will affect the way a
    window will be drawn a display callback.
  • If you need to redisplay a window, instead of
    rendering in whatever callback you happen to be
    in, call glutPostRedisplay.
  • If you use an idle callback to control animation,
    use a visibility callback to determine when the
    window is fully obscured or iconified.

25
More Callback Advice
  • The backspace, Esc, and Del keys generate ASCII
    characters, so detect key presses for these keys
    using the glutKeyboardFunc callback.

26
Design of Interactive Programs
  • A smooth display (no flicker or artifacts of the
    refresh process)
  • A variety of interactive devices on the display
  • A variety of methods for entering and displaying
    information
  • An easy to use interface that does not require
    substantial effort to learn
  • Feedback to the user
  • Tolerance for user errors
  • A design incorporation for consideration of both
    the visual and motor properties of the human

27
Limitations of Geometric Rendering
  • Designing widgets
  • example of popup menu
  • refreshing the display where the menu was
  • no primitives but uses scan line image data
  • operations described in terms of the frame
    buffer or in terms of bit-block transfer
    operation

28
Limitations of Geometric Rendering
  • Rubberbanding
  • a technique for displaying line segments in a
    changing manner.
  • Endpoint is selected
  • Before second endpoint is selected a line segment
    is drawn automatically to where the present
    position of the mouse is
  • As the mouse moves the old segment must be erased
    and a new one drawn.

29
Homework
  • Read chapter 4
  • Program 2 due 02/01/05
Write a Comment
User Comments (0)
About PowerShow.com