Advertisement

glquad and glbegin/glend problem

Started by July 25, 2000 10:54 PM
3 comments, last by mheyman0 24 years, 3 months ago
I have written a function to read data information from a file to be used to create an object, a cube at the moment. The problem is when I run the program, the cube is missing 1 triangle. I tried to see if the data input was the problem, but an output file created the same data set and info. The only other problem I can think of that may cause the problem is either a problem with the way glquad/glbegin/glend work and the way I implemented them, or if I have created a for() loop error. The code goes something like this... glBegin(GL_QUADS);// Draw A Quad for(int loop1 = 0; loop1 < world.numpolys; loop1++) //use a loop to jump through the points in the object { glTexCoord2f(world.Polylist[loop1].TexX, world.Polylist[loop1].TexY); glVertex3f(world.Polylist[loop1].point1, world.Polylist[loop1].point2, world.Polylist[loop1].point3); } glEnd(); I''m not sure how to fix this problem..... Source and/or exe available by request. Thanks for any help Matthew Heyman
for(int loop1 = 0; loop1 < world.numpolys; loop1++)
maybe try:

for(int loop1 = 0; loop1 <= world.numpolys; loop1++)

i can''t finde any other prob in the source...
if there''s 1 poly missing, this is what i''d try first...

hope it helps...

cya,

Phil
Advertisement
GL_QUADS need 4 vertices per poly. You specify only one vertex in your loop ?! Are you sure you must loop to world.numpolys, and not world.numvertices (or whatever it''s called ?). And why are you calling Polylist a structure that is (should, in fact be), Vertexlist ?

Y.
Most of the problems you are seeing simply deal with bad naming parameters when I originally wrote the code...

The poly structure holds the 3 points and 2 texture coordinates. It should properly be named vertex, but thats beside the point.

The polylist structure holds a list of poly structures, or vertexlist if the naming was proper.

The numpolys refers to the total number of what would properly be called vertices in the object. Seeing as how there is only 1 object in the world, that should fit properly.

I only specify 1 vertex in my loop because the vertex number changes with the looping variable.. If it is working properly, you should have 24 different vertices called and put into the poly before you run into the glend, and thus a perfect 4 sided object.

GLQUADS should, based on my understanding, turn those 24 vertices into 6 faces with 4 vertices each. I can''t see any real distinction(based on NeHe''s code, which is what this is built off) between running through a loop that goes through 24 vertices or typing out the 24 vertices seperately.

After digging through the Opengl documentation, I am beginning to think I have a looping error, but I can''t find where..

Hope this clears a good bit up

Matthew Heyman


Ok...... problem fixed..... there was something screwy in the data file. Looked to be completely right, but retyping the sucker fixed the problem... Man stuff like that is annoying.

Matthew Heyman

This topic is closed to new replies.

Advertisement