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();
}
Grid Drawing
Wow, im at a complete loss and pretty embarassed about it lol
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
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;
float hTotalSize = 0.5 * TotalSize;
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement