190 likes | 322 Views
Drawing Primitives. Foreward. This presentation shows how some primitive shapes may be drawn using openTK ( openGL ) This is not the only approach to draw these primitives, but may be the most common. DrawLine (). private void DrawLine () { // Clear screen to background color.
E N D
Foreward This presentation shows how some primitive shapes may be drawn using openTK (openGL) This is not the only approach to draw these primitives, but may be the most common
DrawLine() private void DrawLine() { // Clear screen to background color. GL.Clear(ClearBufferMask.ColorBufferBit); // Set foreground (or drawing) color. GL.Color3(Color.White); GL.Begin(BeginMode.Lines); GL.Vertex3(20.0, 20.0, 0.0); GL.Vertex3(80.0, 20.0, 0.0); GL.Vertex3(80.0, 80.0, 0.0); GL.Vertex3(20.0, 80.0, 0.0); GL.End(); // Flush created objects to the screen, i.e., force rendering. glControl1.SwapBuffers(); }
Polygon private void DrawPolygon() { // Clear screen to background color. GL.Clear(ClearBufferMask.ColorBufferBit); // Set foreground (or drawing) color. GL.Color3(Color.White); GL.Begin(BeginMode.Polygon); GL.Vertex3(20.0, 20.0, 0.0); GL.Vertex3(80.0, 20.0, 0.0); GL.Vertex3(80.0, 80.0, 0.0); GL.Vertex3(20.0, 80.0, 0.0); GL.End(); // force rendering. glControl1.SwapBuffers(); }
Triangles private void DrawLine() { // Clear screen to background color. GL.Clear(ClearBufferMask.ColorBufferBit); // Set foreground (or drawing) color. GL.Color3(Color.White); GL.Begin(BeginMode.Triangles); GL.Vertex3(10.0, 90.0, 0.0); GL.Vertex3(10.0, 10.0, 0.0); GL.Vertex3(35.0, 75.0, 0.0); GL.Vertex3(30.0, 20.0, 0.0); GL.Vertex3(90.0, 90.0, 0.0); GL.Vertex3(80.0, 40.0, 0.0); GL.End(); // force rendering. glControl1.SwapBuffers(); }
LineStrip private void DrawLineStrip() { // Clear screen to background color. GL.Clear(ClearBufferMask.ColorBufferBit); // Set foreground (or drawing) color. GL.Color3(Color.White); GL.Begin(BeginMode.LineStrip); GL.Vertex3(20.0, 20.0, 0.0); GL.Vertex3(80.0, 20.0, 0.0); GL.Vertex3(80.0, 80.0, 0.0); GL.Vertex3(20.0, 80.0, 0.0); GL.End(); // force rendering. glControl1.SwapBuffers(); }
TriangleFan private void DrawTRFan() { // Clear screen to background color. GL.Clear(ClearBufferMask.ColorBufferBit); // Set foreground (or drawing) color. GL.Color3(Color.White); GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Line); // Draw a polygon with specified vertices. GL.Begin(BeginMode.TriangleFan); GL.Vertex3(10.0, 10.0, 0.0); GL.Vertex3(15.0, 90.0, 0.0); GL.Vertex3(55.0, 75.0, 0.0); GL.Vertex3(80.0, 30.0, 0.0); GL.Vertex3(90.0, 10.0, 0.0); GL.End(); // Flush created objects to the screen, i.e., force rendering. glControl1.SwapBuffers(); }
QuadStrip private void DrawQDStrip() { // Clear screen to background color. GL.Clear(ClearBufferMask.ColorBufferBit); // Set foreground (or drawing) color. GL.Color3(Color.White); GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Line); // Draw a polygon with specified vertices. GL.Begin(BeginMode.QuadStrip); // glBegin(GL_LINE_STRIP); // glBegin(GL_LINE_LOOP); GL.Vertex3(10.0, 90.0, 0.0); GL.Vertex3(10.0, 10.0, 0.0); GL.Vertex3(30.0, 80.0, 0.0); GL.Vertex3(40.0, 15.0, 0.0); GL.Vertex3(60.0, 75.0, 0.0); GL.Vertex3(60.0, 25.0, 0.0); GL.Vertex3(90.0, 90.0, 0.0); GL.Vertex3(80.0, 20.0, 0.0); GL.End(); // Flush created objects to the screen, i.e., force rendering. glControl1.SwapBuffers(); }