Skip to main content
GameDev.net gamedev.net
🔒 Locked

GL_LINES color [solved]

Started by Endar Jun 26, 2006 at 5:31 AM 0 replies 4.4k views
Original Post
Endar
Endar
I have a function that draws a line using immediate mode:

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();
}



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]
[size="2"][size=2]Mort, Duke of Sto Helit: NON TIMETIS MESSOR -- Don't Fear The Reaper
Endar
Endar
I found the problem: I'm an idiot.

The lines for the joints and the skeleton were being drawn using glBegin(GL_LINES), but in different functions (one using draw3dLine, the other not), so were I had one that was doing all the housekeeping (turning off lighting, texturing, saving the previous color, etc), the skeleton drawing one wasn't.

Solution? I changed the function that drew the skeleton to use 'draw3dLine', so everything is now all good as I can change the colors at will to anything I want.
[size="2"][size=2]Mort, Duke of Sto Helit: NON TIMETIS MESSOR -- Don't Fear The Reaper

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.