Does SDL work with Opengl 3.2 ?

Started by
10 comments, last by kimi 13 years, 4 months ago
Hi all,

Can anyone tell me whether SDL works with OpenGL 3.2 I need to have some text and timer. I think SDL is easier but does it work with 3.2 ? Glut also does the same thing ? Is it compatible with 3.2?


I am new to this but have to use openGL 3.2
Advertisement
I havn't tried it, but this was the first hit on google with the following search term "SDL OpenGL 3.2":

Creating a Cross Platform OpenGL 3.2 Context in SDL
How do you request a core only profile or a compatibility profile?
Sig: http://glhlib.sourceforge.net
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);
Using OpenGL 3.x with SDL requires using the highly unstable SDL 1.3 branch. Otherwise, you are stuck with a legacy context using the stable SDL 1.2 branch. That's not a terrible thing, though. Unless you plan on using 3.x specific functionality (stuff like instanced drawing), you can code in a very "OpenGL 3 way" (just avoid deprecated functionality).
Amateurs practice until they do it right.Professionals practice until they never do it wrong.
Thanks for replies. Yeah there is example in C but still if I can get the text and timer in SDL 1.214 working in openGL 3.2 that's all I want in this projectm I a using VS 2010, VC plus plus.Can anyone elaborate more if I can some trick to get this working ?

Is there any tutorial of getting text and timer function in opengGL 3.2 or something ?
You can use freetype for text, just google it and tutorials on how to use it with OpenGL.

As to timers, you can use SDL 1.2's timers without creating a window, but it's probably neater to just switch to another library (GLFW for example) that supports OpenGL 3+ contexts until SDL 1.3 is officially out.
Yeah, just keep in mind that there zero relationship between OpenGL and timers. There will never be an "OpenGL timer". You will always find timer functionality in other APIs. That is why SDL is so good: it is an all-in-one solution. It has timers, threads, etc.
Amateurs practice until they do it right.Professionals practice until they never do it wrong.
hmm ok thanks. I will try to use the timer without creating a window in SDL but is it possible to use it in openGL ? Some other method is used for timers by Win32 ?


Aslo does anyone know how to use glfonts to display text as a hud ? It should remain stable in the top of screen.
If you want just timer functionality, only initialize the timer.

if (SDL_Init(SDL_INIT_TIMER) < 0){    // failed to initialize}


From then on, you can track how many milliseconds have passed since the program started.

Uint32 start = SDL_GetTicks();// do lots of stuffUint32 current = SDL_GetTicks() - start; // how much time has passed// ...SDL_Delay(500); // pause for half a second
Amateurs practice until they do it right.Professionals practice until they never do it wrong.
Thanks. I will try. Thinking of using SDL for timer function but printing this on openGL is also a problem [sad]

This topic is closed to new replies.

Advertisement