SDL2 and openGL3-4

Started by
3 comments, last by Ubermeowmix 9 years, 2 months ago
Hey everyone, Can I ask a quick question about SDL2
What are it's restrictions when implementing openGL 3-4 with it? Am I wasting my time learning it or do they work hand in hand quite nicely?
If you get near a point, make it!
Advertisement


Am I wasting my time learning it or do they work hand in hand quite nicely?
That depends. Exactly what part of SDL you want to work "hand in hand" with OpenGL?

SDL handles many things, context creation, input, sound, threading (I think networking too?), it has some 2D drawing facilities, etc.

"I AM ZE EMPRAH OPENGL 3.3 THE CORE, I DEMAND FROM THEE ZE SHADERZ AND MATRIXEZ"

My journals: dustArtemis ECS framework and Making a Terrain Generator

SDL2 works just fine, just tell it what kind of context you want to create with a few calls to SDL_GL_SetAttribute. It doesn't handle the function pointers for the needed OpenGL functions though, so use GLEW or something similar for that to make your life easier.

Derp

As far as I know SDL2 is just a multi platform framework, intended to work with C code, to produce multimedia applications.

This core handles some aspects of application development like: Window Creation, Threads, Rendering, Input (keyboard, mouse, joystick)... There is some additional libraries (called Projects) that are hosted by libsdl.org site (libsdl.org/projects/) that provide other functions, like ImageLoading (SDLImage), Font loading (SDL_ttf) and even networking (SDLNet) but are not supported and does not belong to SDL2 core.

SDL2 is platform independent, so you can write you code using it and run on Linux, Mac and Windows... I don't know about Smart Phones and other platforms...

Talking about OpenGL: One of the main components of SDL is the rendering system (personal impression). So, you may create a 'renderer' object (its almost and object if you consider OOP) that supports OpenGL context and use your OpenGL code to render your scene to a 'buffer' and use SDL2 renderer to draw that buffer on your screen... simple as that....

The point is: You use SDL2 to render base structure (input, sounds, rendering, etc etc) and use OpenGL to create the content for the rendering mechanism to display... this way, all the OpenGL code you will learn/create is able to be reused in other projects, even if you decide to do not use SDL2.... and btw, its pretty simple to make SDL and OpenGL to work together....

So, in my opinion, its not a waste of time to spend some time learning it... hope it helps.

KrinosX

So, in my opinion, its not a waste of time to spend some time learning it... hope it helps.

Thanks, that really does help. And I really like SDL2 so it's made the whole process fun. Back to my tile engine as it's not going to build itself... yet!

If you get near a point, make it!

This topic is closed to new replies.

Advertisement