The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
SDL 2.0: Loading images with OpenGL?
Paulo C. Filho


Joined: 26 Mar 2013
Posts: 2
Location: Brazil
So I have this code (bear with my unexpertise of how to properly name things):

Code:
class CGame
{
    private:
        bool running;
        SDL_Window* window;
        SDL_GLContext mainContext;
        //SDL_Renderer *renderer;
        CPlayer thePlayer;
        CWorld gameWorld;

    public:
        CGame();
        int onExecute();
        bool onInit();
        void onEvent(SDL_Event* event);
        void onUpdate();
        void onRender();
        void onCleanup();
};


I'm starting with game programming and I chose a 2D game with OpenGL, I've been reading some samples but got confused at some point. It seems 2D rendering is already hardware-accelerated with SDL_Renderer and stuff, it's quite simple to use RenderCopy but I couldn't figure out how to render a texture with OpenGL set up.

I ran into this when designing a sprite class (it will have to render the texture on the screen), so many codes that I can't figure how to fit everything into OpenGL. I know it may sound ridiculously dumb question but I thought I'd give it a try! Thanks! Smile
Paulo C. Filho


Joined: 26 Mar 2013
Posts: 2
Location: Brazil
So I've done a bit more research about this and it seems the SDL_GL_* functions communicate SDL with OpenGL directly, but it's been said OpenGL isn't well-supported in Windows so I should use DX instead. My question is going to change now: should I really use generic SDL functions that automatically chooses the better API, and stay away from OpenGL if my game is to become cross-platform at some point? am I going to lose any special ability if I don't use OpenGL directly for my 2D game?

Any insights about this would be much appreciated guys.