With OpenGL, should I use GLut or SDL?

Started by
4 comments, last by _w4r10ck 9 years, 10 months ago

Hello GameDev.net community.

Operating System : Ubuntu 12.04 LTS
Currently Learning : OpenGL using GLut

Languages : C/C++

"IDE": gedit + gnome-terminal

Trying to avoid being voluble, I settled that i would use a powerful and reliable graphics library which would give me support to 3D graphics and also flexibility using C++. After doing some research I turned to OpenGL, which gave me not just reliability but also facility on my operating system. Although It is a possible perfect choice, I still have some issues about using GLut, Would i achieve better performance using it or SDL? and what about the portability? SDL is widely used not just with OpenGL but also to make games and applications. SDL is very powerful and not so specific as GLut. I am using GLut for studying and creating small applications, but I don't think it would be so powerful as SDL for creating games ( that is my goal =] ).

Am I interpreting GLut wrong? would it be better?

TIA.

Advertisement

Don't use glut. It's 1. ancient software ("latest" version 3.7 is from 1998) 2. not public domain / proprietary licensed. If you like glut go with freeglut instead. SDL is a more complete toolkit and also has an audio-mixer and supports direct3d (where applicable) and accelerated 2d without having to use gl calls. Both have font renderers but both are useless (SDL_ttf has terrible performance if used with direct opengl and freeglut font functions are restricted to certain fonts). Regarding portability both are portable to many platforms so unless you're developing for an exotic platform both will suit your needs.

I don't know about performance of glut builds though. I'd say just build simple programs using SDL and glut and see if you notice performance issues or higher memory usage.

One thing caught my attention here:

"IDE": gedit + gnome-terminal

Have you ever tried vim?

SDL 2.x is actually quite nice.

SlimDX | Ventspace Blog | Twitter | Diverse teams make better games. I am currently hiring capable C++ engine developers in Baltimore, MD.

If your ultimate goal is to create games that you want to sell and redistribute, don't use GLUT (unless you absolutely HAVE to), and chances are you will not have any solid reasons to use it. SDL has much more to offer as a game dev then GLUT does. As it was already mentioned, GLUT is really old and is not actively maintained. SDL, however, is and is much more suitable for games as it was largely inspired for such usage.

In my experience, I have experienced better control and performance using SDL. GLUT is widely supported on nearly every OS, but implementing controls using GLUT is not feasible to say the least. I wrote a very simple game using GLUT on Windows once, and thought it worked fine for the most part, but when I ported it to other OSes, the controls were not nearly as smooth for what a game should have, because they were not suited for games (the keyboard timestamp feature will annoy you and everyone else who plays your game; also, the mouse input is not very smooth or accurate enough). SDL takes a bit more work to setup, but it's worth it.

Lastly, using GLUT, you are limited to legacy OpenGL, afaik. With SDL 2.0, you can easily create a context for the latest OpenGL version you want/need. This should be a deal breaker for GLUT in most cases alone.

Before I wrap up my response, I will give a small defense for GLUT. I actually have my latest game using GLUT atm. The reason why I chose GLUT (at the time at least) was because it was easy to setup, and my game in particular with it's mechanics were much easier to get up and running using GLUT. Another reason is that GLUT's borderless window was proven invaluable when deving and debugging on MacOSX. Lastly, I initially started writing my game on MacOSX, not knowing much of anything about OpenGL for Mac. GLUT just felt right at that moment, and it ultimately saved me much time, energy, frustration and needless hassle (there are some features in my game I never would have considered if I didn't use GLUT), but ultimately, using GLUT in a commercial game comes with a price. Since GLUT is not actively maintained, you are risking future compatibility with new OSes. The same old glut32.dll or GLUT.framework is not guaranteed to be working on the next Windows or MacOSX, respectively, due to possible removal of a specific API or something. That probably won't happen, but it can, and it's not worth the risk, IMO. When it's time for the release, I will likely switch to SDL to avoid that potential land mine.

My recommendation to you is to learn the basics of SDL 2.0. Don't bother with the deprecated SDL 1.x, and it's easy to get the two confused as many things have changed for the better, causing some functionality not to work (Example, if you want SDL 2.0 controller functionality, use this, not the legacy stuff because it won't work).

Don't worry about GLUT or legacy OpenGL. If your card/drivers support it, start learning OpenGL 4.1 or later.

Shogun.

I use SFML, but I think I'll change to SDL 2.X by the fact that I'm not using all SFML features (like OpenGL rendering) and was a pain in the ass to get working on VS2013 (I took an template from a guy at the library's forum). Again, nothing agaist SFML.


@ilreh
I used Windows in the past, and I tried to use Vim there (Not like a hardware Vim user). Saying goodbye to WIndows, I moved to Ubuntu, and after 4 months I have my Internet cutted off. After that, I noticed that I didn't install Vim on my Ubuntu and today I regret having to use gedit. There is a console version of Vim on my PC, but is not so good as the 'interfaced' one I used on Windows.
Now I just have Internet access at work, and I need to thank you for making me remeber to download it !
I will need to improve my linux-installing-fu to install it, because I am I Linux noob. And now I will need to install SDL too !

Thus, Thank you.

@Promit

Thank you!

@blueshogun96

Thank you!

" I actually have my latest game using GLUT."
You mean Loop-til?

@Irlan R.
Nothing against SFML, but I prefer Allegro over it, and SDL over Allegro.
Thank you!

This topic is closed to new replies.

Advertisement