Sign in to follow this  
kimi

OpenGL Does SDL work with Opengl 3.2 ?

Recommended Posts

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

Share this post


Link to post
Share on other sites
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).

Share this post


Link to post
Share on other sites
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 ?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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 stuff

Uint32 current = SDL_GetTicks() - start; // how much time has passed

// ...

SDL_Delay(500); // pause for half a second


Share this post


Link to post
Share on other sites
Thanks. I will try. Thinking of using SDL for timer function but printing this on openGL is also a problem [sad]

Share this post


Link to post
Share on other sites
We are given with openGL 3.2 program. I first thought it was cool as it uses shaders GLSL but it has made things more complicated. OpenGL2 or 2.1 would have been easier to work

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this