init of glew

Is there another way to initialize glew successfully (by glewInit(), without an no-gl-version-error) beside the way using glut to create a window.
I need to init glew for a library in that no window cration function exists. But of course I have access to the handle of that certain window where the program is supposed to run in.

Any ideas?


Are you using the most recent version of GLEW?

You need to initialize GLEW after you create your OpenGL context, otherwise you’ll get error(s). See the GLEW documentation for additional information.

I’ve used GLEW in Cocoa ( OS X ) as well as simple GLUT testbeds, and as far as I can tell, all that matters is that you call glewInit sometime after a context is created ( and made current ) and before you make any opengl calls.

Probably, you could get away with calling it the first time your draw command is invoked, since by then you know your context is active, but I could be wrong. If you do that, you’d better make sure the caller isn’t calling glClear or anything else before handing off to your code.

Calling functionality from 1.1 will be fine since it isn’t initialized through function pointers. The 1.1 content is provided through prototypes and doesn’t need to be initialized. Calling glClear won’t hurt anything. You will need to be sure glewInit is called before using calls from 1.2 or greater, or from extensions.

It sounds like you are putting this in some library code that is not utilizing glut. If that is the case, give your library an initContext method and have your users call it for each context before rendering.

Putting it into the first call to render will cause you problems if you have different contexts that may have different capabilities or function entry points.