Running into trouble with GLUT.

This is a discussion on Running into trouble with GLUT. within the C++ Programming forums, part of the General Programming Boards category; So I've been using GLUT as my window power for OpenGL, in some huge project I'm working on. Two problems ...

  1. #1
    Registered User Josh@Dreamland's Avatar
    Join Date
    Dec 2007
    Posts
    10

    Running into trouble with GLUT.

    So I've been using GLUT as my window power for OpenGL, in some huge project I'm working on.

    Two problems I have run into thus far:

    1) GLUT doesn't give mouse motion callback outside the window, and I don't see a way to fix this. I need to make sure that mouse_x and mouse_y are relatively consistently accurate. Otherwise, should a game be designed where mouse motion is tracked, it could be cheated by having the mouse leave the window.

    2) Window positioning. I devised three functions. window_set_position(), window_get_x(), and window_get_y(). GLUT_WINDOW_X/Y return the location of the drawing are of the window, not the corner of the border. On the other hand, the positioning function does work according to the border origin. Meaning that calling window_set_position(window_get_x(),window_get_y()) causes fail. I came up with a temporary, or permanent, solution. At the beginning, I set the initial window position to (100,100). On the initialize callback, I set __window_borderh and __window_borderw to glutGet(WINDOW_GET_X) - 100 and glutGet(WINDOW_GET_Y) - 100. This allows me to call those vars in the window_get_x/y functions to make it in sync.

    3) Cursors hate me. I'm assuming there's something I should have enabled, but didn't, and will look into that in a minute here. But only like eight cursor settings do anything, and only three are accurate.

    If you know a solution to any of those, or would like to suggest some other API with all the power of GLUT (especially in the window area. I need those window functions for the project to succeed) please let me know. If somehow you've heard about the project (VERY unlikely) and you'd like to help (even less likely), or you'd just like to see what the hell I'm doing, feel free to drop me an email. Or whatever.

    Thanks, and Merry Christmas (or just happy holidays)

  2. #2
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    1) Getting mouse information outside your own window means that the underlying windowing system needs to send you this info, which it doesn't by default. (Because it's none of your business.) There are OS-specific functions to enable this tracking, but I don't think GLUT provides wrappers.
    Do you have a concrete case where you have a problem? Your descriptions sounds highly hypothetical to me.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  3. #3
    Registered User Josh@Dreamland's Avatar
    Join Date
    Dec 2007
    Posts
    10
    I'll show you a game I ran into long ago where complete tracking of this may have been for the best. To cheat it, hit control-alt-delete, drag the window to where the mouse hovers over the start button (the little circle), go back to the task manager and drag it to the newly displayed finish button (the square), then move the mouse right back out onto it.

    http://www.fetchfido.co.uk/games/mouse-escape/mouse.htm

    That is not the kind of problem I'd like to face in GLUT.


    You see, the problem doesn't actually involve me specifically. But that's because I'm making a program to make programs. And my goal is to be better than the other one like mine, which enables that tracking. The problem is, the program I'm attempting to be better than only has Windows to worry about. I'm trying for all systems.
    Last edited by Josh@Dreamland; 12-28-2007 at 10:34 AM. Reason: Explain

  4. #4
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    I see what you mean.

    I'd do it differently. I'd just track when the mouse leaves and enters your game area (that's possible, though you'd probably have to write platform-specific stubs for it still) and send appropriate events to the game. A game that relies on the mouse always staying within the window to avoid cheating can then catch the mouseleave event and react, e.g. by resetting the level.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  5. #5
    Registered User Josh@Dreamland's Avatar
    Join Date
    Dec 2007
    Posts
    10
    I suppose. But another game on that site, hit the monkey, I think it was. You have to move the mouse within the window to hit it. Having outside callback would enable better tracking altogether.

    I just want games made in this software to have all that good stuff.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Glut
    By Matty_Alan in forum C Programming
    Replies: 7
    Last Post: 07-16-2007, 07:01 AM
  2. Displaying my glut output in my own class window.
    By Queatrix in forum Windows Programming
    Replies: 0
    Last Post: 10-19-2005, 10:09 AM
  3. GLUT and Dev-CPP
    By Canadian_coder in forum Game Programming
    Replies: 4
    Last Post: 12-22-2004, 02:12 AM
  4. Running External Process from service
    By rotis23 in forum Windows Programming
    Replies: 2
    Last Post: 12-02-2004, 07:56 AM
  5. Dis/Advantages of Glut?
    By Zeusbwr in forum Game Programming
    Replies: 1
    Last Post: 11-28-2004, 09:00 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21