我開始將我的遊戲從iOS移植到Android,並且遇到了問題。將Java頂點對象的數組傳遞給OpenGL入口點
在我的標準的工作流在iOS上我會存儲我的頂點信息的結構數組:
typedef struct{
float x, y, z;
} Vector3;
Vector3 verts[];
這種事情。
然後,當我將頂點數據發送給GL時,我只需指向verts數組,並將它視爲浮點數組。
glVertexAttribPointer(Vertex_POSITION, 3, GL_FLOAT, 0, 0, (void *)verts);
如何在Java中執行此操作?
我試着製作一個Vector3類,並將其中的一些放入數組中,但當我嘗試將該數組填充到GL時,會引發錯誤。
AFAIK漂浮物數組應該做得很好。 – 2014-10-03 19:03:52
[這些](http://stackoverflow.com/questions/15380491/glvertexattribpointer-in-opengl-and-in-opengles)[questions](http://stackoverflow.com/questions/9954759/using-glvertexattribpointer-and -gldrawelements-to-draw-from-a-packed-vertex-buff)顯示使用GL_FLOAT []或FloatBuffer;我不知道,我自己。 – 2014-10-03 19:19:28
所以在Java中沒有辦法做到這一點?我在iOS中這樣做的好處是,它更容易,更高效地獲取和設置值。 – Bananable 2014-10-03 20:10:08