What's wrong here?:(

Unfortunately I have to post this topic at Advanced board, there was no solution at the beginner board for a week

I’ve written this code, but it dosn’t work:
In render function I call glCallList(rhino);

Here is the list creating routine + OBJ load routine:

float va, na, ta;
unsigned int i3, i4;
sizes temp;
temp = GetPointerSizes(“1.obj”);
va = new float[temp.vert
3+3];
na = new float[temp.vert
3+3];
ta = new float[temp.vert
2+2];
i3 = new unsigned int[temp.i3
3];
i4 = new unsigned int[temp.i4
4];
Loader(“1.obj”, va, na, ta, i3, i4);
glEnableClientState( GL_VERTEX_ARRAY );
glVertexPointer(3, GL_FLOAT, 0, va);
rhino = glGenLists (1);
glNewList(rhino, GL_COMPILE);
glColor4f(1,0,0,1);
(temp.i3==0)?NULL:glDrawElements(GL_TRIANGLES, temp.i3, GL_UNSIGNED_INT, i3);
(temp.i4==0)?NULL:glDrawElements(GL_QUADS, temp.i4, GL_UNSIGNED_INT, i4);
glEndList();
glDisableClientState (GL_VERTEX_ARRAY);

header file => ObjLoader.h <=

#include <windows.h>
#include <GL/gl.h>
struct sizes{
int vert;
int i3;
int i4;};
sizes GetPointerSizes(const char *file);
void Loader(const char *file, float *va, float *na, float *ta, unsigned int *i3, unsigned int *i4);

and source file => ObjLoader.cpp <=

#include <fstream.h>
#include <string.h>
#include “ObjLoader.h”
struct sizes GetPointerSizes(const char *file)
{ sizes temp;
temp.i3=0;
temp.i4=0;
temp.vert=0;
fstream obj;
obj.open(file,ios::in);
if (!obj.is_open())
MessageBox(NULL,“Error opening file!”,“Load error!”,MB_ICONSTOP);
while (!obj.eof())
{ char c[100]=“”;
obj.getline(c,99,’
‘);
if ((c[0]==‘v’) && (c[1]==’ ‘))
temp.vert++;
if ((c[0]==‘f’) && (c[1]==’ ‘))
{
int i=0, sp=0;
while (c[i]!=0)
{
if (c[i]==32)
sp++;
i++;
}
(sp>3)?temp.i4++:temp.i3++;
}
}
obj.close();
return temp;
}
void Loader(const char *file, float *va, float *na, float *ta, unsigned int *i3, unsigned int *i4)
{
fstream obj;
obj.open(“1.obj”,ios::in);
if (!obj.is_open())
MessageBox(NULL,“Error opening file!”,“Load error!”,MB_ICONSTOP);
while (!obj.eof())
{
int i=0;
char c[89]=“”;
obj.getline(c,88,’
‘);
if ((c[0]==‘v’) && (c[1]==’ ‘))
for (i=0;i<abs(strlen(c));i++)
{
if (c[i]==’ ‘)
{
int k=i+1;
char temp[26]=“”;
int j=0;
while ((c[k]!=’ ‘)&&(c[k]!=0))
{
temp[j]=c[k];
j++;
k++;
}
*va++=float(atof(temp));
}
}
if ((c[0]==‘v’) && (c[1]==‘t’))
for (i=0;i<abs(strlen(c));i++)
{
if (c[i]==’ ‘)
{
int k=i+1;
char temp[12]=“”;
int j=0;
while ((c[k]!=’ ‘)&&(c[k]!=0))
{
temp[j]=c[k];
j++;
k++;
}
*ta++=float(atof(temp));
}
}
if ((c[0]==‘v’) && (c[1]==‘n’))
for (i=0;i<abs(strlen(c));i++)
{
if (c[i]==’ ‘)
{
int k=i+1;
char temp[26]=“”;
int j=0;
while ((c[k]!=’ ‘)&&(c[k]!=0))
{
temp[j]=c[k];
j++;
k++;
}
*na++=float(atof(temp));
}
}
if ((c[0]==‘f’) && (c[1]==’ ‘))
{
int i=0, sp=0;
while (c[i]!=0)
{
if (c[i]==’ ‘)
sp++;
i++;
}
if (sp>3)
{
for (i=0;i<abs(strlen(c));i++)
{
if (c[i]==’ ‘)
{
int k=i+1;
char temp[5]=“”;
int j=0;
while ((c[k]!=’/‘)&&(c[k]!=0))
{
temp[j]=c[k];
j++;
k++;
}
*i4++=int(atoi(temp))-1;
}
}
}
else
{
for (i=0;i<abs(strlen(c));i++)
{
if (c[i]==’ ‘)
{
int k=i+1;
char temp[5]=“”;
int j=0;
while ((c[k]!=’/')&&(c[k]!=0))
{
temp[j]=c[k];
j++;
k++;
}
*i3++=int(atoi(temp))-1;
}
}
}
}
}
obj.close();
}

It seems that arrays are ok, idices also, but list is empty, it draws nothing

Madman

[This message has been edited by M/\dm/
(edited 11-30-2002).]

dont you to enable/disable the vertex array inside the list, and not outside? it seems to me you are drawing the mesh with vertexarray disabled.

That shouldn’t be a problem. When you build a display list from a vertex array, the vertex array data will be dereferenced at compile time and moved to the display list instead. As long as the vertex array is enabled at the point where it’s compiled it should be OK.

By the way, this kind of operation is typically something you put in the startup phase of your program, but make sure you’re not calling it too early, i.e. make sure you have a rendering context.

Thanks for advice, but unfortunately that didn’t helped. Other Lists in my program, that are being created before this and also include vertex arrays works with no problems. So there’s somthing wrong with OBJ importer I checked out va,na… in MSVC debuger and they have real data, that from the file.

Everything looks fine, and if you say you’ve got the correct results in memory in the vertex and index arrays, it’s probably not the OBJ importer.

Maybe it’s a stupid mistake somewhere else ? You say nothing is drawn, but are your transformation matrix correct ? Maybe you’re just not looking at the object ?

Y.

What’s the size of the object? What’s your viewing frustum in object space? (near/far may clip it out, too)

Have you tried to create and render only THIS display list ?
Are you sure you have enought video memory to create all your display lists ?

I don’t see what video memory has anything to do with that matter. For all we know, display lists can be stored in AGP or in system memory. In addition, you have no way to check for video memory usage.

Y.

I want to import static cube -1,-1,-1 1,1,1 in my game so far, so i can walk to that point It seems that I’ll have to look for other examples and check them out.

Did you just say unit cube?
Ummm … do you have backface culling enabled?

Try
glDisable(GL_CULL_FACE);