/// <summary> /// Render Method /// </summary> public void Render() { int wid2 = m_WindowWidth / 2; // Draw demo 1 on the first half of the window GL.Viewport(0, 0, wid2, m_WindowHeight); m_Demo01.Render(); // Draw demo 2 on the second half of the window. GL.Viewport(wid2, 0, wid2, m_WindowHeight); m_Demo02.Render(); }
/// <summary> /// Render /// </summary> public override void Render() { // // First Render to our frame buffer. // // bind to our frame buffer GL.BindFramebuffer(FramebufferTarget.Framebuffer, m_Fbo); GL.Enable(EnableCap.DepthTest); // we need to clear our frame buffer ourselves. GL.ClearColor(0.0f, 0.0f, 0.0f, 1f); GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); // render the triangle from the triangle demo onto our frame buffer. m_TriangleDemo.OnResize(FRAME_BUFFER_DIM, FRAME_BUFFER_DIM); m_TriangleDemo.Render(); // // Now render the frame buffer texture to our screen. // // back to the standard frame buffer. GL.BindFramebuffer(FramebufferTarget.Framebuffer, 0); GL.ClearColor(0.2f, 0.2f, 0.2f, 1f); // ensure viewport set correctly. OnResize(m_Width, m_Height); // begin using the shader. m_Shader.Begin(); // reset the model view matrix. m_ModelViewMatrix = Matrix4.Identity; // apply a rotation to the model view. m_ModelViewMatrix = Matrix4.Mult(m_ModelViewMatrix, Matrix4.CreateRotationZ(MathHelper.DegreesToRadians(angle))); m_ModelViewMatrix = Matrix4.Mult(m_ModelViewMatrix, Matrix4.CreateRotationY(MathHelper.DegreesToRadians(angle))); m_Shader.UpdateProjectionMatrix(m_ProjectionMatrix); m_Shader.UpdateModelViewMatrix(m_ModelViewMatrix); // ensure vertex and tex coords attrib arrays are enabled. GL.EnableVertexAttribArray(m_Shader.VertexAttribLocation); GL.EnableVertexAttribArray(m_Shader.TextureCoordAttribLocation); // set up where to find the data in the buffer. GL.BindBuffer(BufferTarget.ArrayBuffer, m_CubBuffer); GL.VertexAttribPointer(m_Shader.VertexAttribLocation, 3, VertexAttribPointerType.Float, true, sizeof(float) * 5, 0); GL.VertexAttribPointer(m_Shader.TextureCoordAttribLocation, 2, VertexAttribPointerType.Float, true, sizeof(float) * 5, sizeof(float) * 3); // set up to look at the Frame buffer texture. m_Shader.SetTextureSlot(0); GL.ActiveTexture(TextureUnit.Texture0); GL.BindTexture(TextureTarget.Texture2D, m_FboColorTexture); // draw the cube (made up of triangle strip) GL.DrawArrays(BeginMode.TriangleStrip, 0, 14); GL.BindTexture(TextureTarget.Texture2D, 0); // finished with the shader. m_Shader.End(); // increment our rotation angle += 1; if (angle > 360) { angle = 0f; } ; }