Jump to content
  • Advertisement
Sign in to follow this  
Ademan555

Grid Drawing

This topic is 4974 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

Wow, im at a complete loss and pretty embarassed about it lol
void	DrawGrid(float Spacing, UINT Num, float R, float G, float B)
{
	float TotalSize = Num * Spacing;
	float hTotalSize = (1/2) * TotalSize;
	float nhTotalSize = hTotalSize * -1.0f;

	float Pos;
	Pos = nhTotalSize;

	glBegin(GL_LINES);
	glColor3f(R, G, B);
	for (UINT x = 0; x < Num; ++x)
	{
		glVertex3f(Pos, 0.0f, nhTotalSize);
		glVertex3f(Pos, 0.0f, hTotalSize);
		Pos += Spacing;
	}
	Pos = nhTotalSize;
	for (UINT y = 0; y < Num; ++y)
	{
		glVertex3f(nhTotalSize, 0.0f, Pos);
		glVertex3f(hTotalSize, 0.0f, Pos);
		Pos += Spacing;
	}
	glEnd();
}

texturing is disabled, so is lighting, im passing to it 1.0f for the cellspacing and 10 for the count, and 0, 1, 0 for the color, and in fact, i draw a line right outside of this function and it works... so im just at a loss... probably something dumb, ive been a bit sleep deprived lately lol thanks a ton -Dan

Share this post


Link to post
Share on other sites
Advertisement
It would be more helpful if you actually specified what the error is with that, kinda hard to take a guess at what could be wrong. Knowing the error there are probably only a few lines to look at.

Share this post


Link to post
Share on other sites
One thing that rings alarm bells is the (1/2) in line 4 (integer math), which would give you 0, try:

float hTotalSize = 0.5 * TotalSize;

Share this post


Link to post
Share on other sites
lucid ion: AHH!!!!! evil integer division!!! hahah thanks, im sure thats it


[EDIT:] yep, that was the problem, thanks again, i knew itd be something braindead and easy :-D
-Dan

[Edited by - Ademan555 on January 6, 2005 8:49:01 PM]

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!