Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I know that SDL 1.2 does software rendering (CPU) and not hardware rendering (GPU). My question is, how do I use SDL but with hardware rendering? How do I not use its rendering API (software) and rather a hardware rendering API like OpenGL?

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

SDL supports OpenGL outright. There is a guide in the SDL documentation on how to use OpenGL (This is mainly a SDL tutorial, not an OpenGL one [it uses a lot of deprecated functionality]).

You probably also want to change the SDL_GL_SetAttribute( SDL_GL_RED/GREEN/BLUE_SIZE, 5 ); from 5 to 8 bits per pixel, and also add an alpha channel (SDL_GL_ALPHA_SIZE).

After that, you can start using OpenGL like you normally do. Here's a good tutorial - you only need to replace the glutSomething functions with their SDL equivalents.

Note that if you use OpenGL with SDL, you can't blit onto the screen surface anymore (it works if you use the right flags, but even then it's deprecated functionality). But you can still use SDL_image to load images and use the SDL_Surface data to create textures.

share|improve this answer
    
Thanks for the reply. This was what I was looking for! Also, would you recommend SFML over SDL? I know C++ is more OO and a modern interface for C++ but besides that, it seems to have better features although SDL is more mature. I'm not quite sure what I should use. –  hullot Mar 31 '12 at 19:37
    
I've never used SFML. Basically, I know that it exists. SDL has always been "good enough" for me. Your mileage may vary. –  Raphael R. Mar 31 '12 at 19:58
1  
If you're using C++, there's literally zero reason to use SDL instead of SFML (unless you want to target FreeBSD or something). Just rememeber to use the latest SFML 2.0 snapshot instead of SFML 1.6. –  TravisG Mar 31 '12 at 22:39
1  
Use whatever gets the job done. If you already know all the little nooks and crannies of SDL, then SDL is likely to remain a better choice. Switching to a different platform just because it's more modern or more OO is a really really bad reason. Choose your platform based on what you know and what does the job you need done first. –  Jimmy Shelter Mar 31 '12 at 23:40
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.