CgExamples.Gl_06_vertex_twisting.keyboard C# (CSharp) Method

keyboard() private static method

private static keyboard ( byte key, int x, int y ) : void
key byte
x int
y int
return void
        private static void keyboard(byte key, int x, int y)
        {
            //static int animating = 0,
            //  wireframe = 0;

            switch (key)
            {
                case (byte)' ':
                    animating = !animating; /* Toggle */
                    if (animating)
                    {
                        Glut.glutIdleFunc(idleDelegate);
                    }
                    else
                    {
                        Glut.glutIdleFunc(null);
                    }
                    break;
                case (byte)'w':
                case (byte)'W':
                    wireframe = !wireframe;
                    if (wireframe)
                    {
                        Gl.glPolygonMode(Gl.GL_FRONT_AND_BACK, Gl.GL_LINE);
                    }
                    else
                    {
                        Gl.glPolygonMode(Gl.GL_FRONT_AND_BACK, Gl.GL_FILL);
                    }
                    Glut.glutPostRedisplay();
                    break;
                case 27:  /* Esc key */
                    /* Demonstrate proper deallocation of Cg runtime data structures.
                       Not strictly necessary if we are simply going to exit. */
                    Cg.cgDestroyProgram(myCgVertexProgram);
                    Cg.cgDestroyProgram(myCgFragmentProgram);
                    Cg.cgDestroyContext(myCgContext);
                    Environment.Exit(0);
                    break;
            }
        }