====== glColor() ====== glColor() ist definiert im OpenGL zugehörigen [[Include]] des jeweiligen Betriebsystems. ===== Funktion ===== glColor() definiert die Farbe des nächsten Vertex. Diese Farbe wird für alle folgenden Vertexe verwendet, bis sie mit glColor wieder geändert wird. ===== Signatur ===== void glColor3b( GLbyte red, GLbyte green, GLbyte blue); void glColor3s( GLshort red, GLshort green, GLshort blue); void glColor3i( GLint red, GLint green, GLint blue); void glColor3f( GLfloat red, GLfloat green, GLfloat blue); void glColor3d( GLdouble red, GLdouble green, GLdouble blue); void glColor3ub( GLubyte red, GLubyte green, GLubyte blue); void glColor3us( GLushort red, GLushort green, GLushort blue); void glColor3ui( GLuint red, GLuint green, GLuint blue); void glColor4b( GLbyte red, GLbyte green, GLbyte blue, GLbyte alpha); void glColor4s( GLshort red, GLshort green, GLshort blue, GLshort alpha); void glColor4i( GLint red, GLint green, GLint blue, GLint alpha); void glColor4f( GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); void glColor4d( GLdouble red, GLdouble green, GLdouble blue, GLdouble alpha); void glColor4ub( GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha); void glColor4us( GLushort red, GLushort green, GLushort blue, GLushort alpha); void glColor4ui( GLuint red, GLuint green, GLuint blue, GLuint alpha); **red**: Rotanteil der Farbe \\ **green**: Grünanteil der Farbe \\ **blue**: Blauanteil der Farbe \\ **alpha**: Opazität((Gegenteil von Transparenz("Durchleuchtbarkeit"): je opakter eine Farbe ist, desto weniger Licht scheint durch die Farbe hindurch, desto klarer ist der Gegenstand zu sehen. Besitzt ein Gegenstant keine Opazität, so ist er durchsichtig.)) Alle Werte werden von 0.0 bis 1.0 angegeben. Bei den Varianten, die [[c:attr:unsigned|vorzeichenlose]] Integertypen nehmen, wird der jeweils höchst darstellbare Wert als 1.0 repräsentiert und 0 wird auf 0.0 abgebildet. Bei [[c:attr:signed|vorzeichenbehafteten]] Integerstypen wird der höchste Wert als +1.0 gewertet, der niedrigstmögliche Wert als -1.0 und 0 auf einen Wert sehr nahe 0.0 abgebildet. void glColor3bv( GLbyte const * values); void glColor3sv( GLshort const * values); void glColor3iv( GLint const * values); void glColor3fv( GLfloat const * values); void glColor3dv( GLdouble const * values); void glColor3ubv( GLubyte const * values); void glColor3usv( GLushort const * values); void glColor3uiv( GLuint const * values); void glColor4bv( GLbyte const * values); void glColor4sv( GLshort const * values); void glColor4iv( GLint const * values); void glColor4fv( GLfloat const * values); void glColor4dv( GLdouble const * values); void glColor4ubv( GLubyte const * values); void glColor4usv( GLushort const * values); void glColor4uiv( GLuint const * values); **values**: Array mit 3 bzw. 4 Werten des angegebenen Datentyps, entsprechend wie oben beschrieben in der Reihenfolge Rot, Grün, Blau, bzw. Rot, Grün, Blau, Alpha. ===== Fehlerquellen ===== -- ===== Hinweise ===== ===== Beispiel ===== void display( void ) { /* clear all pixels */ glClear( GL_COLOR_BUFFER_BIT ); /* Draw white polygon (rectangle) with corners at * (0.25, 0.25, 0) and (0.75, 0.75, 0.0) */ glColor3f( 1.0, 1.0, 1.0 ); glBegin( GL_POLYGON ); glVertex3f( 0.25, 0.25, 0.0 ); glVertex3f( 0.75, 0.25, 0.0 ); glVertex3f( 0.75, 0.75, 0.0 ); glVertex3f( 0.25, 0.75, 0.0 ); glEnd(); /* don't wait * start processing buffered OpenGL routines */ glFlush(); } ===== Abfragen per glGet() ===== * GL_CURRENT_COLOR * GL_RGBA_MODE ===== siehe auch ===== [[ogl:lib:start|OpenGL]]: [[ogl:lib:glColorPointer()]], [[ogl:lib:glIndex()]], [[ogl:lib:glSecondaryColor()]], [[ogl:lib:glGet()]]