SDL and OpenGL

Started by
5 comments, last by Cocalus 18 years, 5 months ago
Hello, I've some questions about SDL (when it's used with OpenGL). Before, i was doing opengl in Java with LWJGL and JOGL. That was good yes, but now i really want to go further with C++. But which toolkit must i used ? For me, the choice is between Glut and SDL. 1)SDL/OpenGL has been used in several great commercial games like UT2004, Neverwinter Nights and the new Quake 4 (at least in their Linux versions), hasn't it ? But Quake 4 uses the Doom3 game engine, no ? So Doom3 is written with SDL too ? 2)The SDL FAQ isn't very clear (even more for a french man like me :)). I didn't understand the part with hardware acceleration. There is hardware acceleration on Linux (if it's possible of course), but on Windows, if i use OpenGL with SDL, i have hardware acceleration too (the FAQ said no, but i think i haven't understand it correctly) ? 3)If i use SDL, i can always write my OpenGL code normally ? With all the new extensions of OpenGL possible, and with vertex shaders (CG, ect..) ? The only think in which SDL takes part is the windowing and the input (keyboard, mouse...) ? Thanks for your answers.
Advertisement
Quote:SDL/OpenGL has been used in several great commercial games like UT2004, Neverwinter Nights and the new Quake 4 (at least in their Linux versions), hasn't it ? But Quake 4 uses the Doom3 game engine, no ? So Doom3 is written with SDL too ?


I would guess that they used SDL/OpenGL on their Linux versions only. AFAIK, all of those games used a Direct3D renderer.

Quote:The SDL FAQ isn't very clear (even more for a french man like me :)). I didn't understand the part with hardware acceleration. There is hardware acceleration on Linux (if it's possible of course), but on Windows, if i use OpenGL with SDL, i have hardware acceleration too (the FAQ said no, but i think i haven't understand it correctly) ?


SDL is not hardware accelerated. OpenGL would be hardware accelerated if your hardware (and OpenGL driver) support it.

Quote:If i use SDL, i can always write my OpenGL code normally ? With all the new extensions of OpenGL possible, and with vertex shaders (CG, ect..) ? The only think in which SDL takes part is the windowing and the input (keyboard, mouse...) ?


Yes. SDL really just handles app startup, gives you a window and a video mode, and provides cross-platform handling of input.

Of course, there's also the other SDL libraries for sound, etc., that handle other aspects in a cross-platform manner.

I really just use SDL as a cross-platform application core.
Quote:
UT2004, Neverwinter Nights and the new Quake 4 (at least in their Linux versions), hasn't it ? But Quake 4 uses the Doom3 game engine, no ? So Doom3 is written with SDL too ?


Those games use a Direct3D renderer? It's just a question, but if they do, then how did they port it to linux? SDL doesn't seem to solve that problem, seeing as how usually they just do the window handling and input, unless the game was in 2D, I doubt that they ported the games from Direct3D to SDL rendering, it'd be notably slow?
They very well may have used OpenGL under Windows as well, as I said, I'm not 100% sure. Regardless, a well-written game engine should be able to swap in a different 3D API without too much difficulty (certainly it would be the easier of the chores associated with porting a game like those to Linux).

They most certainly used OpenGL under Linux/Mac. Like I said, SDL is just the core window/app setup.
Quote:I would guess that they used SDL/OpenGL on their Linux versions only. AFAIK, all of those games used a Direct3D renderer.

Neverwinter Nights and Quake 4 use opengl natively UT is d3d (but theres also a gl renderer)

Quote:2)The SDL FAQ isn't very clear (even more for a french man like me :)). I didn't understand the part with hardware acceleration. There is hardware acceleration on Linux (if it's possible of course), but on Windows, if i use OpenGL with SDL, i have hardware acceleration too (the FAQ said no, but i think i haven't understand it correctly) ?

yes theres full hardware acceleration with sdl + windows (ive been using it for years)
I'm currently using SDL for my OpenGL engine, the main reason being that I would eventually like to go crossPlatform(especially if VISTA does what it's said to do)

SDL has a SDL part(its own 2D library), and it also provides functions to create an OpenGL context(cross platform too, on windows, linux, and others), and i believe the other parts of SDL are cross platform too(input sound, the works)

SDL allows you to set up an OpenGL context(the OpenGL window), and OpenGL will take care of using hardware accelleration, depending on the current video card settings and what you pass to SDL to create it...

you then use OpenGL in basically the exact same way you would as if you set up the OpenGL context using the windows functions.(you use the SDL_GL_SwapBuffers() command to swap buffers(back and front), as oppose to writing this yourself...)

and that's that!

simple, reliable, and crossplatform!
~ReKlipz
For extensions use something like GLEW or GLEE they make extensions nearly painless to use (and you need to use extensions to use opengl > 1.1-1.2 on windows). OpenGL will be accelerated as much as any other opengl program that doesn't use SDL. And linux supports opengl, there's even a software version (MESA) that supports most of the new stuff (slow as heck) if you don't have a good card (on winows it's only opengl 1.1 or 1.2)

SDL also provides a cross platform threads library.

All of ID's game since quake 1 use opengl (the xbox version of doom3 is D3D but ID didn't port it, and I'm not counting doomrpg for phones). I think they use DirectX to handle the input and audio on the windows verions. SDL's audio is pretty lacking, you'd probably want to use another library like sdl_mixer, openal or fmod.

This topic is closed to new replies.

Advertisement