Post by m***@yahoo.comAs I couldn't find examples on how to use extensions directly I
ended up using glew. I still do not undestand what glew does
for me but apparently initialise all these extensions so they
become available in the program. Although indeed when I look at
some examples that compile under Windows, it seems that
extensions are initialized using wglGetProcAddress but I should
left that to another thread.
It fit's here IMHO. An extension to OpenGL consists of several
additions and changes to the OpenGL specification, introducing
new Tokens (a token are OpenGL enumeration constants like
GL_TEXTURE_1D or GL_TEXTURE_MIN_FILTER or, GL_LIGHT1 or
GL_LIGHTING), new Procedures and dependencies within OpenGL
itself.
To access an extension you only need the Tokens and the
Procedures.
The Tokens are added by e.g.
#define GL_FOOBAR_BLA_EXT 0x....
A Procedure is accessed by a function pointer type, e.g.
typedef GLvoid (*PFNGLFOOFOO_BLAPROC)(GLenum foo, GLuint bar);
typedef GLvoid (*PFNGLBARBAR_BLAPROC)(GLint foo, GLuint bar);
and the pointer itself
PFNGLFOOFOO_BLAPROC glFooFooBLA = NULL;
PFNGLBARBAR_BLAPROC glBarBarBLA = NULL;
After getting a valid OpenGL context and testing for presence of
the extension by checking the string returened by
glGetString(GL_EXTENSIONS) you retrieve the address of the
procedure with wglGetProcAddress (Windows) glXGetProcAddress
(X11 based Systems, i.e. Linux, all *nix, *BSD),
aglGetProcAddress (Apple).
if(strstr(glGetString(GL_EXTENTIONS), "GL_BLA_foo")!=NULL)
{
glFooFooBLA = wglGetProcAddress("glFooFooBLA");
glBarBarBLA = wglGetProcAddress("glBarBarBLA");
}
Post by m***@yahoo.comIt's frustrating because despite
all the docs/books and tutorials which are out there, there's
none that seem to explain you clearly step by step how those
things work. For example the orange book tells you how to write
GlSl shaders but doesn't really provide you with a complete
openGl c program that shows you how to use them in the context
of a functional program.
Appendix C (in the 3rd Edition) of the red book tells you
everything you need to know.
Wolfgang Draxinger
--