SDL doubts

Started by
2 comments, last by Aldacron 8 years, 7 months ago

Hiho Guys!

I'm now start to program in SDL.
And i got a new doubt
Some people use sdL_Surface to handle images in window, and others uses sdl_textures..
What's the diference between the two?
And the diference between renderer and surface to create the background of the window?
Thanks Everyone! biggrin.png
Advertisement
An SDL_Surface is more like a bitmap in system memory, whereas a SDL_Texture is a handle to an image on the GPU. The renderer in SDL serves to abstract the rendering such that hardware acceleration can be done in OpenGL or DirectX, if available, otherwise it falls back to the software renderer.

At least, that's as far as I know.

So, the most indicated to make a game is use SLD_Renderer with SDL_Texture, right?

Yes, you will generally want to use the SDL_Renderer API and SDL_Textures for games these days. SDL_Surfaces are used for loading images from disk, generating images to create textures from, and such. Other than that, there's little reason to use them outside of a few special cases. For example, if I ever felt the desire to work on an old-style raycaster or a custom software 3D renderer, I would likely use the SDL_Surface API.

This topic is closed to new replies.

Advertisement