2D OpenGL vs SDL2 Advanced Rendering
Members - Reputation: 106
Posted 09 October 2013 - 01:03 AM
So if this is not the case then they must be using OpenGL for shaders or particle effects. Particle effects I guess I can understand but shaders I do not. Shaders work with vertices and vectors and seem to inherently require 3Dimensional space.
For example, if I am to make a game with lighting, it seems to me that I can achieve this with alpha blending/color modulation and maybe some raytracing and use SDL2 to render this on screen. I can't see how it wound be possible to do this with OpenGL as light calculations must involve vectors and bouncing off walls in 3d space. It would mean that I would somehow have to translate my 2d tilespace into 3d meshes with vertices and then load shader programs that would understand the nature of my flatspace. Which sseems odd and maybe slower to use an entire mesh per tile or sprite.
I don't mind learning OpenGL, I just want to make sure it's worth it! Maybe I made the mistake of learning SDL2's advanced rendering first, as its just so simple to use.
Any information from the eexperienced would be greatly appreciated. Thanks for reading and am excited to have joined GameDev!
Crossbones+ - Reputation: 7993
Posted 09 October 2013 - 02:17 AM
What you do with your shaders is entirely up to you too. If you want lighting, then you will probably have to add some additional meta data with your tiles. If you just want some fancy blending and some glow effects then you can do that too. It should be noted that all effects which you could achieve with some texture combiner work can also be done in shaders, usually far simpler too. You can also do a lot of things you could not do before.
Also note, that if you look at any modern smartphone, they will be using OpenGL ES 2 for rendering their entire UI. OpenGL ES 2 is somewhere between desktop OpenGL 2 and OpenGL 3 (plus a few tidbits minus a few other tidbits) and requires you to use shaders (the fixed function pipeline does not exist there at all).
Can you use shaders for a purely 2d game? Definitely.
Will it be useful for what exactly you have in mind? Impossible to answer for an outsider.
Edited by BitMaster, 09 October 2013 - 02:18 AM.
Crossbones+ - Reputation: 11728
Posted 09 October 2013 - 03:26 AM
SDL2's accelerated rendering is nothing more than a software wrapper around OpenGL or Direct3D. By using OpenGL (or D3D for that matter) you bypass the wrapper and get to use the underlying API directly, which can give you more control but at the expense of greater complexity. Whether or not you need that extra control is a question only you can answer.
In the case of your lighting example, it's perfectly possible to do this via OpenGL, and I can say this (and you can believe it) with extreme confidence because (as I've noted) that's how SDL2 does it too.
Right now SDL2 is working fine for you, so I don't think you need to consider using something else for the moment. As you do more work, get more experience, get more ideas for cool stuff you'd like to do, you're going to start running into obstacles and things that SDL2 can't do so well. At that point the greater control of the underlying API will be needed, and maybe a good starting point for you might be to look at the SDL source code and understand how they did it, in conjunction with some more specific learning material.
It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.
Members - Reputation: 106
Posted 09 October 2013 - 11:48 AM