OpenGL (1.2 - 2.0) Code Samples - Page 6

Optimizing Meshes
 

This sample demonstrates how to optimize a regular triangle mesh by using a combination of indexed geometry, tri-strips, and degenerate triangles.

Relevant Keywords: glInterleavedArrays, glDrawElements, glDrawArrays, GL_TRIANGLE_STRIP, GL_T2F_C3F_V3F, GL_UNSIGNED_INT, and GL_TRIANGLES.

 

Stanford Bunny Data Set
 

This sample demonstrates how to make use of the useful Stanford Bunny model or data set for testing and prototyping purposes.

 

Point Sprites
 

This sample demonstrates how to use the OpenGL's ARB_point_sprite extensions to create point sprites. Point sprites are hardware-accelerated billboards, which are capable of being textured. Point sprites are ideal for creating high-performance particle systems because you only have to send a single vertex point or point sprite for each particle instead of four vertices for a regular billboarded quad. Point sprites also do all the math involved in view aligning the final quad on the GPU instead of the CPU. See the Particle System sample on this page for a more complex example of their usage. Check out the DirectX9 source code page for the Direct3D equivalent of this sample.

Relevant Keywords: GL_NV_point_sprite, glPointParameterfARB, glPointParameterfvARB, glPointSize, wglGetProcAddress, glGetString, glGetFloatv, auxDIBImageLoad, glGenTextures, glBindTexture, glTexParameteri, glTexImage2D, glEnable, glBindTexture, AUX_RGBImageRec, GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_TEXTURE_MAG_FILTER, GL_LINEAR, GL_UNSIGNED_BYTE, GL_EXTENSIONS, PFNGLPOINTPARAMETERFARBPROC, PFNGLPOINTPARAMETERFVARBPROC, GL_POINT_SIZE_MAX_ARB, GL_BLEND, GL_SRC_ALPHA, GL_ONE, GL_POINT_DISTANCE_ATTENUATION_ARB, GL_POINT_SIZE_MIN_ARB, GL_POINT_SIZE_MAX_ARB, GL_COORD_REPLACE_ARB, and GL_POINT_SPRITE_NV.

 

Particle System
 

Adding a particle system to your game engine has become all the rage, but where do you start? Here of course! This sample demonstrates how to create a particle system class which uses OpenGL's ARB_point_sprite extension to create hardware accelerated point sprites. To learn more about point sprites, check out the Point Sprites sample on this page. Check out the DirectX9 source code page for the Direct3D equivalent of this sample.

Relevant Keywords: GL_NV_point_sprite, glPointParameterfARB, glPointParameterfvARB, glPointParameteriNV, glPointParameterivNV, glPointSize, wglGetProcAddress, glGetString, glGetFloatv, auxDIBImageLoad, glGenTextures, glBindTexture, glTexParameteri, glTexImage2D, glEnable, glBindTexture, AUX_RGBImageRec, GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_TEXTURE_MAG_FILTER, GL_LINEAR, GL_UNSIGNED_BYTE, GL_EXTENSIONS, PFNGLPOINTPARAMETERFARBPROC, PFNGLPOINTPARAMETERFVARBPROC, GL_POINT_SIZE_MAX_ARB, GL_BLEND, GL_SRC_ALPHA, GL_ONE, GL_POINT_DISTANCE_ATTENUATION_ARB, GL_POINT_SIZE_MIN_ARB, GL_POINT_SIZE_MAX_ARB, GL_COORD_REPLACE_ARB, and GL_POINT_SPRITE_NV.

 

Particle System Using Optimized Billboards
 

This sample is basically a performance test for particle systems, which allows you to switch between three different methods of creating eye-rotated billboards. For the first method, billboard calculations are done manually and take place totally on the CPU by the application. For the second method, the particle system uses ARB_point_sprite extension to offload the creation of billboards to the GPU. And finally, the third method uses Cg to build billboards on the GPU via a vertex shader.