1 / 19

Drawing Primitives

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.

ursala
Download Presentation

Drawing Primitives

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

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

More Related