OpenGL (1.2 - 2.0) Code Samples - Page 1

Initialization
 

Demonstrates how to initialize OpenGL under the Win32 framework. This sample is by far the simplest of all OpenGL samples on this page. If you know nothing about OpenGL, you probably need to start here. Check out the DirectX9 source code page for the Direct3D equivalent of this sample.

Relevant Keywords: GetDC, ChoosePixelFormat, DescribePixelFormat, SetPixelFormat, GetLastError, wglCreateContext, wglMakeCurrent, wglDeleteContext, ReleaseDC, glClearColor, SwapBuffers, PIXELFORMATDESCRIPTOR, PFD_DRAW_TO_WINDOW, PFD_SUPPORT_OPENGL, PFD_DOUBLEBUFFER, PFD_TYPE_RGBA, nSize, nVersion, dwFlags, iPixelType, cColorBits, cDepthBits, GL_COLOR_BUFFER_BIT, and GL_DEPTH_BUFFER_BIT.

 

Full-Screen Initialization
 

This sample demonstrates how to probe the hardware for specific Display Settings and Pixel Formats suitable for a full-screen application with OpenGL. Check out the DirectX9 source code page for the Direct3D equivalent of this sample.

Relevant Keywords: EnumDisplaySettings, ChangeDisplaySettings, GetDC, ChoosePixelFormat, DescribePixelFormat, SetPixelFormat, GetLastError, wglCreateContext, wglMakeCurrent, wglDeleteContext, ReleaseDC, DEVMODE, DISP_CHANGE_SUCCESSFUL, CDS_TEST, ENUM_CURRENT_SETTINGS, dmPelsWidth, dmPelsHeight, dmBitsPerPel, and dmDisplayFrequency.

 

Primitive Types
 

This sample demonstrates how to use the 10 primitive types available under OpenGL: points, lines, line strip, line loop, triangles triangle strips, triangle fan, quads, quads strips, and polygon. Check out the DirectX9 source code page for the Direct3D equivalent of this sample.

Relevant Keywords: glInterleavedArrays, glDrawArrays, glCullFace, glEnable, GL_BACK, GL_CULL_FACE, GL_C4UB_V3F, GL_POINTS, GL_LINES, GL_LINE_STRIP, GL_LINE_LOOP, GL_TRIANGLES, GL_TRIANGLE_STRIP, GL_TRIANGLE_FAN, GL_QUADS, GL_QUAD_STRIP, and GL_POLYGON.

 

Vertex Data (Vertex Arrays)
 

Demonstrates how to use Vertex Arrays for the storage of model data. The sample creates a textured cube as an example. Check out the DirectX9 source code page for a Vertex Buffer sample which is Direct3D's equivalent of OpenGL's Vertex Arrays.

Relevant Keywords: glGenTextures, glBindTexture, glTexParameteri, glTexImage2D, glClearColor, glEnable, glMatrixMode, glLoadIdentity, gluPerspective, glRotatef, glInterleavedArrays, glDrawArrays, SwapBuffers, auxDIBImageLoad, AUX_RGBImageRec, GL_MODELVIEW, GL_PROJECTION, GL_TEXTURE_2D, GL_T2F_V3F, GL_QUADS, GL_COLOR_BUFFER_BIT, GL_DEPTH_BUFFER_BIT, GL_TEXTURE_2D, GL_DEPTH_TEST, GL_TEXTURE_MAG_FILTER, GL_TEXTURE_MIN_FILTER, GL_LINEAR, and GL_UNSIGNED_BYTE.

 

Multiple Vertex Arrays
 

This sample demonstrates how to create 3D geometry with OpenGL by loading vertex data into multiple Vertex Arrays. Check out the DirectX9 source code page for the Direct3D equivalent of this sample, which uses multiple Vertex Buffers.

Relevant Keywords: glEnableClientState, glDisableClientState, glDrawArrays, glVertexPointer, glColorPointer, glTexCoordPointer, GL_FLOAT, GL_VERTEX_ARRAY, GL_COLOR_ARRAY, and GL_TEXTURE_COORD_ARRAY.