I am trying to get my rendering function to work. I use vertex arrays. Here is my vertex structure.
struct Vertex
{
float x, y, z;
float u, v;
float padding[3];
};
Here is my rendering code:
void WLD::render(GLuint* textures, long curRegion, CFrustum cfrustum)
{
int num = 0;
GLuint indicies[3];
while(num < regions[curRegion].visibility.size())
{
int i = regions[curRegion].visibility[num];
if(!regions[i].dead && regions[i].meshptr != NULL)
{
if(cfrustum.BoxInFrustum(regions[i].meshptr->min[0], regions[i].meshptr->min[2], regions[i].meshptr->min[1], regions[i].meshptr->max[0], regions[i].meshptr->max[2], regions[i].meshptr->max[1]))
{
for(int j = 0; j < regions[i].meshptr->polygonCount; j++)
{
indicies[0] = regions[i].meshptr->poly[j].vertIndex[0];
indicies[1] = regions[i].meshptr->poly[j].vertIndex[1];
indicies[2] = regions[i].meshptr->poly[j].vertIndex[2];
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3, GL_FLOAT, sizeof(Vertex), &verticies[0].x);
int tex = regions[i].meshptr->poly[j].tex;
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glTexCoordPointer(2, GL_FLOAT, sizeof(Vertex), &verticies[0].u);
glDrawElements(GL_TRIANGLES, 3, GL_UNSIGNED_INT, indicies);
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
}
}
}
num++;
}
}
One argument is that GLuint * textures contain all loaded textures. Thus, the value returns the string int tex = regions [i] .meshptr-> poly [j] .tex; is the texture index for this particular polygon. How to associate this with every polygon when I create it? Let me know if you have any questions.
, glClientActiveTexture(), , , undefined, , , , . . , , , 4, , glClientActiveTexture.