# Thread: Vertexarrays problem

1. ## Vertexarrays problem

I've an object(loaded from md2)everything is loaded fine(i think :-)).When i show it classically(glBegin(GL_TRIANGLES) .... normals textures vertices glEnd()) it is shown correctly but i want to use vertex arrays(and VBO's later)i've loaded everything into arrays but there's the problem it chrashes by calling glDrawArrays,glArrayElement(even with first field!) and aslo by calling glDrawElements.What could be the problem?
Code :
```	float *tevectorarray,*tenormalarray,*tetexcoordarray;
FILE *file;
tevectorarray=new float[numTriangles*9];
tenormalarray=new float[numTriangles*9];
tetexcoordarray=new float[numTriangles*6];
for(i=0;i<numTriangles;i++)
{																					//for testing only
tetexcoordarray[6*i]=TexCoordArray[3*i].x;
tetexcoordarray[6*i+1]=TexCoordArray[3*i].y;
tetexcoordarray[6*i+2]=TexCoordArray[3*i+1].x;
tetexcoordarray[6*i+3]=TexCoordArray[3*i+1].y;
tetexcoordarray[6*i+4]=TexCoordArray[3*i+2].x;
tetexcoordarray[6*i+5]=TexCoordArray[3*i+2].y;
}
file=fopen("vertex.log","w");
for(i=0;i<numTriangles*3;i++)
{
fprintf(file,"%d %f %f %f \n",i,tevectorarray[3*i],tevectorarray[3*i+1],tevectorarray[3*i+2]);
}
fclose(file);
file=fopen("normals.log","w");
for(i=0;i<numTriangles*3;i++)
{
fprintf(file,"%d %f %f %f \n",i,tenormalarray[3*i],tenormalarray[3*i+1],tenormalarray[3*i+2]);
}
fclose(file);
file=fopen("texture.log","w");
for(i=0;i<numTriangles*3;i++)
{
fprintf(file,"%d %f %f \n",i,tetexcoordarray[2*i],tetexcoordarray[2*i+1]);
}
fclose(file);
glEnableClientState(GL_NORMAL_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glEnableClientState(GL_VERTEX_ARRAY);
glEnable(GL_COLOR_MATERIAL);
glFrontFace(GL_CW);
glColor3f(1.0f,1.0f,1.0f);
if(oglv.ActiveTexture!=0xFFFF)
{
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D,oglv.texture_id[oglv.ActiveTexture]);
}
if(oglv.Vertex_VBO_id==0)
{
glTexCoordPointer(2,GL_FLOAT,0,&amp;tetexcoordarray);
{
glVertexPointer(3,GL_FLOAT,0,deltaFrame.VertexArray);
glNormalPointer(GL_FLOAT,0,deltaFrame.NormalArray);
}
else
{
glVertexPointer(3,GL_FLOAT,0,tevectorarray); //changed for testing
glNormalPointer(GL_FLOAT,0,tenormalarray);
}
glDrawArrays(GL_TRIANGLES,0,numTriangles);```

2. ## Re: Vertexarrays problem

Originally posted by Vlasko:
Code :
```float *tevectorarray,*tenormalarray,*tetexcoordarray;
...
glTexCoordPointer(2,GL_FLOAT,0,&amp;tetexcoordarray);```
You're passing the address of the pointer when you should pass the value of it.

3. ## Re: Vertexarrays problem

changed that but it doesn't solve the problem

4. ## Re: Vertexarrays problem

Are you by any chance using a 3DLabs realizm board?

5. ## Re: Vertexarrays problem

no I'm not :-) I've updated drivers it helped a bit.I've used glGetPointerv to see if my arrays are bound and it seems that they are not.
Code :
```GLfloat *p;
glTexCoordPointer(2,GL_FLOAT,0,tetexcoordarray);
glVertexPointer(3,GL_FLOAT,0,tevectorarray);
glNormalPointer(GL_FLOAT,0,tenormalarray);
glGetPointerv(GL_NORMAL_ARRAY,(GLvoid **)&amp;p);
glGetPointerv(GL_VERTEX_ARRAY,(GLvoid **)&amp;p);
glGetPointerv(GL_TEXTURE_COORD_ARRAY,(GLvoid **)&amp;p)```
with the debugger I've checked that p doesn't change!

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•