I'm currently leaning towards the GLUT approach because it seems like it would be much more efficient than the SFML approach. Are there any advantages to using a SFML style or disadvantages to using a GLUT style?
They really are the same thing, glut just wraps the loop in glutmainloop or whatever it is called, I would recommend not using glut or sfml, and just doing it in the os.
the os will most likely have a loop where you process all the events.
Some person, "I have a black belt in karate"
Dad, "Yea well I have a fan belt in street fighting"
avansc wrote:They really are the same thing, glut just wraps the loop in glutmainloop or whatever it is called, I would recommend not using glut or sfml, and just doing it in the os.
the os will most likely have a loop where you process all the events.
SFML creates it own separate queue for events, I doubt glut does that. Although I'm not currently planning to make the library multi platform (mainly because I only have a windows machine) I'd still like it to be an option. Also, message handling can be a pain in windows sometimes. One of the things I wanted to do with the library was to make it simpler.
In order to really understand how SFML does it vs GLUT requires some more digging. I personally have gutted SFML's windowing code (for linux at least) in my pursuit to understand XLib. Basically what SFML has in the background is "handlers" that take system generated events, act upon them in some way, then decide whether to convert it to an sf::Event and pump it in to the queue. GLUT has user-provided handlers (and just user provided handlers).
Quit procrastinating and make something awesome.
Ducky wrote:Give a man some wood, he'll be warm for the night. Put him on fire and he'll be warm for the rest of his life.
Ginto8 wrote:In order to really understand how SFML does it vs GLUT requires some more digging. I personally have gutted SFML's windowing code (for linux at least) in my pursuit to understand XLib. Basically what SFML has in the background is "handlers" that take system generated events, act upon them in some way, then decide whether to convert it to an sf::Event and pump it in to the queue. GLUT has user-provided handlers (and just user provided handlers).
I've looked through SFML's windowing code for windows. I decided to look through it after I finished the current version of the windowing system I have in my library. I wanted to see how SFML did it because I wasn't happy with the way mine turned out and I was hoping to get an idea of how to make it better. The main difference between mine and SFML's is that mine doesn't create its own queue. Every time a window's getEvents function is called it calls either GetMessage or PeekMessage. Then it converts the message it gets into an Event. Then the function returns whatever the call to Get/PeekMessage returned.
The main problem I have with my current system is how it handles messages that are sent to the window procedure rather than the message queue. At that point what I have to do is post a user message to queue so I can turn it into an event. I have to do this when the user moves, resizes, or closes the window.