OpenGL fullscreen mode

Started by
6 comments, last by Erik Rufelt 10 years, 7 months ago

My game runs in full screen mode(glutEnterGameMode()) without a problem. However, my game is an FPS shooter, and because of this I'm locking my cursor invisible in the middle of the screen. So when I minimize the game, the cursor pops up again but it is still locked in the middle of the screen, so the only option is to restart your computer. Is there a GLUT function to detect whether its window is minimized or maximized or something to that effect so I may "free" the locked cursor when the window(game) is minimized?

Advertisement

1. don't use glut

2. at drastic times use ctrl+alt+del to kill the program and unlock mouse

You'd want to unbind the mouse when the opengl window is out of context, not when it's minimized.

I'm not sure how to accomplish this with glut.

Yeah, I can't find any solution to my problem in GLUT docs, so I'll just put a disclaimer on my game that says not to minimize.

What's the best window API to render openGL, other than GLUT?

Define "best".

The native platform API is ultimately the most flexible, since multi-platform libraries to some degree has to pick the lowest common denominators of all platforms. GLUT is one of the best APIs if you value rapid development time for quick applications, since you can get a window with keyboard and mouse handling up and running in just a handful or lines of code. Libraries such as SDL, SFML and GLFW are in-between, and qualifies as "best" in other areas.

I assumed GLUT was the best overall in terms of ease of use and portability. After seeing the comments I thought GLUT was deprecated in some fashion or there were better API's overall, not just in terms of window handling. But I think i'll just stick to GLUT, and I don't think many other API's can beat the simplicity of keyboard&mouse handling in a handful of line of code like you said.

Thanks!

I don't believe glut is maintained anymore. I've worked with it before and It does make settings things up quite easy, but be wary of that alluring fact. Things can get quite annoying once you start to get into the meat of game programming.

Others you may want to consider are SDL and GLFW. Personally I like GLFW because it does everything I need it to do: window context creation and input handling.

SDL is another great choice, but I feel it tries to do everything, and at times it doesn't do them very good. It supports sound and the such, but i'd rather write my own code for sound with OpenAL. But that's my choice.

I suppose it would depend what you want to do. Glut for little demos or for proofs of concepts, SDL for getting started into game programming right away, or GLFW which takes a little more set up and you have to do a good bit yourself, but it gives you more control and maybe even the chance to learn more.

If you just need it to work on Windows you can probably include Windows.h and cstring and do a test like


char str[255] = {0};
GetWindowTextA(GetFocus(), str, 255);
if(strcmp(str, "your window title here") != 0)
  iDontHaveFocusAnymore();

This topic is closed to new replies.

Advertisement