Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why are SDL and OpenGL related?

Tags:

c++

c

opengl

sdl

I was messing around with SDL and found out that you cannot rotate images with SDL. Everywhere the question was asked, people said to use OpenGL to do rotation. I always thought that SDL was completely separate from OpenGL, am I wrong in thinking this? I even found tutorials for using OpenGL within SDL, which confused me even further. What exactly is the relationship between SDL and OpenGL? Why not just use OpenGL if its more powerful and allows you to do more (this is from what I've read)?

like image 536
Devan Buggay Avatar asked Apr 24 '11 06:04

Devan Buggay


People also ask

Do you need OpenGL with SDL?

If you want a lot of fancy effects and sprites on the screen at once, use OpenGL because it supports shaders and is hardware accelerated. If your game is simple and doesn't need a lot of effects or sprites, stick with SDL, especially if it's your first game. SDL isn't hardware accelerated, but it's much easier to use.

Does SDL renderer use OpenGL?

Also note that the SDL renderer does not have to rely on OpenGL (it may use Direct3D on Windows).

Does SDL use directx?

SDL supports directx 11 and directx 9/10 renderers.

Should I use SDL or Glfw?

If you only want input and use raw opengl calls, glfw is the smallest option of the 3 (it also handles window/context creation for you if you want to). SDL and sfml are bigger packages that have more features available (sound, fonts, texture imports, some rendering abstractions).


2 Answers

SDL is a layer above OpenGL; in fact it uses GDI on Windows by default and also has a DirectX backend. People are probably saying you can use OpenGL to get around limitations of SDL on platforms that by default use OpenGL (ahem, Linux) because the higher level abstraction doesn't expose that functionality. However, then your code is "less" portable to Windows (or at least Windows using the GDI backend).

Also, SDL does a lot of other things besides graphics - audio, input, etc. that OpenGL doesn't do.

like image 119
J Trana Avatar answered Sep 19 '22 23:09

J Trana


SDL is a cross-platform multimedia library designed to provide low level access to audio, keyboard, mouse, joystick, etc. It also supports 3D hardware via OpenGL.

OpenGL is a standard specification defining a cross-language, cross-platform API for writing applications that produce 2D and 3D computer graphics. The interface consists of over 250 different function calls which can be used to draw complex three-dimensional scenes from simple primitives. OpenGL was developed by Silicon Graphics Inc. (SGI) in 1992[4] and is widely used in CAD, virtual reality, scientific visualization, information visualization, and flight simulation. It is also used in video games, where it competes with Direct3D on Microsoft Windows platforms (see OpenGL vs. Direct3D).

like image 35
karlphillip Avatar answered Sep 22 '22 23:09

karlphillip