Thread: Need help organizing a platformer project with SDL2 and OpenGL

  1. #1
    Registered User
    Join Date
    Jun 2018

    Question Need help organizing a platformer project with SDL2 and OpenGL

    Hi, I'm new here and this is my first post. I am not a professional programmer, so I have been gathering tutorials from the Internet and basically writing short practice programs. I decided to go with SDL2 and OpenGL. I tried some OpenGL snippets as well as SDL2 and I am having a hard time understanding how to organize a simple project.

    I am planning a 2D platformer and would like to render my images to OpenGL planes, so I can have very smooth motion. I am looking for the simplest and shortest code path possible to do this. I'm not working on anything serious other than the graphics. So I scrapped all my tests and would like a fresh start with this. I have many questions, but my main question is this.

    How can I go from start of program to a gameloop to do this. I already did many of the tutorials, so I am not asking how to use SDL2.
    What I mean instead, is, how can I modularize and do this with OpenGL, so I can have a good image loading routine that renders to OpenGL planes.

    Does anyone have a good example of how this has been done before. There are many smooth gameplay examples out there using OpenGL and SDL2, but not too many examples of projects.

    Any pointers in the right direction is very appreciated. This is going to be my ongoing project for the near future and this is my first post requesting help in this matter. That is why I am here.

    Thank you,

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    > I am looking for the simplest and shortest code path possible to do this.
    To be honest, your approach is wrong.

    The first problem is that directly coding the solution results in inflexible code that has no reuse. As soon as your requirement changes, you have to throw it away and start again. Or you modify it so much that it becomes so brittle and fragile that you can no longer fix a bug without introducing another bug.

    Also, tutorials are fine for beginner stuff. But sooner or later, the problems you face become larger and more specialised. So much so that there are no longer any tutorials to guide you. Most people by this stage have learnt to stand on their own and no longer need that kind of hand holding.

    It seems to me that in your rush to learn OpenGL, you forgot to learn how to program along the way.
    Programming is so much more than knowing an API and where the curly braces go.

    At some level, you need the skill that allows you to step back from a problem and be able to generalise the solution in some way. Forget about how you might draw it, and think about what the essence of this might be.
    class Platform {
    Besides, the best teacher is experimentation and failure. You should plan for and expect that your first few attempts will crash and burn. But the experiences will teach you a lot and you should do better each time.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. SDL2 - GCC vs. G++ segmentation fault
    By Zacariaz in forum C Programming
    Replies: 8
    Last Post: 06-01-2015, 06:23 AM
  2. SDL2 Codeblocks error
    By russiancircles in forum Game Programming
    Replies: 2
    Last Post: 05-08-2014, 06:08 AM
  3. I need a good openGL project
    By revelation437 in forum C++ Programming
    Replies: 13
    Last Post: 09-15-2004, 08:40 AM
  4. New OpenGL project (tCUBED)
    By Jeremy G in forum Game Programming
    Replies: 1
    Last Post: 12-10-2003, 05:42 PM
  5. I know i want a good project 2 work on...
    By Zeeshan Zia in forum Game Programming
    Replies: 2
    Last Post: 10-20-2001, 12:18 PM

Tags for this Thread