我有一個立方體在OpenGL ES的頂點數組
float vertex_coordinates [] = {
-12.43796, -12.43796, 12.43796, -12.43796, 12.43796, 12.43796, 12.43796, 12.43796, 12.43796,
12.43796, 12.43796, 12.43796, 12.43796, -12.43796, 12.43796, -12.43796, -12.43796, 12.43796,
12.43796, -12.43796, -12.43796, 12.43796, 12.43796, -12.43796, -12.43796, 12.43796, -12.43796,
-12.43796, 12.43796, -12.43796, -12.43796, -12.43796, -12.43796, 12.43796, -12.43796, -12.43796,
-12.43796, -12.43796, -12.43796, -12.43796, 12.43796, -12.43796, -12.43796, 12.43796, 12.43796,
-12.43796, 12.43796, 12.43796, -12.43796, -12.43796, 12.43796, -12.43796, -12.43796, -12.43796,
12.43796, -12.43796, 12.43796, 12.43796, 12.43796, 12.43796, 12.43796, 12.43796, -12.43796,
12.43796, 12.43796, -12.43796, 12.43796, -12.43796, -12.43796, 12.43796, -12.43796, 12.43796,
-12.43796, 12.43796, 12.43796, -12.43796, 12.43796, -12.43796, 12.43796, 12.43796, -12.43796,
12.43796, 12.43796, -12.43796, 12.43796, 12.43796, 12.43796, -12.43796, 12.43796, 12.43796,
-12.43796, -12.43796, -12.43796, -12.43796, -12.43796, 12.43796, 12.43796, -12.43796, 12.43796,
12.43796, -12.43796, 12.43796, 12.43796, -12.43796, -12.43796, -12.43796, -12.43796, -12.43796,
};
的這個頂點數組目前使用GL_SHORT代替GL_FLOAT我使其使用
glVertexPointer(3, GL_FLOAT, 0, vertex__coordinates);
// texture pointer ...
// colour pointer
glDrawArrays(GL_TRIANGLES, 0, size);
我怎麼會去轉換頂點數組轉換成的值可以精確地呈現相同的 立方體,但是使用GL_SHORT
作爲glVertexPointer的第二個參數,以便加速 我的代碼?
謝謝!然而,如果我有多個不同尺寸(例如+ -6)的多個 立方體,我將如何應用此邏輯? – Dimitris 2009-11-19 12:44:38
在iPhone上,減少頂點陣列的尺寸可顯着提升性能。從花車轉換到短褲本身提升了我的渲染性能30%。 Dimitris,爲了將其應用於各種情況,您只需將浮點值標準化爲+ -32767即可。找到任何頂點座標的最大絕對值,並將所有頂點值乘以32767除以該值。然後,您可以調整模型視圖或投影矩陣以匹配新的縮放大小。 – 2009-11-19 17:05:26
布拉德的建議可行,但前提是你的模型大致集中在(0,0,0)左右。如果不是,你需要定期的規模和偏見。 – Alan 2009-11-19 19:45:52