Computer Graphics - PowerPoint PPT Presentation

1 / 14
About This Presentation
Title:

Computer Graphics

Description:

Initialize the GLUT library and negotiate a session with the window system ... When GLUT determines that the normal plane for the window needs to be ... – PowerPoint PPT presentation

Number of Views:19
Avg rating:3.0/5.0
Slides: 15
Provided by: billj2
Category:

less

Transcript and Presenter's Notes

Title: Computer Graphics


1
Computer Graphics
  • OpenGL

2
What is OpenGL?
  • A low-level graphics library specification
  • designed for use with the C and C
  • provides
  • a set of commands that allow the specification
    of geometric objects in two or three dimensions
  • graphics primitives
  • commands that control how these objects are
    rendered into the frame buffer

3
Libraries
Gl.h
  • gl.h - GL foundation
  • glu.h - GL utilities
  • glaux.h - GL auxiliary
  • glut.h - GL utility toolkit

Glaux.h
Glu.h
Glut.h
4
What does GLUT do for us?
  • Allows us to initialize a GL program using fewer
    function calls than with just GL
  • Allows us to still access the lower level GL, GLU
    and GLAUX calls

5
GLUT main( )
Command-line arguments
  • void main(int argc, char argv)
  • glutInit(argc, argv)
  • glutInitDisplayMode(GLUT_DOUBLE GLUT_RGB
    GLUT_DEPTH)
  • glutInitWindowSize(100,100)
  • glutInitWindowPosition(0,0)
  • glutCreateWindow("GL Example")
  • init()
  • glutDisplayFunc(display)
  • glutReshapeFunc(reshape)
  • glutIdleFunc(animate)
  • glutMouseFunc(handleEvent)
  • glutMainLoop()

Display mode tokens
Window size and position
Creates window
Specifies display, reshape, idle and mouse
functions
Starts execution
6
glutInit ( )
  • Initialize the GLUT library and negotiate a
    session with the window system
  • May cause the termination of the GLUT program
    with an error message to the user if GLUT cannot
    be properly initialized
  • Processes command line options, but the specific
    options parse are window system dependent.

7
glutInitDisplayMode( )
  • GLUT_RGB
  • Bit mask to select an RGBA mode window. This is
    the default if neither GLUT_RGBA nor GLUT_INDEX
    are specified.
  • GLUT_SINGLE /GLUT_DOUBLE
  • Bit mask to select a single buffered or double
    buffered window.
  • GLUT_DEPTH
  • Bit mask to select a window with a depth buffer.
  • GLUT_STEREO
  • Bit mask to select a stereo window.

8
glutInitWindowSize(int width,int
height)glutInitWindowPosition(int x,int
y)glutCreateWindow(Title)
  • Windows created by glutCreateWindow will be
    requested to be created with the current initial
    window position (x,y) and size (width,height)

9
init( )
  • void init (void)
  • // Additional user specified GL calls, such as
    ...
  • glClearColor(1,1,1,0.0)
  • glShadeModel(GL_SMOOTH)

10
glutDisplayFunc( )
  • Sets the display callback for the current window
  • When GLUT determines that the normal plane for
    the window needs to be redisplayed, the display
    callback for the window is called
  • Before the callback, the current window is set to
    the window needing to be redisplayed and (if no
    overlay display callback is registered) the layer
    in use is set to the normal plane.

11
glutReshapeFunc( )
  • Sets the reshape callback for the current window
  • The reshape callback is triggered when a window
    is reshaped
  • A reshape callback is also triggered immediately
    before a window's first display callback after a
    window is created or whenever an overlay for the
    window is established
  • The width and height parameters of the callback
    specify the new window size in pixels
  • Before the callback, the current window is set to
    the window that has been reshaped

12
glutIdleFunc( )
  • Sets the global idle callback so a GLUT program
    can perform background processing tasks or
    continuous animation when window system events
    are not being received
  • If enabled, the idle callback is continuously
    called when events are not being received

13
glutMouseFunc( )
  • Sets the mouse callback for the current window
  • When a user presses and releases mouse buttons in
    the window, each press and each release generates
    a mouse callback
  • The button parameter is one of GLUT_LEFT_BUTTON,
    GLUT_MIDDLE_BUTTON, or GLUT_RIGHT_BUTTON
  • The state parameter is either GLUT_UP or
    GLUT_DOWN
  • The x and y callback parameters indicate the
    window relative coordinates when the mouse button
    state changed

14
glutMainLoop( )
  • Enters the GLUT event processing loop
  • This routine should be called at most once in a
    GLUT program
  • Once called, this routine will never return
  • It will call as necessary any callbacks that have
    been registered
Write a Comment
User Comments (0)
About PowerShow.com