Exemple #1
0
        public override void OnRenderFrame(float deltaTime)
        {
            Gl.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Fill);

            // bind the font program as well as the font texture
            Gl.UseProgram(fontProgram.ProgramID);
            Gl.BindTexture(font.FontTexture);

            // draw the tutorial information, which is static
            information.Draw();


            // BUG The VBO not disposing error seems to come from in here.
            if (ShowInfo)
            {
                FontVAO gameOverlayInfo = font.CreateString(fontProgram, GameInfo,
                                                            BMFont.Justification.Right);

                gameOverlayInfo.Position = new Vector2(Width / 2 - 10, Height / 2 - font.Height - 10);
                gameOverlayInfo.Draw();
                gameOverlayInfo.Dispose();
            }
        }
Exemple #2
0
        private static void OnRenderFrame()
        {
            watch.Stop();
            float deltaTime = (float)watch.ElapsedTicks / System.Diagnostics.Stopwatch.Frequency;

            watch.Restart();

            // update our camera by moving it up to 5 units per second in each direction
            if (down)
            {
                camera.MoveRelative(Vector3.UnitZ * deltaTime * 5);
            }
            if (up)
            {
                camera.MoveRelative(-Vector3.UnitZ * deltaTime * 5);
            }
            if (left)
            {
                camera.MoveRelative(-Vector3.UnitX * deltaTime * 5);
            }
            if (right)
            {
                camera.MoveRelative(Vector3.UnitX * deltaTime * 5);
            }
            if (space)
            {
                camera.MoveRelative(Vector3.UnitY * deltaTime * 3);
            }

            // set up the viewport and clear the previous depth and color buffers
            Gl.Viewport(0, 0, width, height);
            Gl.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);

            // make sure the shader program and texture are being used
            Gl.UseProgram(program);
            Gl.ActiveTexture(TextureUnit.Texture1);
            Gl.BindTexture(brickNormals);
            Gl.ActiveTexture(TextureUnit.Texture0);
            Gl.BindTexture(brickDiffuse);

            // apply our camera view matrix to the shader view matrix (this can be used for all objects in the scene)
            program["view_matrix"].SetValue(camera.ViewMatrix);

            // set up the model matrix and draw the cube
            program["model_matrix"].SetValue(Matrix4.Identity);
            program["enable_lighting"].SetValue(lighting);
            program["enable_mapping"].SetValue(normalMapping);

            Gl.BindBufferToShaderAttribute(cube, program, "vertexPosition");
            Gl.BindBufferToShaderAttribute(cubeNormals, program, "vertexNormal");
            Gl.BindBufferToShaderAttribute(cubeTangents, program, "vertexTangent");
            Gl.BindBufferToShaderAttribute(cubeUV, program, "vertexUV");
            Gl.BindBuffer(cubeTriangles);

            Gl.DrawElements(BeginMode.Triangles, cubeTriangles.Count, DrawElementsType.UnsignedInt, IntPtr.Zero);

            // bind the font program as well as the font texture
            Gl.UseProgram(fontProgram.ProgramID);
            Gl.BindTexture(font.FontTexture);

            // draw the tutorial information, which is static
            information.Draw();

            Glut.glutSwapBuffers();
        }