Skip to main content

  | मौसम…

411 समाचार
Public archive edition · Attributed source reporting with original dates · AI drafts are excluded

411 REFERENCE · Wikibooks

OpenGL Programming/reference/glColor

Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.

Description Visual effect changes the color of the next objects to be drawn image:OpenGL_Programming_reference_glColor.png Usage Context Will work anywhere in Display loop but normally used between glBegin and glEnd. Affects everything following until it is called again or the loop starts over. glEnd(); and glBegin(); do not affect it. Usage Examples draws 7 points and 3 different colors starting from x center y .5+ and moving to x .6+ y .5+ shows that the color will stay even if you restart a new gl section shows that the color will stay even if the loop starts over replace the display function with this in the basic testing app program to see the results void display(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glBegin(GL_POINTS); glVertex3f(0.0,0.5,0.0);//drawn white or default color first loop and green all other loops glColor3f(1.0,0.5,0.0);//set red 100% green 50% blue 0% glVertex3f(0.1,0.5,0.0);//drawn orange glVertex3f(0.2,0.5,0.0);//drawn orange glColor3f(1.0,0.0,0.0);//set red 100% green 0% blue 0% glVertex3f(0.3,0.5,0.0);//drawn red glEnd(); glBegin(GL_POINTS); glVertex3f(0.4,0.5,0.0);//drawn red glColor3f(0.0,1.0,0.0);//set red 0% green 100% blue 0% glVertex3f(0.5,0.5,0.0);//drawn green glVertex3f(0.6,0.5,0.0);//drawn green glEnd(); glutSwapBuffers(); } Function definitions WINGDIAPI void APIENTRY glColor3b (GLbyte red, GLbyte green, GLbyte blue); WINGDIAPI void APIENTRY glColor3bv (const GLbyte *v); WINGDIAPI void APIENTRY glColor3d (GLdouble red, GLdouble green, GLdouble blue); WINGDIAPI void APIENTRY glColor3dv (const GLdouble *v); WINGDIAPI void APIENTRY glColor3f (GLfloat red, GLfloat green, GLfloat blue); WINGDIAPI void APIENTRY glColor3fv (const GLfloat *v); WINGDIAPI void APIENTRY glColor3i (GLint red, GLint green, GLint blue); WINGDIAPI void APIENTRY glColor3iv (const GLint *v); WINGDIAPI void APIENTRY glColor3s (GLshort red, GLshort green, GLshort blue); WINGDIAPI void APIENTRY glColor3sv (const GLshort *v); WINGDIAPI void APIENTRY glColor3ub (GLubyte red, GLubyte green, GLubyte blue); WINGDIAPI void APIENTRY glColor3ubv (const GLubyte *v); WINGDIAPI void APIENTRY glColor3ui (GLuint red, GLuint green, GLuint blue); WINGDIAPI void APIENTRY glColor3uiv (const GLuint *v); WINGDIAPI void APIENTRY glColor3us (GLushort red, GLushort green, GLushort blue); WINGDIAPI void APIENTRY glColor3usv (const GLushort *v); WINGDIAPI void APIENTRY glColor4b (GLbyte red, GLbyte green, GLbyte blue, GLbyte alpha); WINGDIAPI void APIENTRY glColor4bv (const GLbyte *v); WINGDIAPI void APIENTRY glColor4d (GLdouble red, GLdouble green, GLdouble blue, GLdouble alpha); WINGDIAPI void APIENTRY glColor4dv (const GLdouble *v); WINGDIAPI void APIENTRY glColor4f (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); WINGDIAPI void APIENTRY glColor4fv (const GLfloat *v); WINGDIAPI void APIENTRY glColor4i (GLint red, GLint green, GLint blue, GLint alpha); WINGDIAPI void APIENTRY glColor4iv (const GLint *v); WINGDIAPI void APIENTRY glColor4s (GLshort red, GLshort green, GLshort blue, GLshort alpha); WINGDIAPI void APIENTRY glColor4sv (const GLshort *v); WINGDIAPI void APIENTRY glColor4ub (GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha); WINGDIAPI void APIENTRY glColor4ubv (const GLubyte *v); WINGDIAPI void APIENTRY glColor4ui (GLuint red, GLuint green, GLuint blue, GLuint alpha); WINGDIAPI void APIENTRY glColor4uiv (const GLuint *v); WINGDIAPI void APIENTRY glColor4us (GLushort red, GLushort green, GLushort blue, GLushort alpha); WINGDIAPI void APIENTRY glColor4usv (const GLushort *v); Related functions WINGDIAPI void APIENTRY glColorMask (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); WINGDIAPI void APIENTRY glColorMaterial (GLenum face, GLenum mode); WINGDIAPI void APIENTRY glColorPointer (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); References http://www.cs.utk.edu/~vose/c-stuff/opengl/glColor.html