Presentation is loading. Please wait.

Presentation is loading. Please wait.

Drawing Primitives. Foreward This presentation shows how some primitive shapes may be drawn using openTK (openGL) This is not the only approach to draw.

Similar presentations


Presentation on theme: "Drawing Primitives. Foreward This presentation shows how some primitive shapes may be drawn using openTK (openGL) This is not the only approach to draw."— Presentation transcript:

1 Drawing Primitives

2 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

3 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(); }

4 Lines

5 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(); }

6 Polygon

7 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(); }

8 Triangles

9 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(); }

10 LineStrip

11 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(); }

12 Triangle Fan

13 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(); }

14 QuadStrip

15 Constructing Shapes from Lines

16 Shapes From Lines

17 Composing Solid Objects Using TRFans

18 A Cone

19 Same Cone Using Outline Mode


Download ppt "Drawing Primitives. Foreward This presentation shows how some primitive shapes may be drawn using openTK (openGL) This is not the only approach to draw."

Similar presentations


Ads by Google