954,535 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

glutAttachMenu() help

Hi, C# in VS2008 using Tao.Freeglut and Tao.OpenGl

I am required to create a 3d Tetris game.

I have a menu named BuildMenu

private static void BuildMenu(){
submenu1 = Glut.glutCreateMenu(selectMessage);
            Glut.glutAddMenuEntry("New Game(N)", 1);
            Glut.glutAddMenuEntry("Reset(R)", 2);
            Glut.glutAddMenuEntry("Quit(Q)", 3);

Glut.glutAttachMenu(Glut.GLUT_RIGHT_BUTTON);
}


using these code I can make a menu pop when I click right mouse button at once

now my real problem is that
I want to use the right button for rotating my game board
while holding the right mouse the game will rotate

that is why I want to make the menu pop up "AFTER" releasing the right mouse button
but I dont know how with glutAttachMenu()
because when I click the right mouse it pops up immediately

here is my code for mouse button

private static void MouseButton(int button, int state, int x, int y)
        {
            if (button == Glut.GLUT_LEFT_BUTTON)
            {
                if (state == Glut.GLUT_DOWN)
                {
                    lmd = 1;
                }
                else
                {
                    lmd = 0;
                }        
            }
            if (button == Glut.GLUT_RIGHT_BUTTON)
            {
                if (state == Glut.GLUT_DOWN)
                {
                    rmd = 1;
                   
                }
                else
                {
                    rmd = 0;
                }
                
            }
            if (button == Glut.GLUT_MIDDLE_BUTTON)
            {
                if (state == Glut.GLUT_DOWN)
                {
                    mmd = 1;
                }
                else
                {
                    mmd = 0;
                }
            }
            
        }


rmd means right mouse down
mmd middle mouse down and
lmd left mouse down

left mouse rotates the game on x-axis
right = z-axis
middle mouse = y-axis

daniel955
Light Poster
25 posts since Jul 2010
Reputation Points: 17
Solved Threads: 0
 

Check the previous status of your mouse button down. If the button was down and it's now up, you know the mouse button has just been released that frame and you can call your menu popup now.

Sodabread
Posting Whiz in Training
290 posts since Nov 2009
Reputation Points: 103
Solved Threads: 42
 

ohh, how do I call the menu to popup.

BuildMenu() only builds the menu.

daniel955
Light Poster
25 posts since Jul 2010
Reputation Points: 17
Solved Threads: 0
 

Ah. My bad. I read it wrong the first time.

From the documentation for FreeGlut, it looks like it's not possible to do it on mouse button release as Tao only uses the 3 mouse buttons regardless of state. You would be able to create your own menu and call it to begin drawing on a button's release, but that also kind of partly defeats the purpose of using the Tao framework, at least for menus.

Sodabread
Posting Whiz in Training
290 posts since Nov 2009
Reputation Points: 103
Solved Threads: 42
 

i see, thanks for the answers ^^

daniel955
Light Poster
25 posts since Jul 2010
Reputation Points: 17
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: