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

doing lines hehehe

Started by stond May 18, 2003 at 7:16 PM 5 replies 500+ views
Original Post
stond
stond
the prog i'm working on showes a cube where each face has a different texture on it. i also have lighting enabled. everything works just peachy except a new function i made that draws the origin on the screen. it uses GL_LINES to draw 3 white lines on each axis intersecting at 0, 0, 0. i set the color to white, but my lines show up black. my question is if lighting can effect the way lines are drawn, and what other possibilities there are for such undesirable effects. ie do lines require normals. . . etc...
here's my drawOrigin function
<textarea name="drawo" rows=8 cols 120>
void drawOrigin(float radius)
{
	float r = radius/2.0f;
	
	glColor3f(1.0f, 1.0f, 1.0f);
	
	//x-axis
	glBegin(GL_LINES);
		glVertex3f(-r, 0.0f, 0.0f);
		glVertex3f( r, 0.0f, 0.0f);
	glEnd();
	
	//y-axis
	glBegin(GL_LINES);
		glVertex3f(0.0f, -r, 0.0f);
		glVertex3f(0.0f,  r, 0.0f);
	glEnd();
	
	//z-axis
	glBegin(GL_LINES);
		glVertex3f(0.0f, 0.0f, -r);
		glVertex3f(0.0f, 0.0f,  r);
	glEnd();
}
 
</textarea>
here's where i use it
<textarea name="implementation" rows=8 cols 120>
	void view(GLvoid)	
	{
		glMatrixMode(GL_MODELVIEW);	
		glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
		glLoadIdentity();

		glTranslatef(vector[X], vector[Y], vector[Z]);
		glRotatef(angle[X], 1.0f, 0.0f, 0.0f);
		glRotatef(angle[Y], 0.0f, 1.0f, 0.0f);
		glRotatef(angle[Z], 0.0f, 0.0f, 1.0f);
		
		rot +=.125f;
		if(rot >= 365.000f)
			rot -= 365.000f;
				
		glColor3f(.8f, .8f, .8f);
		
		drawCube(0.0f, 0.0f, -2.0f, 1.0f, 1.0f, 1.0f, rot);
		drawOrigin(10.0f);
		
		glFlush();	
		SwapBuffers(g_HDC);//bring back buffer to foreground
	} 
</textarea> [edited by - stond on May 18, 2003 8:23:10 PM]
JuNC
JuNC
Lighting affects *vertices*, it doesn''t matter whether you''re using lines or triangles. Typically for wireframe or simple line drawing you''d want to disable lighting (and WTH is ''a'' normal to a line? ).
stond
stond
in void view(GLvoid) i changed it up

glDisable(GL_LIGHTING); // new
drawOrigin(10.0f);
glEnable(GL_LIGHTING);// new

does not fix, maybe i ave the wrong idea of how lighting works.
can you light some things and not light others or does lighting effect the whole scene at all times? . . . i hope i'm asking the question right.

[edited by - stond on May 18, 2003 9:23:40 PM]
JuNC
JuNC
No, it''ll be lit according to whatever the last specified normal was.
stond
stond
i see, it''s that whole state machine business. i changed my last post.
beowulf
beowulf
Tried disabling texture before drawing lines?

glDisable(GL_TEXTURE_2D);
stond
stond
turning off lighting + textures did it.
thx you both taught me something valuble and fundamental.
thx!!

Topic Locked

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

Sign in to reply to this topic.