0% found this document useful (0 votes)
2 views

OpenGL Primitives

The document provides examples of different OpenGL drawing modes, including GL_LINES, GL_LINE_STRIP, GL_LINE_LOOP, GL_TRIANGLES, GL_TRIANGLE_STRIP, GL_QUADS, GL_QUAD_STRIP, GL_POLYGON, and GL_TRIANGLE_FAN. Each mode is illustrated with code snippets that specify vertices and colors for rendering shapes. All examples utilize the same color and a set of vertices to demonstrate the various drawing techniques.

Uploaded by

saranasser59177
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

OpenGL Primitives

The document provides examples of different OpenGL drawing modes, including GL_LINES, GL_LINE_STRIP, GL_LINE_LOOP, GL_TRIANGLES, GL_TRIANGLE_STRIP, GL_QUADS, GL_QUAD_STRIP, GL_POLYGON, and GL_TRIANGLE_FAN. Each mode is illustrated with code snippets that specify vertices and colors for rendering shapes. All examples utilize the same color and a set of vertices to demonstrate the various drawing techniques.

Uploaded by

saranasser59177
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 9

(1) GL_LINES

glBegin(GL_LINES);
glColor3f(1, 0, 0);
glVertex3f(-50, 0, 0);
glVertex3f(-25, 50, 0);
glVertex3f(-25, -50, 0);
glVertex3f(25, 50, 0);
glVertex3f(25, -50, 0);
glVertex3f(50, 0, 0);
glEnd();
(2) GL_LINE_STRIP

glBegin(GL_LINE_STRIP);
glColor3f(1, 0, 0);
glVertex3f(-50, 0, 0);
glVertex3f(-25, 50, 0);
glVertex3f(-25, -50, 0);
glVertex3f(25, 50, 0);
glVertex3f(25, -50, 0);
glVertex3f(50, 0, 0);
glEnd();
(3) GL_LINE_LOOP

glBegin(GL_LINE_LOOP);
glColor3f(1, 0, 0);
glVertex3f(-50, 0, 0);
glVertex3f(-25, 50, 0);
glVertex3f(-25, -50, 0);
glVertex3f(25, 50, 0);
glVertex3f(25, -50, 0);
glVertex3f(50, 0, 0);
glEnd();
(4) GL_TRAINGLES

glBegin(GL_TRIANGLES);
glColor3f(1, 0, 0);
glVertex3f(-50, 0, 0);
glVertex3f(-25, 50, 0);
glVertex3f(-25, -50, 0);
glVertex3f(25, 50, 0);
glVertex3f(25, -50, 0);
glVertex3f(50, 0, 0);
glEnd();
(5) GL_TRIANGLE_STRIP
glBegin(GL_TRIANGLE_STRIP);
glColor3f(1, 0, 0);
glVertex3f(-50, 0, 0);
glVertex3f(-25, 50, 0);
glVertex3f(-25, -50, 0);
glVertex3f(25, 50, 0);
glVertex3f(25, -50, 0);
glVertex3f(50, 0, 0);
glEnd();
(6) GL_QUADS
glBegin(GL_QUADS);
glColor3f(1, 0, 0);
glVertex3f(-50, 0, 0);
glVertex3f(-25, 50, 0);
glVertex3f(25, 50, 0);
glVertex3f(50, 0, 0);
glEnd();
(7) GL_QUAD_STRIP

glBegin(GL_QUAD_STRIP);
glColor3f(1, 0, 0);
glVertex3f(-50, 0, 0);
glVertex3f(-25, 50, 0);
glVertex3f(-25, -50, 0);
glVertex3f(25, 50, 0);
glVertex3f(25, -50, 0);
glVertex3f(50, 0, 0);
glEnd();
(8) GL_POLYGON

glBegin(GL_POLYGON);
glColor3f(1, 0, 0);
glVertex3f(-50, 0, 0);
glVertex3f(-25, 50, 0);
glVertex3f(25, 50, 0);
glVertex3f(50, 0, 0);
glVertex3f(25, -50, 0);
glVertex3f(-25, -50, 0);
glEnd();
(9) GL_TRAINGLE_FAN

glBegin(GL_TRIANGLE_FAN);
glColor3f(1, 0, 0);
glVertex3f(0,0,0);
glVertex3f(-50, 0, 0);
glVertex3f(-25, 50, 0);
glVertex3f(25, 50, 0);
glVertex3f(50, 0, 0);
glVertex3f(25, -50, 0);
glVertex3f(-25, -50, 0);
glEnd();

You might also like