Archived

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

RavNaz

OpenGl problem!

Recommended Posts

I exported a .map file, and converted the vertices to a pure list file. This file is then passed to my program which stores them in an 2dimensional array. This array is passed to glVertex3f( data[][], data[][], data[][]) So using the indices I loop thorugh the entire array and construct the object out of GL_TRIANGLES. Problem is however that a) the object once drawn is missing bits. b) the program crashes after several seconds. also the object is rotating which seems to work fine. Any ideas????

Share this post


Link to post
Share on other sites
Try to step through it in debug mode. Have a look on the arrays while doing this. Maybe any of the operations tries to access an invalid (unassigned) memory area. You should also check the declaration of the array; is it assigned dynamically, or has it a constant size? If so, maybe your program crashes because you try to access fields of the array which point to no data.
It would be much easier to help you if you provided more information, better a snippet from your code!

hth anyway
pi~

Share this post


Link to post
Share on other sites
float data[1000][3];

for (ctr = 0 ; ctr<=340 ; ctr++)
fscanf(in, "%f %f %f", &data[ctr][0], &data[ctr][1], &data[ctr][2]);

for (rav = 0 ; rav<=340 ; rav++)
{
glBegin(GL_TRIANGLES);
glVertex3f(data[rav][0], data[rav][1], data[rav][2] );
glEnd();
}

Any ideas??


Share this post


Link to post
Share on other sites
I doubt it will help your problem (well, maybe), but you should put glBegin/glEnd outside of your loop. glBegin and glEnd are somewhat expensive calls. And you don''t draw any triangles, only vertices. That''s bad. A triangle is made up from three vertices.

EL

----------------------------------------
"Inash neteia haeg joa kavari quilm..." SD4

Share this post


Link to post
Share on other sites
I don''t know if this is a problem or not, but if you are using .map files from a Quake engine editor those vertices that you are using will never form the geometry that is shown in the editor. The vertices in that file are used to generate plane equations and then those planes are clipped against eachother to form the correct geometry. Again, I''m not sure if you are using a Quake editor, but its just a thought.

Nate Miller
http://nate.scuzzy.net

Share this post


Link to post
Share on other sites