im trying to get my terrain engine to support vertex arrays now, and im having a lot of trouble...
i read the red book, i think chapter 2, and im implementing from the knowledge they teach in that chapter
here's my generic crappy function, i dont know if its correct, as currently i have an array problem that prevents me from compiling...
//the make your cool array function
void MakeTerrainVertexArray(BYTE *pHeightMap,float *vertsave,float *texcoordsave)
{
glEnableClientState(GL_VERTEX_ARRAY);
int vertsize=3*((MAP_SIZE*MAP_SIZE)/STEP_SIZE);
int texcoordsize=2*((MAP_SIZE*MAP_SIZE)/STEP_SIZE);
int vcount=0;
int tcount=0;
float *verts=new float[vertsize];
float *texcoords= new float[texcoordsize];
for(int iz=0;iz < MAP_SIZE-STEP_SIZE;iz+=STEP_SIZE)
{
for(int ix=0;ix < MAP_SIZE-1;ix+=STEP_SIZE)
{
texcoords[tcount]=ix/((float)MAP_SIZE-(float)STEP_SIZE);
texcoords[tcount+1]=1-(iz/((float)MAP_SIZE-(float)STEP_SIZE));
tcount+=2;
verts[vcount]=ix;
verts[vcount+1]=Height(pHeightMap,ix,iz)*HEIGHT_RATIO;
verts[vcount+2]=iz;
vcount+=3;
texcoords[tcount]=ix/((float)MAP_SIZE-(float)STEP_SIZE);
texcoords[tcount+1]=1-(iz/((float)MAP_SIZE-(float)STEP_SIZE));
tcount+=2;
verts[vcount]=ix;
verts[vcount+1]=Height(pHeightMap,ix,iz+STEP_SIZE)*HEIGHT_RATIO;
verts[vcount+2]=iz+STEP_SIZE;
vcount+=3;
}
}
glVertexPointer(3,GL_FLOAT,0,verts);
vertsave=verts;
texcoordsave=texcoords;
}
and i dont have a drawing function yet, cuz im not clear on how to actually draw the array...
also, im not storing the tex coords, because im not sure on how to use tex coords in mult-texturing with texturecoord arrays...
i use this to set my texture coordinates in my regular drawing routine...
void SetTextureCoord(float x, float z)
{
float u = x / ((float)MAP_SIZE-(float)STEP_SIZE);
float v = z / ((float)MAP_SIZE-(float)STEP_SIZE);
glMultiTexCoord2fARB(GL_TEXTURE0_ARB, u,1- v);
glMultiTexCoord2fARB(GL_TEXTURE1_ARB, u,1- v);
}
the way the book describes these vertex array functions to me, tells me that its gonna use glTexCoord2f() when i use one of the glArrayElement/glDrawElements functions... which isnt what i want since im using multitexturing...
if someone could help me, id greatly appreciate it, this stuff is confusing
[edited by - fireking on November 9, 2003 4:39:12 AM]
--FirekingOwner/LeaderFiregames Development &Blackdragon Studios