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

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.

ohh, how do I call the menu to popup.

BuildMenu() only builds the menu.

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.

commented: Good +1

i see, thanks for the answers ^^

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.