예제 #1
0
        public static void AnimateCursor()
        {
            ulong Random     = CPUInfo.ReadTSC() % (CPUInfo.CPUSpeed * 1000000);
            bool  DrawCursor = (Random <= CPUInfo.CPUSpeed * 500000);

            GL.Clear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);

            Draw();

            if (DrawCursor)
            {
                GL.Begin(GL.GL_QUADS);
                GL.Color4f(1.0f, 1.0f, 1.0f, 1.0f);         // opaque white, not transparent
                GL.Vertex2f(_CursorPosX * 8, _CursorPosY * 8);
                GL.Vertex2f(_CursorPosX * 8, _CursorPosY * 8 + 8);
                GL.Vertex2f(_CursorPosX * 8 + 8, _CursorPosY * 8 + 8);
                GL.Vertex2f(_CursorPosX * 8 + 8, _CursorPosY * 8);
                GL.End();
            }

            FG.SwapBuffers();
        }
예제 #2
0
        public static void Display()
        {
            if (!ConsoleManager.IsOpen)
            {
                ulong StartTime = CPUInfo.ReadTSC();

                if (ConsoleVarManager.GetValueToByte("DemoFreeglut") == 1)
                {
                    GL.Clear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
                    GL.PushMatrix();

                    GL.Rotatef(SpinAroundX, 1.0f, 0.0f, 0.0f);
                    GL.Rotatef(SpinAroundY, 0.0f, 1.0f, 0.0f);
                    GL.Rotatef(SpinAroundZ, 0.0f, 0.0f, 1.0f);

                    switch (DrawObject)
                    {
                    case ObjectNames.Teapot:
                        FG.WireTeapot(15.0);
                        break;

                    case ObjectNames.Cube:
                        FG.WireCube(15.0);
                        break;

                    case ObjectNames.Sphere:
                        FG.WireSphere(15.0, 25, 25);
                        break;

                    case ObjectNames.Torus:
                        FG.WireTorus(7.5, 15.0, 25, 25);
                        break;

                    case ObjectNames.Cone:
                        FG.WireCone(15.0, 15.0, 25, 25);
                        break;
                    }

                    GL.PopMatrix();

                    GL.Flush();
                    FG.SwapBuffers();
                }

                if (ConsoleVarManager.GetValueToByte("DemoCubemapping") == 1)
                {
                    GL.Clear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
                    GL.LoadIdentity();

                    GL.Translatef(0.0f, 0.0f, -5.0f);

                    GL.PushMatrix();

                    GL.Rotatef(SpinAroundX, 1.0f, 0.0f, 0.0f);
                    GL.Rotatef(SpinAroundY, 0.0f, 1.0f, 0.0f);
                    GL.Rotatef(SpinAroundZ, 0.0f, 0.0f, 1.0f);

                    // Assign The CubeMaps to the mesh defined below
                    GL.BindTexture(GL.GL_TEXTURE_CUBE_MAP_POSITIVE_X_EXT, CM_X_POSITIVE.GLTextureNumber);
                    GL.BindTexture(GL.GL_TEXTURE_CUBE_MAP_NEGATIVE_X_EXT, CM_X_NEGATIVE.GLTextureNumber);
                    GL.BindTexture(GL.GL_TEXTURE_CUBE_MAP_POSITIVE_Y_EXT, CM_Y_POSITIVE.GLTextureNumber);
                    GL.BindTexture(GL.GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_EXT, CM_Y_NEGATIVE.GLTextureNumber);
                    GL.BindTexture(GL.GL_TEXTURE_CUBE_MAP_POSITIVE_Z_EXT, CM_Z_POSITIVE.GLTextureNumber);
                    GL.BindTexture(GL.GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_EXT, CM_Z_NEGATIVE.GLTextureNumber);

                    GL.Enable(GL.GL_TEXTURE_CUBE_MAP_EXT);      // Start cube mapping
                    GL.Enable(GL.GL_TEXTURE_GEN_S);
                    GL.Enable(GL.GL_TEXTURE_GEN_T);
                    GL.Enable(GL.GL_TEXTURE_GEN_R);

                    GLU.Sphere(SphereQuadratic, 0.8, 64, 64);   // Draw sphere

                    GL.Begin(GL.GL_QUADS);
                    // Front Face
                    GL.Normal3f(0.0f, 0.0f, 1.00f);
                    GL.Vertex3f(-0.25f, -1.0f, +1.0f);
                    GL.Vertex3f(+0.25f, -1.0f, +1.0f);
                    GL.Vertex3f(+0.25f, +1.0f, +1.0f);
                    GL.Vertex3f(-0.25f, +1.0f, +1.0f);
                    // Back Face
                    GL.Normal3f(0.0f, 0.0f, -1.0f);
                    GL.Vertex3f(-0.25f, -1.0f, -1.0f);
                    GL.Vertex3f(-0.25f, +1.0f, -1.0f);
                    GL.Vertex3f(+0.25f, +1.0f, -1.0f);
                    GL.Vertex3f(+0.25f, -1.0f, -1.0f);
                    // Top Face
                    GL.Normal3f(0.0f, 1.0f, 0.0f);
                    GL.Vertex3f(-0.25f, +1.0f, -1.0f);
                    GL.Vertex3f(-0.25f, +1.0f, +1.0f);
                    GL.Vertex3f(+0.25f, +1.0f, +1.0f);
                    GL.Vertex3f(+0.25f, +1.0f, -1.0f);
                    // Bottom Face
                    GL.Normal3f(0.0f, -1.0f, 0.0f);
                    GL.Vertex3f(-0.25f, -1.0f, -1.0f);
                    GL.Vertex3f(+0.25f, -1.0f, -1.0f);
                    GL.Vertex3f(+0.25f, -1.0f, +1.0f);
                    GL.Vertex3f(-0.25f, -1.0f, +1.0f);
                    // Right face
                    GL.Normal3f(1.0f, 0.0f, 0.0f);
                    GL.Vertex3f(+0.25f, -1.0f, -1.0f);
                    GL.Vertex3f(+0.25f, +1.0f, -1.0f);
                    GL.Vertex3f(+0.25f, +1.0f, +1.0f);
                    GL.Vertex3f(+0.25f, -1.0f, +1.0f);
                    // Left Face
                    GL.Normal3f(-1.0f, 0.0f, 0.0f);
                    GL.Vertex3f(-0.25f, -1.0f, -1.0f);
                    GL.Vertex3f(-0.25f, -1.0f, +1.0f);
                    GL.Vertex3f(-0.25f, +1.0f, +1.0f);
                    GL.Vertex3f(-0.25f, +1.0f, -1.0f);
                    GL.End();

                    // Restore OpenGL States
                    GL.Disable(GL.GL_TEXTURE_CUBE_MAP_EXT);     // Stop Cube Mapping
                    GL.Disable(GL.GL_TEXTURE_GEN_S);
                    GL.Disable(GL.GL_TEXTURE_GEN_T);
                    GL.Disable(GL.GL_TEXTURE_GEN_R);

                    GL.PopMatrix();

                    // Bind The background Texture
                    GL.BindTexture(GL.GL_TEXTURE_2D, CM_BACK.GLTextureNumber);
                    GL.Begin(GL.GL_QUADS);
                    // Front Face
                    GL.Normal3f(0.0f, 0.0f, 1.0f);
                    GL.TexCoord2f(0.0f, 0.0f); GL.Vertex3f(-4.0f, -4.0f, -2.0f);
                    GL.TexCoord2f(1.0f, 0.0f); GL.Vertex3f(+4.0f, -4.0f, -2.0f);
                    GL.TexCoord2f(1.0f, 1.0f); GL.Vertex3f(+4.0f, +4.0f, -2.0f);
                    GL.TexCoord2f(0.0f, 1.0f); GL.Vertex3f(-4.0f, +4.0f, -2.0f);
                    GL.End();

                    GL.Flush();
                    FG.SwapBuffers();
                }

                if (ConsoleVarManager.GetValueToByte("DemoGUI") == 1)
                {
                    GL.Clear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
                    GL.LoadIdentity();

                    GL.PushMatrix();

                    GL.Begin(GL.GL_QUADS);
                    // GUI Background
                    GL.Color4f(0.50f, 0.50f, 0.50f, 1.0f);
                    GL.Vertex3f(0.0f, 0.0f, -100.0f);
                    GL.Vertex3f(1024.0f, 0.0f, -100.0f);
                    GL.Vertex3f(1024.0f, 768.0f, -100.0f);
                    GL.Vertex3f(0.0f, 768.0f, -100.0f);
                    // GUI Foreground
                    GL.Color4f(0.50f, 0.50f, 0.50f, 0.5f);
                    GL.Vertex3f(0.0f, 0.0f, 0.0f);
                    GL.Vertex3f(512.0f, 0.0f, 0.0f);
                    GL.Vertex3f(512.0f, 384.0f, 0.0f);
                    GL.Vertex3f(0.0f, 384.0f, 0.0f);
                    GL.End();

                    GL.PopMatrix();

                    GL.Flush();
                    FG.SwapBuffers();
                }

                ulong  FinishTime = CPUInfo.ReadTSC();
                double Interval   = Math.Round((double)(FinishTime - StartTime) / (double)(CPUInfo.CPUSpeed * 1000000), 5);
                double fps        = Math.Round(1 / Interval, 5);
                // Console.WriteLine("[FRAME_INFO] {0} FPS", fps);
            }
        }