GLUT vs SDL

25173620a178828c4af639e495d588be
0
onyxthedog 101 Nov 19, 2009 at 21:05

As I work on the two little “games”, if you could even call them that, that I mentioned a few days ago (pong/pacman) I realized that I eventually I will want to do something in 3D. I was wondering whether or not it would be better to learn GLUT rather than use the SDL/OpenGL duo. (I am on Linux, so no DX for me :lol:)

Just wondering what your opinions on this were.

P.S. I am using purely SDL and haven’t even started learning OpenGL.

13 Replies

Please log in or register to post a reply.

A8433b04cb41dd57113740b779f61acb
0
Reedbeta 167 Nov 19, 2009 at 21:09

I haven’t extensively used SDL or GLUT, but as far as using them with OpenGL goes, you will pretty much just open a window and create a context at startup. It’s all OpenGL from there on out; use of the underlying windowing system is minimal. So if you’re already comfortable with SDL for things like audio, input handling and so on, then I’d probably stick with that.

25173620a178828c4af639e495d588be
0
onyxthedog 101 Nov 19, 2009 at 21:43

I guess that I could worry more about that a little later, but I will probably use SDL/OpenGL. Thanks Reedbeta.

A638aa42130293f319eda7fa4ba121f4
0
fireside 141 Nov 20, 2009 at 03:43

I think Reedbeta’s advice is good, but there are some other alternatives like glut you might want to look at before deciding.

http://www.opengl.org/resources/libraries/windowtoolkits/

The only problem with sdl is that it carries a little more weight than necessary. Also, check out Assimp. I had never heard of it till another poster put it up somewhere, but it looks really useful for opengl programming.

724f55482b95a484f843181229edf5ff
0
StudioFortress 101 Nov 20, 2009 at 04:08

SDL is my recommendation. I found the GLUT API ugly, far more confusing and couldn’t record if a key was absolutely pressed or not (it would just give repeated hits and releases).

To be fair I was using Ruby’s bindings for GLUT, so they might have just been particularly bad. But I know several programmers who dislike GLUT and have never met someone who does like it.

78467dc8c883ae363021f250edfc45a2
0
flodihn 101 Dec 01, 2009 at 17:41

The standard GLUT is pretty bad, it won’t allow you to run your own loop. Try FreeGLUT instead, it should be in most Linux standard repositories.

I don’t think it’s is fair to compare GLUT vs SDL. GLUT helps you with creating windows and has a pretty crude keyboard/mouse handling, you probably want to use something other for this, such as OIS (object oriented input system).
SDL on the other hand gives you much more, image functions for managing sprites, sound managament, mouse/keyboard/joystick input and with the SDL_net addon, functions to deal with sockets.

There is often no problem to combine SDL with other libraries, I use Ogre for graphics, OIS for keyboard and mouse input and SDL for joystick, sound and networking.

www.next-gen.cc
www.abydosonline.com

B7dcbc0c0f07253f25ff5c25fe38c081
0
SamuraiCrow 101 Dec 02, 2009 at 03:18

If you’re writing object-oriented code you might want to substitute SFML instead of SDL or GLUT. It’s got most of the functionality of SDL but is written in C++ rather than C.

25173620a178828c4af639e495d588be
0
onyxthedog 101 Dec 02, 2009 at 05:31

@SamuraiCrow

If you’re writing object-oriented code you might want to substitute SFML instead of SDL or GLUT. It’s got most of the functionality of SDL but is written in C++ rather than C.

I know enough C++ where I could probably pull some OOP off, but when I came back to programming my intention was *nix system programming, so I learned C fairly well.

After reading through a few thousand lines of someone else’s code and write a lot* of code I got a little burned out, as no one really used my shell and therefore it got a little discouraging.

Although I still work on my shell, I decided to take a little rest of working on it full time and split my attention to a few games/shell to kind of work my way out of my little burn out period. I still find it really fun to program the shell, I was just running out of features to implement and dreading the thought of starting from ground zero as far as the documentation is concerned. (It is derived, and the project that was its base had no docs. Such is open source.)

I am going to take a C++ class at the local community college next semester, so that maybe when I make the conversion, so to speak.

*Lot is kind of relative, it was no 50k lined beast. It was 3k but I had never really worked on someone else’s code or a shell and the whole thing was a new experience. Before that I think the largest thing I had worked on was about 1k lines, give or take 100, of my own code.

A638aa42130293f319eda7fa4ba121f4
0
fireside 141 Dec 02, 2009 at 23:04

Thanks for the link Samurai. I’ve never really liked SDL, to be honest. It’s just too c for me. SFML looks great. Don’t know when I’ll get around to use it though. I’m currently trying to learn Flash.

6837d514b487de395be51432d9cdd078
0
TheNut 179 Dec 03, 2009 at 01:05

SDL? GLUT? Bah… X11 4 teh win! :)

I’ve used GLUT and SDL before and while both get the job done (SDL more feature rich), I loath how they don’t fully implement the window API. SDL in particular ticked me off when I couldn’t disable the window title bar to be substituted for my own OpenGL rendered version. I had to get around it by accessing the windows handlers directly. There was something else about SDL as well that I didn’t like, but it’s been a while. Something to do with needing more control over the video mode. Just something to keep an eye out for.

36b416ed76cbaff49c8f6b7511458883
0
poita 101 Dec 03, 2009 at 02:37

Just go to NeHe, download the source for some tutorial and use that to get started. That will set up a window for you – you’ll just need to do the gl* draw calls from there.

btw, GLUT is not an alternative to OpenGL. It’s just an extra library that sits on top with some high level features. You still need to do raw OpenGL calls if you want to draw anything.

25173620a178828c4af639e495d588be
0
onyxthedog 101 Dec 03, 2009 at 03:10

@poita I knew that GLUT wasn’t a replacement. It just handles GUI related stuff, more or less. Thanks though, I may go to NeHe and try my hand at a little OpenGL this weekend, assuming I get a little study time in for finals.

@TheNut I know (X11), that is why I switched to Linux, all the goodness of a lot of low level stuff with twice as many calls that does 2/3rds the work!:happy: Gotta love raw Xlib calls.

In more seriousness, wasn’t it created to create libraries on top of, not actual consumption as a main course?

8676d29610e6c98d6dd2d9c38528cd9c
0
alphadog 101 Dec 03, 2009 at 15:31

SDL, SFML or GLFW. Possibly Qt.

(Wow. It’s been a while since one of my posts had such a high acronym-to-text ratio! :) )

8676d29610e6c98d6dd2d9c38528cd9c
0
alphadog 101 Dec 03, 2009 at 15:35

To add, make sure to stay away from GLUT. While it has a lot of “mindshare”, it is defunct and may actually emphasize some bad habits.