Graphics Reference
In-Depth Information
Handling OpenGL Extensions
At this time, shader programming with GLSL is new enough that many of the
GLSL API calls are handled through OpenGL extensions. In order to manage
extensions in a cross-platform way, we can use the OpenGL Extension Wrangler
Library ( GLEW ). GLEW provides efficient run-time mechanisms for determin-
ing which OpenGL extensions are supported on the target platform. OpenGL
core and extension functionality is exposed in a single header file. GLEW
changes often to keep up with OpenGL developments. You can download
GLEW from htp://glew.sourceforge.net you should check for new GLEW
releases frequently.
In this chapter, we will refer to some GLSL functions that may be either
EXT or ARB functions (that is, may not yet be fully integrated into the OpenGL
standard), but GLEW will handle that and will replace a function name like
glCreateProgram( ) with glCreateProgramEXT( ) or glCreateProgramARB( )
if either of those is the appropriate one for your system. In this chapter, we will
only use the general function names and will leave EXT or ARB details up to
GLEW.
You need to initialize GLEW in your application, probably in the func-
tion where you initialize your OpenGL system. The code below will do that
for you.
#include “glew.h“
. . .
GLenum err = glewInit( );
if( err != GLEW_OK )
{
fprintf( stderr, “glewInitError\n” );
exit( 1 );
}
fprintf( stderr,“GLEW initialized OK\n” );
fprintf( stderr,”Status: Using GLEW %s\n”,glewGetString(GLEW_
VERSION) );
How Is a GLSL Shader Program Created?
The usual way of creating shader functionality is to create a collection of differ-
ent types of shaders (e.g., vertex, tessellation, geometry, fragment) and collect
Search WWH ::




Custom Search