0% found this document useful (0 votes)
4 views2 pages

Work Text4

Uploaded by

ianmodesto34
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views2 pages

Work Text4

Uploaded by

ianmodesto34
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Work Text #4: Drawing Primitives and Colors

Learning Outcomes:
a. Familiarize the different drawing primitives in OpenGL
b. Demonstrate OpenGL Colors

Drawing Primitives
Primitives are basic shapes that you can easily draw. It can be a triangle, a square, or even a
single point.

glBegin — delimit the vertices of a primitive or a group of like primitives


Specifies the primitive or primitives that will be created from vertices presented
between glBegin and the subsequent glEnd

GL_POINTS Draws points on screen. Every vertex specified is a point.


GL_LINES Draws lines on screen. Every two vertices specified compose a line.
GL_LINE_STRIP Draws connected lines on screen. Every vertex specified after first
two are connected.
GL_LINE_LOOP Draws connected lines on screen. The last vertex specified is
connected to first vertex.
GL_TRIANGLES Draws triangles on screen. Every three vertices specified compose a
triangle.
GL_TRIANGLE_STRIP Draws connected triangles on screen. Every vertex specified after
first three vertices creates a triangle.
GL_TRIANGLE_FAN Draws connected triangles like GL_TRIANGLE_STRIP, except
draws triangles in fan shape.
GL_QUADS Draws quadrilaterals (4 – sided shapes) on screen. Every four
vertices specified compose a quadrilateral.
GL_QUAD_STRIP Draws connected quadrilaterals on screen. Every two vertices
specified after first four compose a connected quadrilateral.
GL_POLYGON Draws a polygon on screen. Polygon can be composed of as many
sides as you want.

OpenGL Color
glColor3f( )
- has three parameters of type float
- The parameters give the red, green, and blue components of the color as numbers in the
range 0.0 to 1.0.
Example: glColor3f(1,0, 0) → display red color

glColor4f( )
- The fourth component, known as alpha
Associated with;
glEnable(GL_BLEND)
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
example:
glColor4f(1, 0, 0, 0.5); # Draw in transparent red, but only if OpenGL
# has been configured to do transparency.
# By default this is the same as drawing in plain red.

You might also like