1 / 13

OpenGL Help Session

OpenGL Help Session. CS248 Fall 2008 Derek Chan. OpenGL needs a windowing system. OpenGL by itself does not talk to the windowing system/manager by itself. Need a toolkit to tell the windowing system that we need an OpenGL window. Examples: GLUT/ GLUI (used in Project 2) ‏

thisbe
Download Presentation

OpenGL Help Session

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. OpenGL Help Session CS248 Fall 2008 Derek Chan

  2. OpenGL needs a windowing system OpenGL by itself does not talk to the windowing system/manager by itself. Need a toolkit to tell the windowing system that we need an OpenGL window. Examples: GLUT/ GLUI (used in Project 2)‏ SDL (more features: sound, image file loaders)‏ wxWidgets, Qt (full fledged widget toolkits, probably overkill for a game)‏

  3. OpenGL needs a windowing system What does the windowing toolkit handle? Opening a window in the OS Window resizing Mouse/ keyboard presses Mouse position/movement What does OpenGL do? - draw

  4. Drawing glBegin(): GL_POINTS GL_LINES GL_TRIANGLES Etc.

  5. Drawing glBegin(GL_LINES); glColor3f(r,g,b); glNormal3f(x,y,z); glTexCoord2d(u,v); glVertex3f(x,y,z); … glEnd();

  6. OpenGL function suffixes OpenGL functions that take different types of arguments while providing the same functionality will often have a suffix to denote which type of function they are: glVertex2i - input is 2 integers glVertex3fv - input is 3 floats in an array glVertex3f - input is 3 floats

  7. OpenGL Camera glFrustrum gluPerspective glOrtho gluOrtho2d glViewport gluLookAt

  8. OpenGL glEnable( )‏ glDisable( )‏ GL_DEPTH_TEST GL_BLEND GL_LIGHTING GL_LIGHT1

  9. OpenGL Find simple tutorials online OpenGL does many things which you might not know about Display Lists (glGenLists, glCallList)‏

  10. OpenGL extensions Extensions to the OpenGL base system often have their own suffixes. For example: glCreateProgramObjectARB(to create a shader program using an ARB extension)‏ Use GLEW (OpenGL Extension Wrangler) for easy access to extensions.

  11. Basic OpenGL Game Flowchart Load up an OpenGL window using a toolkit to talk to the windowing system Set up projection matrices, shading properties, etc. Load textures, etc. Event loop: Check for any events or user input and process them Redraw the OpenGL scene as necessary Wait a small amount of time.

  12. General Programming Advice have a math library use object oriented programming use c++ stl classes (or equivalent)‏

  13. Example Pitfalls Depth Testing vs blending (transperancies)‏ Texture dimensions – power of 2(fixed in more recent implementations of OpenGL)‏ Projection matrix should only be used for camera position, etc. It has a shorter stack than the Model-View matrix.

More Related