Grid Drawing

Started by
2 comments, last by Ademan555 19 years, 3 months ago
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
When General Patton died after World War 2 he went to the gates of Heaven to talk to St. Peter. The first thing he asked is if there were any Marines in heaven. St. Peter told him no, Marines are too rowdy for heaven. He then asked why Patton wanted to know. Patton told him he was sick of the Marines overshadowing the Army because they did more with less and were all hard-core sons of bitches. St. Peter reassured him there were no Marines so Patton went into Heaven. As he was checking out his new home he rounded a corner and saw someone in Marine Dress Blues. He ran back to St. Peter and yelled "You lied to me! There are Marines in heaven!" St. Peter said "Who him? That's just God. He wishes he were a Marine."
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.
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;

-- Jonathan
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]
When General Patton died after World War 2 he went to the gates of Heaven to talk to St. Peter. The first thing he asked is if there were any Marines in heaven. St. Peter told him no, Marines are too rowdy for heaven. He then asked why Patton wanted to know. Patton told him he was sick of the Marines overshadowing the Army because they did more with less and were all hard-core sons of bitches. St. Peter reassured him there were no Marines so Patton went into Heaven. As he was checking out his new home he rounded a corner and saw someone in Marine Dress Blues. He ran back to St. Peter and yelled "You lied to me! There are Marines in heaven!" St. Peter said "Who him? That's just God. He wishes he were a Marine."

This topic is closed to new replies.

Advertisement