私は最近中間モードから切り替えて、新しいレンダリングプロセスを持っています。私が理解していないものがなければならない。私はそれが指数と関係があると思う。OpenGLのレンダリングメッシュポリゴン - 非常に遅い
私のダイアグラムは、Region-> Mesh-> Polygon Array->頂点のマスターリストを参照する3つの頂点インデックスです。私は何を残した場合
// Render the mesh
void WLD::render(GLuint* textures, long curRegion, CFrustum cfrustum)
{
int num = 0;
// Set up rendering states
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
// Set up my indices
GLuint indices[3];
// Cycle through the PVS
while(num < regions[curRegion].visibility.size())
{
int i = regions[curRegion].visibility[num];
// Make sure the region is not "dead"
if(!regions[i].dead && regions[i].meshptr != NULL)
{
// Check to see if the mesh is in the frustum
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]))
{
// Cycle through every polygon in the mesh and render it
for(int j = 0; j < regions[i].meshptr->polygonCount; j++)
{
// Assign the index for the polygon to the index in the huge vertex array
// This I think, is redundant
indices[0] = regions[i].meshptr->poly[j].vertIndex[0];
indices[1] = regions[i].meshptr->poly[j].vertIndex[1];
indices[2] = regions[i].meshptr->poly[j].vertIndex[2];
// Enable texturing and bind the appropriate texture
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, textures[regions[i].meshptr->poly[j].tex]);
glVertexPointer(3, GL_FLOAT, sizeof(Vertex), &vertices[0].x);
glTexCoordPointer(2, GL_FLOAT, sizeof(Vertex), &vertices[0].u);
// Draw
glDrawElements(GL_TRIANGLES, 3, GL_UNSIGNED_INT, indices);
}
}
}
num++;
}
// End of rendering - disable states
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
}
申し訳ありません:ここで
は私のコードのレンダリング。そして私は本当にフィードバックを感謝し、これを助けます。私はOpenGLと最適化に恵まれている人にこれを手伝ってもらうことさえ考えています。
私は、現在バインドされていないテクスチャを呼び出すときだけテクスチャをバインドするようにしました。これにより、FPSは約10-15増加しました。 –
1つのglDrawElements-callに同じテクスチャのすべてのポリゴンを描画できるように、メッシュデータを配置します。だから、すべてのポリゴンをループするのではなく、そのテクスチャのインデックスとテクスチャIDを格納したmeshptr-> textureCountのようなものをループします。 gl_texture_2dをループ外または初期化中に1回有効にするだけです。また、メッシュコンテンツのコントロールがある場合は、メッシュ全体(または複数のメッシュ)に単一のテクスチャを使用してみてください。 –