11

I assume that SDL 2 uses OpenGL rendering in the background (or perhaps DirectX if on Windows) and this decision is made by SDl itself.

I have seen tutorials which show the use of OpenGL directly in SDL and wondered what benefit, if any would you get from using OpenGL direct? Are there things which SDL would not be able to achieve natively?

TPS
  • 2,067
  • 3
  • 23
  • 32

2 Answers2

11

If you completely rely on SDL functionality for graphic purposes, you only have access to simple image and buffer functions.

Accelerated 2D render API: Supports easy rotation, scaling and alpha blending, all accelerated using modern 3D APIs

But what SDL also does is providing an OpenGL context. This means you also have full access to OpenGL functionality including 3D objects, shaders, etc.

You can use SDL simply to create your context and provide you with sound, input, and file i/o, and use OpenGL to bring color to the screen, or use the SDL video API to draw sprites and images.

Appleshell
  • 7,088
  • 6
  • 47
  • 96
  • Cool thank you. So is OpenGL only worth delving in to for 3D graphics etc where as if I am just doing basic 2D stuff SDL is sufficient? – TPS Sep 16 '13 at 10:01
  • 1
    @Zammalad Thats basically it, yes – Appleshell Sep 16 '13 at 14:00
  • 1
    @Zammalad This is a bit late, but note that there are some shader tricks that you can't really replicate with the SDL renderer API but that are useful in 2D graphics - for example, if you want to render a tilemap, you can do this efficiently in a single draw call with a specialized shader, compared to the thousands you'd need if you rendered it as separate sprites. – Cubic Mar 22 '14 at 14:25
1

http://wiki.libsdl.org/MigrationGuide

Simple 2D rendering API that can use Direct3D, OpenGL, OpenGL ES, or software rendering behind the scenes

SDL2 just give you easy start with 2D graphics (and other matters) but you can't do "real 3D" only with SDL. (or i don't know about something?)

I don't know what SDL do "behind the scenes" but if you use directly OpenGL (or other API like Direct3D) you have full control over the code and rendering process and you aren't limited to SDL graphics API.

I use SDL only for creating window, graphics context and using input devices like mouse.

trebor
  • 724
  • 5
  • 16