int DrawModel(MODEL model, BITMAP* buffer)
{
int i;
int x;
int y;
int num_faces = model.num_faces;
int num_triangles[num_faces];
textout(screen,font,"found number of faces/triangles", 1,40,makecol16(255,255,255));
for(i = 0; i < num_faces; i++)
{
num_triangles = model.faces.num_triangles;
}
textout(screen,font,"filled in num trianglse in each face", 1,50,makecol16(255,255,255));
for(x = 0; x < num_faces; x++)
{
textout(screen,font,"got in x loop", 1,x*10,makecol16(255,0,0));
for(y = 0; y < num_triangles[x]; y++)
{
triangle(buffer, MAKE_CORD_X(model,model.faces[x].triangles[y],0), MAKE_CORD_Y(model,model.faces[x].triangles[y], 0), MAKE_CORD_X(model,model.faces[x].triangles[y],1), MAKE_CORD_Y(model,model.faces[x].triangles[y], 1), MAKE_CORD_X(model,model.faces[x].triangles[y],2), MAKE_CORD_Y(model,model.faces[x].triangles[y], 2), makecol16(255,0,0));
textout(screen,font,"drawn triangle", 1,80, makecol16(255,0,0));
}
textout(screen,font,"done drawing triangles in face",10,x*20,makecol16(255,0,0));
// i never get this message, so this must be where it is hanging
}
textout(screen,font,"got out of loop", 1,90,makecol16(255,0,0));
return(0);
}
</pre>
if you look up under the for() loop inside the other for() loop, i have a function that prints out a message. i get all messages previous to this one, so i figure that is where it is hanging.
i have a feeling it is hanging becuase right now i have only 1 face, and 1 triangle on that face, and it is messing it up with the array or something. </i>
problems with a for() loop
alright im also the guy from the "more problems with pointers" post, so read that first and get an update on my structures
heres my problem, my function DrawModel(MODEL model) is hanging because of a for() loop. heres the code:
"I never let schooling interfere with my education" - Mark Twain
Shouldn't the line in that first for loop say num_triangles? <br> </pre> <br><br><br>Edited by - Ampere on December 10, 2000 6:13:30 PM
December 13, 2000 11:29 AM
Does anyone here ever use their debugger? With mine I can see what line the program is on, right down to the assembly instruction that is being executed (with a niffty highlighted text showing where I am in the source code), look at the varibles as they change, as even see structures as nested varibles. Don''t ever say ''I figure that is where it is hanging''. Follow your program as it executes and know for sure. Set a break point at that line of code and check it each time it gets there. Mine even works with optimized code (although that is harder to follow).
Sorry if that sounded mean, but you really should learn how to use a debugger. It can save you alot of time guessing at the problem. If you don''t have one (which I doubt) get one!!!
Sorry if that sounded mean, but you really should learn how to use a debugger. It can save you alot of time guessing at the problem. If you don''t have one (which I doubt) get one!!!
quote: Original post by Anonymous Poster
Does anyone here ever use their debugger? With mine I can see what line the program is on, right down to the assembly instruction that is being executed (with a niffty highlighted text showing where I am in the source code), look at the varibles as they change, as even see structures as nested varibles. Don''t ever say ''I figure that is where it is hanging''. Follow your program as it executes and know for sure. Set a break point at that line of code and check it each time it gets there. Mine even works with optimized code (although that is harder to follow).
Sorry if that sounded mean, but you really should learn how to use a debugger. It can save you alot of time guessing at the problem. If you don''t have one (which I doubt) get one!!!
Absolutely correct, although to be fair some people only program games in
fullscreen mode, hence they are unable to use the debugger. This is
the main reason why I ALWAYS allow my programs to run in both full screen
and windowed mode. It''s actually rather easy to add that feature in
and it makes debugging 100x easier.
- Houdini
- Houdini
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement