Jump to content
  • Advertisement
Sign in to follow this  

GL_LINES color [solved]

This topic is 4525 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

	// get the current color
	glGetFloatv(GL_COLOR, old_color);
	// copy the new color to an array
	c.getRGBAFloatArray( new_color );


		// 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);


	// restore the old color
	glColor4fv( old_color );

	// if texturing was on, turn it back on
	if( tex )

 * 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]

Share this post

Link to post
Share on other sites
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.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!