OpenGL core profile question

Started by
5 comments, last by jsvcycling 11 years ago

I'm trying to learn the modern opengl with the core profile (+3.x) but I don't know the best way to initialize the opengl extensions.

Glew was a headache for me. I initialized it (and enabled glew experimental) but for some reason I had problems generating vertex arrays. I think it's because I defined the opengl profile to core profile with glfw, but I'm not sure.

There is a good opengl core profile tutorial?

By the way, I'm using windows 7 64bits with Visual C++ 2010 express.

Thanks in advance.

Advertisement

The OpenGL wiki itself has a few tutorials on the subject, though they're not using glfw.

Though I'd guess that the way you use vertex arrays or something related is the problem itself - if you got the context without any errors, it was probably working correctly. The OpenGL vertex array object thing makes no sense anyways. I'd double check that you're actually getting an error of some sort from GLFW or GL related to context creation, not the rendering code itself, before jumping into conclusions. Checking for errors is usually a good idea anyway.

The way I like to use OpenGL extensions is with a small offline script that generates me a header with all the function pointers and a function to load all the extensions based on a core specification I give as a parameter. It took a couple of nights to code, but works like a charm and whenever the ARB releases a new header, I can just ask for the new core (when the drivers arrive, of course) without being tied to anyone elses code.

The OpenGL wiki has a page on some of the common extension loading libraries as well as a page on loading extensions manually.

I know you already said that you dislike GLEW, but maybe you should post some code so we can find out why it isn't working. I've used both GLEW and GL3W with OpenGL 3.X before and have had no major problems. Try adding some error checking code:



GLenum err = glewInit();
if (GLEW_OK != err)
{
  /* Problem: glewInit failed, something is seriously wrong. */
  fprintf(stderr, "Error: %s\n", glewGetErrorString(err));
}

You could also attempt to load a specific extension as described here.

Some favourite quotes:Never trust a computer you can't throw out a window.
- Steve Wozniak

The best way to prepare [to be a programmer] is to write programs, and to study great programs that other people have written.
- Bill Gates

There's always one more bug.
- Lubarsky's Law of Cybernetic Entomology

Think? Why think! We have computers to do that for us.
- Jean Rostand

Treat your password like your toothbrush. Don't let anybody else use it, and get a new one every six months.
- Clifford Stoll

To err is human - and to blame it on a computer is even more so.
- Robert Orben

Computing is not about computers any more. It is about living.
- Nicholas Negroponte

The OpenGL wiki has a page on some of the common extension loading libraries as well as a page on loading extensions manually.

I know you already said that you dislike GLEW, but maybe you should post some code so we can find out why it isn't working. I've used both GLEW and GL3W with OpenGL 3.X before and have had no major problems. Try adding some error checking code:



GLenum err = glewInit();
if (GLEW_OK != err)
{
  /* Problem: glewInit failed, something is seriously wrong. */
  fprintf(stderr, "Error: %s\n", glewGetErrorString(err));
}

You could also attempt to load a specific extension as described here.

Thank you.

But I always get an access violation when trying to generate something. (glGenVertexArray, glGenBuffer, even glCreateShader).

Do you know why I get this kind of errors?

For core profiles glew is kinda hit miss afaik. It doesn't support them cleanly. So it is usullay preferable to use a loader like gl3w or glxw.

But I always get an access violation when trying to generate something. (glGenVertexArray, glGenBuffer, even glCreateShader).

Do you know why I get this kind of errors?

Is your rendering context properly created and current?

Is it possible to you can post the relevent information from the output window during a build (preferably debug)?

I did a quick search for GLEW with OpenGL 3.X tutorials and ran across this page. I'm know that you are using GLFW and this uses Win32/MFC, but maybe the GLEW parts can help you to check against your own code.

Another thought that just popped into my head is that maybe GLFW is interfering with GLEW (or vice versa). If its possible, try switching out GLFW for SDL or SFML (or even freeglut) and try testing it again.

If all else fails, it might just be easier to switch to GL3W.

EDIT: I was just browsing through the forums here and found this thread where the OP has a similar problem to the one you are describing. It may or may not help, but I'm just gonna put it out there for you. You can check the final post for his resolution to the problem.

Some favourite quotes:Never trust a computer you can't throw out a window.
- Steve Wozniak

The best way to prepare [to be a programmer] is to write programs, and to study great programs that other people have written.
- Bill Gates

There's always one more bug.
- Lubarsky's Law of Cybernetic Entomology

Think? Why think! We have computers to do that for us.
- Jean Rostand

Treat your password like your toothbrush. Don't let anybody else use it, and get a new one every six months.
- Clifford Stoll

To err is human - and to blame it on a computer is even more so.
- Robert Orben

Computing is not about computers any more. It is about living.
- Nicholas Negroponte

This topic is closed to new replies.

Advertisement