1 / 20

OpenGL Primitives

OpenGL Primitives. An ongoing debate about which primitives should be supported in an API. OpenGL takes an intermediate position. Two classes of primitives. Geometric Primitives Raster Primitives. Geometric Primitives Defination. GL_LINES. glBegin( GL_LINES ); glVertex2f(x1,y1);

rhutchens
Download Presentation

OpenGL 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. OpenGL Primitives • An ongoing debate about which primitives should be supported in an API. • OpenGL takes an intermediate position

  2. Two classes of primitives • Geometric Primitives • Raster Primitives

  3. Geometric Primitives Defination

  4. GL_LINES glBegin(GL_LINES); glVertex2f(x1,y1); glVertex2f(x2,y2); glEnd( );

  5. GL_POINTS glBegin(GL_POINTS); glVertex2f(x1,y1); glVertex2f(x2,y2); glEnd( );

  6. glVertex* • #define GLfloat float • glVertex2i (GLint xi, GLint yi) • glVertex3f (GLfloat x, GLfloat y, GLfloat z )

  7. glVertex* GLfloat vertex[3] glVertex3fv(vertex)

  8. OpenGL Command Formats

  9. OpenGL Geometric Primitives • GL_POINTS • GL_LINES • GL_LINE_STRIP • GL_LINE_LOOP

  10. P2 P1 P3 P4 P0 P5 GL_POINTS

  11. P2 P1 P3 P4 P0 P5 GL_LINES

  12. GL_LINES_STRIP P2 P1 P3 P4 P0 P5

  13. GL_LINES_LOOP P2 P1 P3 P4 P0 P5

  14. Polygon Types in OpenGL • GL_POLYGON • GL_TRIANGLES • GL_QUADS • GL_TRIANGLE_STRIP • GL_QUAD_STRIP • GL_TRIANGLE_FAN

  15. GL_POLYGON P2 P1 P3 P4 P0 P5

  16. GL_TRIANGLES P2 P1 P3 P4 P0 P5

  17. P2 P1 P3 P4 P0 P5 GL_QUADS

  18. Geometric Primitives

  19. Example 1 void drawRhombus( GLfloat color[] ) {glBegin( GL_QUADS ); glColor3fv( color ); glVertex2f( 0.0, 0.0 ); glVertex2f( 1.0, 0.0 ); glVertex2f( 1.5, 1.118 ); glVertex2f( 0.5, 1.118 ); glEnd(); }

  20. GLfloat red, greed, blue; Glfloat coords[3]; glBegin( primType ); for ( i = 0; i < nVerts; ++i ) { glColor3f( red, green, blue ); glVertex3fv( coords ); } glEnd(); Example 2

More Related