1 / 9

GAM666 – Introduction To Game Programming

GAM666 – Introduction To Game Programming. Introduction to OpenGL. OpenGL is an alternative to Direct3D for 3D graphics rendering Originally developed by Silicon Graphics Inc (SGI), turned over to multi-vendor group (OpenGL Architecture Review Board) in 1992

Télécharger la présentation

GAM666 – Introduction To Game Programming

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. GAM666 – Introduction To Game Programming Introduction to OpenGL • OpenGL is an alternative to Direct3D for 3D graphics rendering • Originally developed by Silicon Graphics Inc (SGI), turned over to multi-vendor group (OpenGL Architecture Review Board) in 1992 • Unlike DirectX, OpenGL is platform independent, with implementations in Linux, Unix and Mac as well as Windows • Can be mixed and matched with non-DirectX Graphics parts of DirectX such as DirectInput and DirectX Audio

  2. GAM666 – Introduction To Game Programming Introduction to OpenGL • Even though OpenGL is platform independent, the framework from which you call it is very much platform determined • GLUT provides a platform independent framework from which you can call OpenGL, but isn't intended to be full featured • GLUT should not be confused with GLU, which are some helper functions to assist with using OpenGL, similar to Direct3D's D3DX functions • The Windows functions wglCreateContext() and wglMakeCurrent() get OpenGL started in a normal Windows framework

  3. GAM666 – Introduction To Game Programming Introduction to OpenGL • OpenGL has its own data types, e.g. • GLfloat (float) • GLint (int) • GLuint (unsigned int) • OpenGL functions begin with gl, e.g. • glClear() • glDrawArrays() • GLU functions begin with glu, e.g. • gluLookAt() • gluPerspective()

  4. GAM666 – Introduction To Game Programming Introduction to OpenGL • The end of function names often have meaning as well: • A name ending with f usually has GLfloat parameters, while the same name only, ending with i, has GLint parameters • A name ending with, e.g., f may take a number of GLfloat parameters while the same name, only ending with fv, will take an array (vector) of GLfloat values

  5. GAM666 – Introduction To Game Programming Introduction to OpenGL The OpenGL view is similar but different from the Direct3D view: • The z axis comes out from the screen rather than going into it • A point or vector is represented with a 4x1 matrix rather than a 1x4, and all matrix operations are reversed • Matrices are stored in column major format rather than the regular C-style row major format (i.e. matrices are transposed)

  6. GAM666 – Introduction To Game Programming Introduction to OpenGL The OpenGL view is similar but different from the Direct3D view: • Vertex information is stored as a series of parallel arrays in system memory rather than an array of structures somewhere else • Triangle culling normally disabled by default, and if you turn it on, it draws the counter-clockwise side rather than the clockwise side by default

  7. GAM666 – Introduction To Game Programming Introduction to OpenGL OpenGL is state-based, so you usually set a few states then do something, rather than pass a whole bunch of parameters with each operation, e.g. • There are two transformation matrices rather than three (Projection and Model/View), and to change one: • first set the matrix state, e.g. glMatrixMode(GL_PROJECTION) • then change that matrix, e.g. glLoadMatrixf(array)

  8. GAM666 – Introduction To Game Programming Introduction to OpenGL • Each type of transformation matrix has a stack of matrices, where the top of the stack is the current active one • glPushMatrix() duplicates the current active matrix, putting the copy onto the top of the stack • glPopMatrix() gets rid of the current active matrix, restoring the previous one to active duty • The GL_PROJECTION stack is at least 2 deep, the GL_MODELVIEW stack is at least 32 deep

  9. GAM666 – Introduction To Game Programming Introduction to OpenGL • Since the Model/View matrix replaces the purpose of both the View and World matrices of Direct3D, the usual drawing technique is: • Set the Model/View to the view matrix, then for each object • Push a copy of the Model/View matrix onto the top of the stack • Multiply by the object's world matrix • Draw the object • Pop the stack (restoring the view matrix) thereby getting ready for the next object

More Related