What should I choose between java sdl, sfml, opengl, etc.

1.1K    Asked by LillianHart in Java , Asked on Oct 10, 2022

I recently started a new project, and I'm wondering if I should change the technology now before it's too late.

I'm using SDL with C++, I have around 6 classes, and the game is going alright, but I got to this point where I have to rotate my sprite to make it point to the coordinates of the mouse.

It's a 2D topdown game, so if I pre-cached the images, I'd have to load 360 images, which is bad for memory. If I used SDL_glx, I could do the rotation in real time, but I heard it'd drop my frame rate very drastically, and I don't want my game to be slow.

I also read that I could use OpenGL, which is faster at these things. The problem is, how much would I have to change my code if I moved to OpenGL with SDL.

So, I considered moving to a completely different language - Java - which is much simpler, and would allow me to focus on the game and handle networking much more easily than with C++.


Answered by Lily Hemmings

If you're fairly new to game programming and programming in general, I recommend against starting out learning everything in C++. Either set your sights lower than sprite-based games while you learn C++, java sdl (e.g., practice with a text adventure while you get comfortable with the language) or go for the less cerebral, more fun route with another language.


Java is a good language to start game programming in if you're at least somewhat comfortable with object oriented programming. You have libraries like JogAmp, LWJGL, and Java Monkey Engine to get started, as well as tools like Eclipse.

Lua and Python have similar libraries to Java available and are also pretty good for getting something on screen relatively quickly and making it move around, although I have to defer to someone else's experience for starter libraries and tools for these languages.

If you're comfortable with C++ and would like to stick with it, then I think it comes down to a matter of personal experience, priorities, and taste. The options you listed are all good ones generally, but you'll want to read up on the APIs, strengths and weaknesses, and so on to see which one fits you best.

My hunch, though, is that you'd be happier working in another language for a while to get some experience before you come back to C++. There is plenty of general game programming experience to be gained elsewhere.

I hope this helps. Good luck.



Your Answer

Answers (2)

If you're already comfortable with C++, I'd stick with SDL for now — switching languages mid-project usually creates more headaches than it solves. For the rotation issue specifically, pairing SDL with OpenGL is a solid move. It takes a bit of adjustment to get comfortable with, but once you're past the initial setup, real-time transformations become much more manageable. Honestly, it's one of those things where the learning curve feels steep at first but clicks pretty fast. Take it step by step rather than trying to overhaul everything at once. I had a similarly frustrating stretch a while back where I was stuck on multiple problems at the same time - oddly enough, stumbling onto https://animeflix.city/ Fast Payout Casinos while looking for something unrelated actually gave me a clear breakdown of a process I'd been overthinking, which reminded me that sometimes the clearest explanations come from unexpected places. Same energy applies here - break the problem down, tackle the OpenGL integration separately, and don't let the big picture overwhelm the small steps.

2 Weeks

rotating a sprite in 2d doesn’t require 360 cached images; just store one texture and rotate with a transform. if you stay on sdl, using sdl2 with hardware acceleration or an sdl+opengl renderer can handle this fine without tanking fps. switching to java won’t magically simplify graphics either, though lwjgl/jme can be nicer for tooling. i got distracted once while debugging input math and ended up on https://twinspinca.com/no-deposit-bonuses/ which says more about my procrastination than my engine choice. i’d pick one stack and finish a small playable slice before rewriting everything.

1 Month

Interviews

Parent Categories