OpenGL linux help requested

Started by
5 comments, last by steenson86 12 years, 2 months ago
Hi All,
So i know the basics of a game loop and how a game works etc, ive been using Xna for a bout 5-6 years and i thought i would try to learn openGL in linux. Using SDL is easy however i would like use openGL without SDL and i have encountered my first issue. Using GLUT is proving to be confusing for me as what i want to do is to have control over the the keypresses and i know that i can tell GLUT which method will handle this but is this the right way of going about things?

I can't help but think that rather than using glutMainLoop etc that i could set up the game loop myself and call the functions separately i.e. handleInput, logic, rendering.

Any pointers would be great thanks!
Advertisement
so after a bit of thinking i reckon i can pass the keypressed to the game state manager and work with it from there. Please reply to this if this is a bad idea but if not i will mark this as solved.
Just one question, Why do you want to use OpenGL without SDL ? and if you want to use it without SDL why do you want to use it with GLUT ?

If you do use GLUT then you should stick with the callback system it provides, trying to work around it is a bad idea.

(GLUT is not a part of OpenGL, it hasn't been updated since 1998 and was primarily intended to simplify the writing of short examples and test applications not games, freeGLUT is slightly better but it still isn't that well suited for games (its primarily intended as a replacement for the abandonded GLUT library)).

I'd recommend that you either go back to SDL, use SFML, or, if you only intend to support Linux: use X11 and GLX
[size="1"]I don't suffer from insanity, I'm enjoying every minute of it.
The voices in my head may not be real, but they have some good ideas!
I've read through SDL tutorials and the conclusion to them all is that OpenGL is better for rendering etc. I've no particular reason for using glut just that most of the online material I've been reading is using it. I want to separate out the controls from the main class and figured the glut keypress handler can only be handled in the main class and no where else. Basically I want the player controls handled in a different class to the menus etc

I've read through SDL tutorials and the conclusion to them all is that OpenGL is better for rendering etc. I've no particular reason for using glut just that most of the online material I've been reading is using it. I want to separate out the controls from the main class and figured the glut keypress handler can only be handled in the main class and no where else. Basically I want the player controls handled in a different class to the menus etc


Just pass them from the input callback function to the class you want to handle it, Just remember to keep input handling away from the game logic or things can get very messy. (Rather than moving the player left when you get the "left key is pressed" message you move the player left in the player update method if the left key has been pressed)
[size="1"]I don't suffer from insanity, I'm enjoying every minute of it.
The voices in my head may not be real, but they have some good ideas!

I've read through SDL tutorials and the conclusion to them all is that OpenGL is better for rendering etc. I've no particular reason for using glut just that most of the online material I've been reading is using it. I want to separate out the controls from the main class and figured the glut keypress handler can only be handled in the main class and no where else. Basically I want the player controls handled in a different class to the menus etc


You can use SDL for easy OpenGL setup (instead of using GLUT, Win32 API or GLX) and not use SDL for anything else related to OpenGL. When the setup has completed you use the OpenGL API (gl____() functions) as usual and get all the performance benefits. This way you avoid having to write code for the different setups for different platform API's. I also urge you not to use GLUT as it is outdated.
So in theory then i can use SDL to handle my inputs from the keyboard or controller etc and just use openGL for drawing the graphics etc i hadn't thought of that but it sounds like it could be useful. Thanks alot

This topic is closed to new replies.

Advertisement