예제 #1
0
        public override void draw()
        {
            /*
             * Vertex positions (in-model)
             */

            int positionAttribLocation = GL.GetAttribLocation(game.getShader(), "in_position");

            GL.VertexAttribPointer(positionAttribLocation, 3, VertexAttribPointerType.Float, false, Vector3.SizeInBytes, 0);
            GL.EnableVertexAttribArray(positionAttribLocation);

            /*
             * Model position (outside-model)
             */

            Matrix4 model = Matrix4.Identity;
            //model = model * Matrix4.CreateTranslation(new Vector3(-game.screenW / 2, -game.screenH / 2, 0));

            int modelUniformLocation = GL.GetUniformLocation(game.getShader(), "model_matrix");

            GL.UniformMatrix4(modelUniformLocation, false, ref model);

            /*
             * Draw
             */

            GL.DrawArrays(PrimitiveType.Triangles, vboIndex, vertices.Length);

            /*
             * Clean up
             */

            GL.DisableVertexAttribArray(positionAttribLocation);
        }
예제 #2
0
        protected override void OnRenderFrame(FrameEventArgs e)
        {
            this.Title = "FPS: " + (this.RenderFrequency).ToString("F2") + " UPS: " + (this.UpdateFrequency).ToString("F2");
            base.OnRenderFrame(e);

            /*
             * Clear buffer
             */

            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);


            /*
             * Calculate Projection & View
             */

            Matrix4 projection = Matrix4.CreateOrthographic(base.Width, base.Height, 0.01f, 100);
            Matrix4 view       = Matrix4.LookAt(new Vector3(0, 0, 3), new Vector3(0, 0, 0), new Vector3(0, 1, 0));

            GL.UseProgram(game.getShader());

            int projectionUniformLocation = GL.GetUniformLocation(game.getShader(), "projection_matrix");
            int viewUniformLocation       = GL.GetUniformLocation(game.getShader(), "view_matrix");

            GL.UniformMatrix4(projectionUniformLocation, false, ref projection);
            GL.UniformMatrix4(viewUniformLocation, false, ref view);

            /*
             * Tell the engine to draw objects
             */

            game.drawAll();

            /*
             * Clean up
             */

            GL.UseProgram(0);
            SwapBuffers();
        }
예제 #3
0
        public override void draw()
        {
            int positionAttribLocation = GL.GetAttribLocation(game.getShader(), "in_position");

            GL.VertexAttribPointer(positionAttribLocation, 3, VertexAttribPointerType.Float, false, Vector3.SizeInBytes, 0);
            GL.EnableVertexAttribArray(positionAttribLocation);

            Matrix4 model = Matrix4.Identity;

            model = model * Matrix4.CreateRotationZ(angle);
            model = model * Matrix4.CreateTranslation(new Vector3(x, y, 0));


            int modelUniformLocation = GL.GetUniformLocation(game.getShader(), "model_matrix");

            GL.UniformMatrix4(modelUniformLocation, false, ref model);


            GL.DrawArrays(PrimitiveType.Triangles, vboIndex, vertices.Length);

            GL.DisableVertexAttribArray(positionAttribLocation);
        }