menus and opengl

This is a discussion on menus and opengl within the Windows Programming forums, part of the Platform Specific Boards category; hi, i have an opengl app in a window with a menu and i have 2 problems. 1. when i ...

  1. #1
    ~viaxd() viaxd's Avatar
    Join Date
    Aug 2003
    Posts
    246

    menus and opengl

    hi, i have an opengl app in a window with a menu and i have 2 problems.
    1. when i click a menu option and a pop up dialog box appears, the app freezes completely. now if i move this dialog box around the screen, the area of the app becomes blured with this box and looks really ugly. this means the GL loop does not refresh itself. how can i make it refresh when the dialog box is open?
    2. i've made it so that when a user presses enter the game begins, the problem is that if the pop up dialog box is open and the user pressed enter to quit that dialog box, the game starts. this means that the GetAsyncKeyState() function catches this keyboard message and the app thinks that the user wants to start the game when he's really just closing the dialog box. how can i make it ignore the keyboard messages if a menu dialog box is open?
    :wq

  2. #2
    Even death may die... Dante Shamest's Avatar
    Join Date
    Apr 2003
    Location
    Malaysia
    Posts
    970
    2. Two ways come to mind.

    1st way: set a bool flag whenever you open the dialog. Then first check if the flag is set before calling GetAsyncKeyState.

    2nd way: Instead of using GetAsyncKeyState, use Nehe's way. Have a global array of bools, one for each key code.

    Code:
    bool keys[256];
    Then during WM_KEYDOWN, do this.

    Code:
    keys[ wParam ] = true;
    In WM_KEYUP, do this.

    Code:
    keys[ wParam ] = false;
    Then to check if a key is down, you do

    Code:
    if ( keys[VK_SPACE] ) {
      // space is down
    }

  3. #3
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,856
    1. How are you creating the dialog?

    Sounds like it is modal not modeless.

    Could send the OpenGL window an update/paint msg each time a msg flows through the popup dialogs callback, but this may create other issues (depending on what the dialog is for).
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  4. #4
    ~viaxd() viaxd's Avatar
    Join Date
    Aug 2003
    Posts
    246
    Dante Shamest, yes, i guess the bool flag way would be the easiest to do. about WM_KEYDOWN, i've heard it's slow and it's better to use GetAsyncKeyState.

    novacain, i create a dialog box with DialogBox(GetModuleHandle(NULL), ..).
    :wq

  5. #5
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,856
    >>i create a dialog box with DialogBox(GetModuleHandle(NULL), ..).

    Try CreateDialog()

    DialogBox is modal, control is not returned to the app until the dlg closes.

    CreateDialog() is modeless, so msgs can flow through the app while the dlg is open.
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  6. #6
    ~viaxd() viaxd's Avatar
    Join Date
    Aug 2003
    Posts
    246
    cool, i didn't know such function existed, thanks. it worked, but i had to use WS_VISIBLE in my resource file for it to work, hope this is the right way to do it.
    :wq

  7. #7
    Even death may die... Dante Shamest's Avatar
    Join Date
    Apr 2003
    Location
    Malaysia
    Posts
    970
    Quote Originally Posted by viaxd
    about WM_KEYDOWN, i've heard it's slow and it's better to use GetAsyncKeyState.
    Actually I think it'll be faster, since it's just a boolean test and you don't have to do a function call.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. OpenGL Window
    By Morgul in forum Game Programming
    Replies: 1
    Last Post: 05-15-2005, 12:34 PM
  2. OpenGL terrain demo (EDITOR)
    By Jeremy G in forum Game Programming
    Replies: 2
    Last Post: 03-30-2003, 07:11 PM
  3. More Problems with OpenGL and the Client Area
    By Niytaan in forum Windows Programming
    Replies: 2
    Last Post: 11-06-2002, 02:24 PM

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