Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the benefits of using OpenGL in SDL 2?

Tags:

opengl

sdl

sdl-2

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?

like image 962
Zammalad Avatar asked Sep 15 '13 18:09

Zammalad


2 Answers

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.

like image 145
Appleshell Avatar answered Sep 17 '22 14:09

Appleshell


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.

like image 36
trebor Avatar answered Sep 18 '22 14:09

trebor