Original Post
I have a function that draws a line using immediate mode: Each of the get*Float() functions returns the corresponding component of color in a range of [0.0,1.0] And, at the moment, lighting and texturing are disabled through use of the glDisable function. My problem is that I'm using this to draw the skeleton of a model, so, lots of lines, and the color of them won't change. In fact, I'm also using this function to draw the joints of the skeleton and the color won't change for them either. What exactly to I have to disable to get everything working? What should I be looking for? I mean, it seems fairly straightforward. Set a color and the line should be drawn in that color. [Edited by - Endar on June 26, 2006 9:09:21 AM]
void CVideoDriver::draw3dLine(const util::CVector3d& p1, const util::CVector3d& p2, const video::CColor& c) const
{
GLboolean tex; // whether texturing is active
float old_color[4];
float new_color[4];
// get if texturing is on
glGetBooleanv(GL_TEXTURE_2D, &tex);
// turn texturing off
glDisable(GL_TEXTURE_2D);
// get the current color
glGetFloatv(GL_COLOR, old_color);
// copy the new color to an array
c.getRGBAFloatArray( new_color );
glBegin(GL_LINES);
// set the color
glColor4fv( new_color );
// specify start and end point for line
glVertex3f(p1.x, p1.y, p1.z);
glVertex3f(p2.x, p2.y, p2.z);
glEnd();
// restore the old color
glColor4fv( old_color );
// if texturing was on, turn it back on
if( tex )
glEnable(GL_TEXTURE_2D);
}
/**
* Store the colors in a float array in the RGBA format
* \param f A pointer to the array to store the vars in
*/
void getRGBAFloatArray(float* f) const
{
f[0] = getRedFloat();
f[1] = getGreenFloat();
f[2] = getBlueFloat();
f[3] = getAlphaFloat();
}