Sign in to follow this  

OpenGL linux help requested

This topic is 2127 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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!

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
[quote name='steenson86' timestamp='1329701381' post='4914695']
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
[/quote]

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)

Share this post


Link to post
Share on other sites
[quote name='steenson86' timestamp='1329701381' post='4914695']
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
[/quote]

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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

This topic is 2127 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this