#include <color.h>
Public Member Functions | |
void | set (int r, int g, int b, int a) |
Function to set the values for a color. | |
ap_color (double r, double g, double b, double a=1.0) | |
Constructor to create a color using floating point values. | |
ap_color (int r, int g, int b, int a=255) | |
Constructor to create a color using byte values. | |
ap_color () | |
Default constructor. | |
Public Attributes | |
byte | r |
red | |
byte | g |
green | |
byte | b |
blue | |
byte | a |
alpha |
Each color is composed of red, green and blue color values along with an alpha value. These values all range from 0 to 255. A color with RGB values <255,0,0> is a bright red. The combination <255,255,0> is red and green which yields yellow. These values are scaled to fit the range 0.0 to 1.0 when used to define colors in OpenGL.
The alpha component is used in OpenGL to control blending of colors. An object with alpha value 255 (1.0 for OpenGL) is opaque and will replace the pixels of previously drawn objects which are behind an object. Smaller values for alpha allow differing amounts of color from more distant objects to blend with the color of an object being drawn.
OpenGL allows the programmer to choose between several blending functions. Animp uses the most obvious blending function with is named in OpenGL as GL_SRC_ALPHA for the source object and GL_ONE_MINUS_SRC_ALPHA for the existing pixels already rendered. This means that if you are currently drawing an object with alpha value 0.3, 30% of the color comes from the object itself and 70% from the objects behind it. Note that this only works if the more distant objects are already rendered. This is the reason why animp sorts the objects it draws.
|
Constructor to create a color using floating point values. This is a logical choice to use since so much OpenGL code and documentation use floating point color values. Note that the default value for alpha is 1.0 which means that colors are opaque unless you specify a different alpha value. |
|
Constructor to create a color using byte values. Note that the default value for alpha is 255 which means that colors are opaque unless you specify a different alpha value. |
|
Default constructor. The default color is an opaque black. |
|
Function to set the values for a color. This is used internally by the various constructors to avoid code duplication. |
|
red
|
|
green
|
|
blue
|
|
alpha
|