Archived

This topic is now archived and is closed to further replies.

DevLiquidKnight

Why isnt this working...

Recommended Posts

int x=0, z=0; for(x=-100; x<=100; x+=5) { for(z=-100; z<=100; z+=5) { glBegin(GL_QUADS); glColor3ub(0, 255, 0); glVertex3f((float)x, -1.0f, (float)z); // Left And Up 1 Unit (Top Left) glVertex3f((float)x, -1.0f, (float)z); // Right And Up 1 Unit (Top Right) glVertex3f((float)x, -1.0f, (float)z); // Right And Down One Unit (Bottom Right) glVertex3f((float)x, -1.0f, (float)z); glEnd(); } } it is suppose to create a bunch of 3d tiles but its not doing anything... Don''t click me! Killer Eagle Software

Share this post


Link to post
Share on other sites
You're specifying the same vertex four times. There is no variation in the four vertices that you send to glVertex3f. You send (x, -1.0f, z) four times. The vertices must be different, or no quad will be drawn.



Coding Stuff ->  [ iNsAn1tY Games | DarkVertex | How To Do CSG | Direct3D Vs. OpenGL | Google ]
Fun Stuff    ->  [ Evil T-Shirts | Stick-Based Comedy | You're Already Here | The Best Film Reviews ]


[edited by - iNsAn1tY on November 2, 2002 6:50:15 PM]

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Umm... you''re creating all your vertices on the same point.
Consider the first iteration:


// x=-100, z=-100
glBegin(GL_QUADS);
glColor3ub(0, 255, 0);
glVertex3f(-100.0f, -1.0f, -100.0f); // Left And Up 1 Unit (Top Left)
glVertex3f(-100.0f, -1.0f, -100.0f); // Right And Up 1 Unit (Top Right)
glVertex3f(-100.0f, -1.0f, -100.0f); // Right And Down One Unit (Bottom Right)
glVertex3f(-100.0f, -1.0f, -100.0f);
glEnd();


And this can''t work very well...

Share this post


Link to post
Share on other sites
quote:
Original post by Anonymous Poster
Umm... you''re creating all your vertices on the same point.
Consider the first iteration:


// x=-100, z=-100
glBegin(GL_QUADS);
glColor3ub(0, 255, 0);
glVertex3f(-100.0f, -1.0f, -100.0f); // Left And Up 1 Unit (Top Left)
glVertex3f(-100.0f, -1.0f, -100.0f); // Right And Up 1 Unit (Top Right)
glVertex3f(-100.0f, -1.0f, -100.0f); // Right And Down One Unit (Bottom Right)
glVertex3f(-100.0f, -1.0f, -100.0f);
glEnd();


And this can''t work very well...



Ah, HA! your right i forgot to do this
for(x=-100; x<=100; x+=5)
{
for(z=-100; z<=100; z+=5)
{
glBegin(GL_QUADS);
glColor3ub(0, 255, 0);
glVertex3f((float)x-5, -1.0f, (float)z-5); // Left And Up 1 Unit (Top Left)
glVertex3f((float)x, -1.0f, (float)z-5); // Right And Up 1 Unit (Top Right)
glVertex3f((float)x, -1.0f, (float)z); // Right And Down One Unit (Bottom Right)
glVertex3f((float)x-5, -1.0f, (float)z);
glEnd();
}
}


Don''t click me!
Killer Eagle Software

Share this post


Link to post
Share on other sites