private void openGLControl2_OpenGLDraw(object sender, UnU.OpenGL.RenderEventArgs args) { // Get the OpenGL object, just to clean up the code. var gl = openGLControlManual.OpenGL; gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT); gl.LoadIdentity(); gl.Translate(0f, 0.0f, -6.0f); gl.Rotate(rtri, 0.0f, 1.0f, 0.0f); gl.Begin(OpenGL.GL_TRIANGLES); gl.Color(1.0f, 0.0f, 0.0f); // Red gl.Vertex(0.0f, 1.0f, 0.0f); // Top Of Triangle (Front) gl.Color(0.0f, 1.0f, 0.0f); // Green gl.Vertex(-1.0f, -1.0f, 1.0f); // Left Of Triangle (Front) gl.Color(0.0f, 0.0f, 1.0f); // Blue gl.Vertex(1.0f, -1.0f, 1.0f); // Right Of Triangle (Front) gl.Color(1.0f, 0.0f, 0.0f); // Red gl.Vertex(0.0f, 1.0f, 0.0f); // Top Of Triangle (Right) gl.Color(0.0f, 0.0f, 1.0f); // Blue gl.Vertex(1.0f, -1.0f, 1.0f); // Left Of Triangle (Right) gl.Color(0.0f, 1.0f, 0.0f); // Green gl.Vertex(1.0f, -1.0f, -1.0f); // Right Of Triangle (Right) gl.Color(1.0f, 0.0f, 0.0f); // Red gl.Vertex(0.0f, 1.0f, 0.0f); // Top Of Triangle (Back) gl.Color(0.0f, 1.0f, 0.0f); // Green gl.Vertex(1.0f, -1.0f, -1.0f); // Left Of Triangle (Back) gl.Color(0.0f, 0.0f, 1.0f); // Blue gl.Vertex(-1.0f, -1.0f, -1.0f); // Right Of Triangle (Back) gl.Color(1.0f, 0.0f, 0.0f); // Red gl.Vertex(0.0f, 1.0f, 0.0f); // Top Of Triangle (Left) gl.Color(0.0f, 0.0f, 1.0f); // Blue gl.Vertex(-1.0f, -1.0f, -1.0f); // Left Of Triangle (Left) gl.Color(0.0f, 1.0f, 0.0f); // Green gl.Vertex(-1.0f, -1.0f, 1.0f); // Right Of Triangle (Left) gl.End(); // Done Drawing The Pyramid }
private void openGLControlTimerBased_OpenGLDraw(object sender, UnU.OpenGL.RenderEventArgs args) { // Get the OpenGL object, just to clean up the code. var gl = openGLControlTimerBased.OpenGL; gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT); gl.LoadIdentity(); gl.Translate(0f, 0.0f, -7.0f); // Move Right And Into The Screen gl.Rotate(rquad, 1.0f, 1.0f, 1.0f); // Rotate The Cube On X, Y & Z gl.Begin(OpenGL.GL_QUADS); // Start Drawing The Cube gl.Color(0.0f, 1.0f, 0.0f); // Set The Color To Green gl.Vertex(1.0f, 1.0f, -1.0f); // Top Right Of The Quad (Top) gl.Vertex(-1.0f, 1.0f, -1.0f); // Top Left Of The Quad (Top) gl.Vertex(-1.0f, 1.0f, 1.0f); // Bottom Left Of The Quad (Top) gl.Vertex(1.0f, 1.0f, 1.0f); // Bottom Right Of The Quad (Top) gl.Color(1.0f, 0.5f, 0.0f); // Set The Color To Orange gl.Vertex(1.0f, -1.0f, 1.0f); // Top Right Of The Quad (Bottom) gl.Vertex(-1.0f, -1.0f, 1.0f); // Top Left Of The Quad (Bottom) gl.Vertex(-1.0f, -1.0f, -1.0f); // Bottom Left Of The Quad (Bottom) gl.Vertex(1.0f, -1.0f, -1.0f); // Bottom Right Of The Quad (Bottom) gl.Color(1.0f, 0.0f, 0.0f); // Set The Color To Red gl.Vertex(1.0f, 1.0f, 1.0f); // Top Right Of The Quad (Front) gl.Vertex(-1.0f, 1.0f, 1.0f); // Top Left Of The Quad (Front) gl.Vertex(-1.0f, -1.0f, 1.0f); // Bottom Left Of The Quad (Front) gl.Vertex(1.0f, -1.0f, 1.0f); // Bottom Right Of The Quad (Front) gl.Color(1.0f, 1.0f, 0.0f); // Set The Color To Yellow gl.Vertex(1.0f, -1.0f, -1.0f); // Bottom Left Of The Quad (Back) gl.Vertex(-1.0f, -1.0f, -1.0f); // Bottom Right Of The Quad (Back) gl.Vertex(-1.0f, 1.0f, -1.0f); // Top Right Of The Quad (Back) gl.Vertex(1.0f, 1.0f, -1.0f); // Top Left Of The Quad (Back) gl.Color(0.0f, 0.0f, 1.0f); // Set The Color To Blue gl.Vertex(-1.0f, 1.0f, 1.0f); // Top Right Of The Quad (Left) gl.Vertex(-1.0f, 1.0f, -1.0f); // Top Left Of The Quad (Left) gl.Vertex(-1.0f, -1.0f, -1.0f); // Bottom Left Of The Quad (Left) gl.Vertex(-1.0f, -1.0f, 1.0f); // Bottom Right Of The Quad (Left) gl.Color(1.0f, 0.0f, 1.0f); // Set The Color To Violet gl.Vertex(1.0f, 1.0f, -1.0f); // Top Right Of The Quad (Right) gl.Vertex(1.0f, 1.0f, 1.0f); // Top Left Of The Quad (Right) gl.Vertex(1.0f, -1.0f, 1.0f); // Bottom Left Of The Quad (Right) gl.Vertex(1.0f, -1.0f, -1.0f); // Bottom Right Of The Quad (Right) gl.End(); // Done Drawing The Q gl.Flush(); rtri += 3.0f;// 0.2f; // Increase The Rotation Variable For The Triangle rquad -= 3.0f;// 0.15f; // Decrease The Rotation Variable For The Quad }