Cross Platform (Mobile + PC) SDL2 + OpenGL setup |
phildo
|
Ok, so still working on figuring this stuff out. I'll try to answer my previous questions to the best of my knowledge for future travelers. I would still LOVE to be corrected or made more clear, because I still haven't found anything particularly straightforward...
- What is SDL + OpenGL philosophy? SDL does the correct include for you by simply "#include <SDL_opengl.h>"ing. From there, after init-ing, you need to SDL_GL_SetAttribute a couple of GL-ish things to let SDL know what GL version you want 'n such. You then SDL_CreateWindow with the SDL_WINDOW_OPENGL flag set, and then use SDL_GLContext gl = SDL_CreateContext with the window you've just created. From there, you have a GL window and a GL context set up and just use openGL calls as though you had set up openGL straight up. tl;dr: Need to use specific SDL calls in generating/ setting up your window to init a GL context, but then SDL is hands off. - How to set it up across platforms? I have #ifdefs for platform around what version of openGL I'm requesting via SDL's SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, ...). But if you are using compatible versions of openGL across platforms, you're fine. For example, I'm planning on using OpenGL 2.1 for desktop, and OpenGL ES 2.1 for mobile. I HAVEN'T TESTED HOW WELL THIS WORKS YET!! - Are there different versions? Kind of answered above - Any straightforward walkthroughs? Oh god no. There are tons of references/documentation for specific API calls on either SDL or OpenGL, but no "Hey, here's conceptually what you need to ensure you are doing to get a damn triangle on screen". There are a couple examples on github 'n such that "display a triangle", but they are all using wildly different versions of this or that and it's all a mess. If you find anything good, tell me! |
|||||||||||
|
macrofeet
|
I recently worked on some sprites for a project (Gigalomaina)
homepage.ntlworld.com/mark.harman/comp_gigalomania.html This is SDL2 Open source and on the android store Hope this helps + anyone reading this think about contributing to this project as its awesome. |
|||||||||||
|