PDA

View Full Version : How to: from OpenGL 2.1 to 3.3 core?



Golgoth
04-19-2011, 09:18 PM
Greetings,

To get started, I would like to know, if possible, how to force 3.3 core with Glew?

If not, is there any example I can chew on, using gl3.h?

Thank you

mobeen
04-19-2011, 09:40 PM
http://www.arcsynthesis.org/gltut/index.html

Golgoth
04-19-2011, 10:48 PM
Ok thank you, can you be a little more specific?

mobeen
04-19-2011, 11:33 PM
For OpenGL 3 context creation, you need the latest version of freeglut and glew. Your main function is as follows,


void main(int argc, char** argv) {
glutInit(&argc, argv);
glutInitContextVersion(3,3);
glutInitContextProfile(GLUT_CORE_PROFILE);
glutInitContextFlags(GLUT_FORWARD_COMPATIBLE);

glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH );
glutInitWindowSize(width, height);
glutCreateWindow("Demo OpenGL 3.3");
GLenum err = glewInit();
if (GLEW_OK != err) {
cerr<<"GLEW Error: <<glewGetErrorString(err)<<endl;
return 1;
}
// Only continue, if OpenGL 3.3 is supported.
if (!glewIsSupported("GL_VERSION_3_3"))
{
cerr<<"OpenGL 3.3 not supported."<<endl;
exit(EXIT_FAILURE);
} else {
cout<<"OpenGL 3.3 supported."<<endl;
}

//attach your callbacks setup OpenGL initialization stuff

glutMainLoop();
}

Golgoth
04-20-2011, 08:24 AM
Hi mobeen, I see, but what if I donít want to use Glut or FreeGlut? Using SFML or SDL.

_arts_
04-21-2011, 12:18 AM
Then have a look at their own site if their latest version allow the creation of GL 3 contexts. As far as I remember, SDL has planned to do so or has experimental release of this. Don't know about SFML.

mobeen
04-21-2011, 01:09 AM
SFML v2 handles opengl3 as given here http://www.sfml-dev.org/forum/viewtopic.php?t=1817&amp;sid=339613d0b27611eddb554cc36 5cb819e
Moreover, this blog entry tells u how to create an opengl3 context in sfml. http://rastergrid.com/blog/2010/01/flawless-alternative-to-sdl/

Golgoth
04-21-2011, 07:40 AM
Alright, thank you very much!