0

I have reinstalled my compiler successfully (finally) and got right back to work. I have created a glModel class as follows:

```
class glModel
{
private:
int numv;
int numn;
unsigned int model;
unsigned int textu;
unsigned int norma;
float *vars;
float *norm;
public:
glModel():numv(0),numn(0){vex=new float[1];tex=new float[1];nex=new float[1];}
glModel& Vertex(float tx, float ty, float x, float y, float z);
glModel& Compile();
glModel& Draw();
glModel& Move(float x, float y, float z){glTranslatef(x,y,z);}
};
glModel &glModel::Vertex(float tx, float ty, float x, float y, float z)
{
float *temp=new float[numv*5];
for (int i=0; i<numv*5; i++)
temp[i]=vars[i];
delete[]vars;vars=NULL;
vars=new float[numv*5+5];
for (int i=0; i<numv*5; i++)
vars[i]=temp[i];
vars[numv*5]=tx;
vars[numv*5+1]=ty;
vars[numv*5+2]=x;
vars[numv*5+3]=y;
vars[numv*5+4]=z;
delete[]temp;temp=NULL;
numv++;
if (numv%3==0)
{
temp=new float[numn*3];
for (int i=0; i<numn*3; i++)
temp[i]=norm[i];
delete[]norm;norm=NULL;
norm=new float[numn*3+3];
for (int i=0; i<numn*3; i++)
norm[i]=temp[i];
delete[]temp;temp=NULL;
float x1,x2,x3,y1,y2,y3,z1,z2,z3;
z3=vars[numn*5-1];
y3=vars[numn*5-2];
x3=vars[numn*5-3];
z2=vars[numn*5-6];
y2=vars[numn*5-7];
x2=vars[numn*5-8];
z1=vars[numn*5-11];
y1=vars[numn*5-12];
x1=vars[numn*5-13];
float dx1,dx2,dy1,dy2,dz1,dz2;
dx1=x2-x1;
dx2=x3-x1;
dy1=y2-y1;
dy2=y3-y1;
dz1=z2-z1;
dz2=z3-z1;
float ox,oy,oz;
ox=dy1*dz2-dz1*dy2;
oy=dz1*dx2-dx1*dz2;
oz=dx1*dy2-dy1*dx2;
float mag=sqrt(ox*ox+oy*oy+oz*oz);
ox/=mag;
oy/=mag;
oz/=mag;
norm[numn*3]=ox;
norm[numn*3+1]=oy;
norm[numn*3+2]=oz;
numn++;
}
return *this;
}
glModel &glModel::Compile()
{
float *temp=new float[numv*3];
for (int i=0; i<numv; i++)
{
temp[i*3]=vars[i*5+2];
temp[i*3+1]=vars[i*5+3];
temp[i*3+2]=vars[i*5+4];
}
glGenBuffers(1,&model);
glBindBuffer(GL_ARRAY_BUFFER, model);
glBufferData(GL_ARRAY_BUFFER, numv*3*sizeof(float), temp, GL_STATIC_DRAW);
delete[]temp;temp=NULL;
temp=new float[numv*2];
for (int i=0; i<numv; i++)
{
temp[i*2]=vars[i*5];
temp[i*2+1]=vars[i*5+1];
}
glGenBuffers(1,&textu);
glBindBuffer(GL_ARRAY_BUFFER, textu);
glBufferData(GL_ARRAY_BUFFER, numv*2*sizeof(float), temp, GL_STATIC_DRAW);
delete[]temp;temp=NULL;
glGenBuffers(1,&norma);
glBindBuffer(GL_ARRAY_BUFFER, norma);
glBufferData(GL_ARRAY_BUFFER, numn*3*sizeof(float), norm, GL_STATIC_DRAW);
return *this;
}
glModel& glModel::Draw()
{
glBindBuffer(GL_ARRAY_BUFFER, model);
glVertexPointer(3, GL_FLOAT, 0, NULL);
glBindBuffer(GL_ARRAY_BUFFER, textu);
glTexCoordPointer(2, GL_FLOAT, 0, NULL);
glBindBuffer(GL_ARRAY_BUFFER, norma);
glNormalPointer(GL_FLOAT, 0, NULL);
glDrawArrays(GL_TRIANGLE,0,numv);
return *this;
}
```

This class is designed to be used simply by the 3d model designers that are helping me out (I suck at making 3D model, they suck at programming), therefore it can be used simply like this:

```
glModel model;
model.Vertex(a,b,c,d,e).Vertex(a,b,c,d,e).Vertex(a,b,c,d,e).Compile().Draw();
```

The problem is that this format and the use of VBOs makes it dang near impossible to debug. I am getting a problem (Windows Error Report) and I would like to see what is wrong with my code. Thank you in advance.