public void Resized(OpenGL gl, double aspect) { // Set the projection matrix. gl.MatrixMode(OpenGL.GL_PROJECTION); // Load the identity. gl.LoadIdentity(); // Create a perspective transformation. gl.Perspective(60.0f, aspect, 0.01, 100.0); CamController.Aspect = aspect; // Use the 'look at' helper function to position and aim the camera. CamController.SetCam(gl); // Set the modelview matrix. gl.MatrixMode(OpenGL.GL_MODELVIEW); }
public void RenderObjects(OpenGL gl, GameObject[] objects) { //clears the screen gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT); //St matrix mode to PROJECTION so we can move the camera gl.MatrixMode(OpenGL.GL_PROJECTION); // Load the identity matrix. gl.LoadIdentity(); //Move the camera CamController.SetCam(gl); //Set matrix mode back to Modelview so we can draw objects gl.MatrixMode(OpenGL.GL_MODELVIEW); if (_mode == RenderMode.WireFrame || _mode == RenderMode.Hitboxes) { foreach (GameObject obj in objects) { //Draw the object with texture obj.Draw(gl); //Unbind texture so we can draw lines gl.BindTexture(OpenGL.GL_TEXTURE_2D, 0); if (_mode == RenderMode.Hitboxes) { obj.DrawVelocity(gl); DrawCircle(gl, obj.GetPosition().x, obj.GetPosition().y, obj.GetPhysSize()); } else { obj.DrawWireFrame(gl); } } } else { foreach (GameObject obj in objects) { //Draw the object with texture obj.Draw(gl); } } //Unbind texture gl.BindTexture(OpenGL.GL_TEXTURE_2D, 0); }