Using OpenGL without GLEW

I’m trying to use OpenGL without the use of glew. The reason is that I want to modify the plotting in octave (a matlab clone) and I run into problems with shared libraries when I try to include GLEW and then compile.

The rendering in the application is now done with deprecated functionality and I want to use OpenGL 3.3 in the parts that I implement. Any ideas on how to manage this? I’m really quite confused on the point of loading functions in OpenGL, usually I’ve just included glew.h and haven’t thought much about what it does. I read the thread http://www.opengl.org/discussion_boards/…;gonew=1#UNREAD
but I’m still not quite sure how I can manage without glew.

Do I have to manually load OpenGL functions? And if yes, are there any examples which shows this? I think I’ve seen gl code before that doesn’t use glew or glXGetProcAddress, how is this possible?

First of all, term “loading extensions” is not adequate. It is in common use, but it is not correct. You have to “grab” pointers to a functions exposed by the driver. Don’t worry, it is quite easy.

Take a look at this:
Introduction to Opengl 3.2
Although it is for Windows, I guess you’ll get the basic skills.

I think I’ve seen gl code before that doesn’t use glew or glXGetProcAddress, how is this possible?

On Windows it is possible for GL 1.1 functionality only. GL 1.1 is not exposed through the extensions, but it is a part of WinAPI.

First of all, term “loading extensions” is not adequate. It is in common use, but it is not correct. You have to “grab” pointers to a functions exposed by the driver. Don’t worry, it is quite easy.

Take a look at this:
Introduction to Opengl 3.2
Although it is for Windows, I guess you’ll get the basic skills.
[/QUOTE]
That didn’t look too hard, thanks! Things are never easy though, I’m a linux user, so I have a few questions:

Is the #include “stdafx.h” something windows specific?

And are you creating the ogl.h and ogl.cc files in the project folder? I’ll give this a go as soon as I’m back at my own computer!

This is perhaps a more thorough, platform-neutral discussion of how to do it. Though honestly, if you’re having problem linking libraries to your project, you should fix that first.

It is a VS specific pre-compiled header. You don’t need it.

Yes, but it is not important. ogl.h/.cpp are used just to define global (extern) pointers (i.e. function names) visible from all files/classes.

Basically, you just have to do the following:


#include "glext.h"
#include "glxext.h"

// For each function you need, grab the pointer
PFNGLCREATEPROGRAMPROC glCreateProgram = NULL;
glCreateProgram =  (PFNGLCREATEPROGRAMPROC)wglGetProcAddress("glCreateProgram");

If the pointer is NULL, then the extension is not supported.

Also read Alfonse’s Wiki. It is well written. Just ignore the second sentence. :wink: