19
Drawing Primitives

Drawing Primitives

  • Upload
    ursala

  • View
    50

  • Download
    0

Embed Size (px)

DESCRIPTION

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. - PowerPoint PPT Presentation

Citation preview

Page 1: Drawing Primitives

Drawing Primitives

Page 2: 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

Page 3: Drawing Primitives

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

Page 4: Drawing Primitives

Lines

Page 5: Drawing Primitives

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

Page 6: Drawing Primitives

Polygon

Page 7: Drawing Primitives

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

Page 8: Drawing Primitives

Triangles

Page 9: Drawing Primitives

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

Page 10: Drawing Primitives

LineStrip

Page 11: Drawing Primitives

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

}

Page 12: Drawing Primitives

Triangle Fan

Page 13: Drawing Primitives

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

Page 14: Drawing Primitives

QuadStrip

Page 15: Drawing Primitives

Constructing Shapes from Lines

Page 16: Drawing Primitives

Shapes From Lines

Page 17: Drawing Primitives

Composing Solid Objects Using TRFans

Page 18: Drawing Primitives

A Cone

Page 19: Drawing Primitives

Same Cone Using Outline Mode