Work Text4
Work Text4
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.
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.