SDL2 - OpenGL

Started by
2 comments, last by Alberth 7 years, 3 months ago

I'm currently working on a personal 2D project, but I'm interested in trying a little 3D, I don't have a background in that and I'm brushing up on the mathematics at this time.

There are ton's of SDL2 tutorials, but I can't seem to find an excellent example to use OpenGL with SDL2. Can someone recommend a good tutorial?

...and I want to move from 0 to some application and I think the route is from Triangle to Object Viewer. What's the best lesson plan for that?

Advertisement

There are many, many tutorials out there on how to set up an OpenGL context using libSDL. The API in that respect is almost unchanged in libSDL2, so they still apply. Then, you need to jump to one of the many, many tutorials on using OpenGL because other than a brief sojourn setting up the context and handling input though libSDL2, that will dominate your life.

Disregard the older (fixed pipeline) OpenGL tutorials. You want at least OpenGL 3.0 or later.

Stephen M. Webb
Professional Free Software Developer

There are ton's of SDL2 tutorials, but I can't seem to find an excellent example to use OpenGL with SDL2. Can someone recommend a good tutorial?

There are many tutorials out there to do this, I would start off by finding one that is a simple a creating an SDL window with an OpenGL context that can draw a triangle or square. This is one of many but covers all of the very basics you need to get started: http://lazyfoo.net/tutorials/SDL/51_SDL_and_modern_opengl/

One thing you will find, if you have done anything in 2D with SDL, is that if you are going to use 3D you will have to do a lot more work in order to get anything drawn to the screen. Such as compiling and linking shaders and creating Vertex Buffer Objects (VBOs) etc. OpenGL is also old, the early versions (before version 3) use the fixed pipeline so be careful when reading tutorials as they might be using the fixed pipeline which you do not want to use.

For OpenGL, learnopengl.com works nicely.

It uses GLFW instead of SDL2, but besides the window creation, window refresh, and the input handling, everything is valid.

This topic is closed to new replies.

Advertisement