not drawing the data I have

Hi and thankyou if you can help.

Firstly:- I have found away to load half-life maps with help from flipcode but anyway I load the file which has a list of vertices and polygons that have these vertices. so a cube can be stored with just its 8 corners and a list of polygons pointing to the corners. I can load the data correctly into a structure(similar to nehe’s simple world tutorial). In the drawing function I have checked all the data and seen that it is all correct however it doesn’t draw anything. I have put a test triangle in that doesn’t use any loaded data and this works fine. The code looks ok to me -

// test triangle that works
glBindTexture(GL_TEXTURE_2D, texture[0]);
glTexCoord2f(0,0); glVertex3f(0,0,0);
glTexCoord2f(1,0); glVertex3f(1,0,0);
glTexCoord2f(1,1); glVertex3f(1,1,0);

numtriangles = sector[0].numtriangles;
int vert[4];
// Process Each Triangle
for (int loop_m = 0; loop_m < 6; loop_m++)
glBindTexture(GL_TEXTURE_2D, texture[0]);
vert[0] = sector[0].triangle [loop_m].vertex[0];
vert[1] = sector[0].triangle[loop_m].vertex[1];
vert[2] = sector[0].triangle[loop_m].vertex[2];
vert[3] = sector[0].triangle[loop_m].vertex[3];

x_m = sector[0].point[vert[0]].x;
y_m = sector[0].point[vert[0]].y;
z_m = sector[0].point[vert[0]].z;

glTexCoord2f(0,0); glVertex3f(x_m,y_m,z_m);

x_m = sector[0].point[vert[1]].x;
y_m = sector[0].point[vert[1]].y;
z_m = sector[0].point[vert[1]].z;

glTexCoord2f(1,0); glVertex3f(x_m,y_m,z_m);

x_m = sector[0].point[vert[2]].x;
y_m = sector[0].point[vert[2]].y;
z_m = sector[0].point[vert[2]].z;

glTexCoord2f(1,1); glVertex3f(x_m,y_m,z_m);

   x_m = sector[0].point[vert[3]].x;
   y_m = sector[0].point[vert[3]].y;
   z_m = sector[0].point[vert[3]].z;

glTexCoord2f(0,1); glVertex3f(x_m,y_m,z_m);

I know is sector[0].triangle[] etc. but that doesn’t matter, it does hold the 4 points for a quad.(all the data is in quads.)
As i said all the data is correct but nothing in the for loop draws while the triangle at the top does, there is no error message or anything out of the ordinary. Can someone please help.

I know this sounds really simple, but could it be that your model that you load from a file is not in the view frustum?

Or possibly you are inside the cube and you have GL_CULL_FACE enabled?


Originally posted by j:
[b]I know this sounds really simple, but could it be that your model that you load from a file is not in the view frustum?

Or possibly you are inside the cube and you have GL_CULL_FACE enabled?


I don’t have any culling, and you can walk about and not see anything - the dimensions are very big , about 600200300 for a small cube so I will have to shrink the data by a factor of 150 or so to get correct proportions, but anyerway surely you should see something somewhere, apart from the test triangle. Thanks for any help.

Can think of another reason: Black colored polygons on a black background (or any other color on the same colored background, but you get the idea). This, in turn, can be because of two reasons: Failed to create/upload a new texture, or black color with glColor*() and GL_MODULATE as glTexEnv*() parameter.

First reason, you should always check for errors. When using glGenTextures, make sure you get a non-zero value. Else the allocation failed. Also check for errors with glGetError(), because error can uccur when uploading textures.

Second reason, GL_MODULATE multiplies the texelcolor with the polygoncolor, and if the polygoncolor is black, the resulting color will be blackaswell.

Try to turn off texturing and set color to something other than the background. Or wait a second, did you enable GL_TEXTURE_2D at all?

[This message has been edited by Bob (edited 12-18-2000).]

I havn’t checked for errors in creating the texture but the texture I am using is the same as the test triangle which works( i have enabled GL_TEXTURE_2D).
I wasn’t using any colors, even so I made it draw everything white with glColor3f, it made no difference even if I turned off texturing. I’m not using GL_MODULATE.
Thanks for the help but the problem isn’t that simple. I’ve tried for weeks checking and adjusting the code. I will spend some more time using glGetError etc.

A couple of months ago my project didn’t load the data correctly but could draw it. Now it loads but doesn’t draw. Unfortunatly the data stored differently so I can’t combine them.