sdl with opengl

Started by
6 comments, last by GameDev.net 18 years, 7 months ago
I am trying to make a game with opengl. However I need some 2d graphics for sprites and such, not to mention things like sound. Can I mix both opengl and sdl? Should the 2d graphics use sdl or use opengl? who creates the window? opengl or sdl? Thanks in advance
Advertisement
You can create an SDL window that you can render to with both SDL blitting functions and OpenGL functions, however, that functionality is deprecated and slow as a snail dragging a semi-truck. However, you can use OpenGL functions to do 2D blitting with an orthographic projection.
If you're just starting out, I'd say SDL is the way to go. SDL_gfx provides methods to rotate surfaces, but they are very slow if you require 50+ objects rotating freely. All in all, start out with SDL and move onto a different API like OpenGL or DirectX when you feel ready.
Rob Loach [Website] [Projects] [Contact]
There was also an SDLgl project floating around the web that seems to be a hack, to force the SDL functions to use openGL. For a beginner i suggest just using SDL, SDL_Image, and SDL_Mixer. If you want to leaarn more than just SDL, then use SDL for windowing and input, use openGL in an orthographic projection and draw textured quads for sprites. And for audio again SDL_mixer or openAL.

You will see a speed increase on 3d accelerated computers going the openGL route.
how much slower will SDL be than Win32 using OpenGL?
Quote:Original post by SpacedOut
how much slower will SDL be than Win32 using OpenGL?


Using OpenGL though SDL will have no performance difference then when using OpenGL though Win32. SDL would act as simply an OpenGL framework then, such as GLFW, and just provide additional non-graphics cross platform features.
Dude, just use OpenGL. OpenGL is perfectly capable of 2D graphics, more so than SDL is, and it is much faster. It takes more technical know-how than SDL, but it is worth it if you're going to use it anyway.
To answer your original question, you use SDL to create the window and handle input&sound&networking, and OpenGL to just draw the graphics.

This topic is closed to new replies.

Advertisement