我试图实现三角形细分算法,我遇到了如果我更新具有更大阵列几何形状的缓冲区消失了。如您所见,我使用glBufferData()
更新缓冲区。如果我更新具有相同大小(或更小)数组的缓冲区,它就可以工作。它应该有效,但事实并非如此。
glGetString(GL_VERSION) -> 3.1.0 - Build 9.17.10.3517
glGetString(GL_VENDOR) -> Intel
glEnableClientState(GL_VERTEX_ARRAY) -> DONE
glEnableClientState(GL_INDEX_ARRAY) -> DONE
glEnable(GL_NORMALIZE) -> DONE
glEnable(GL_DEPTH_TEST) -> DONE
glDisable(GL_CULL_FACE) -> DONE
glCullFace(Off) -> DONE
glDepthFunc(LessOrEqual) -> DONE
glBindBuffer(VertexArray, -1) -> DONE
glBindBuffer(ElementArray, -1) -> DONE
glBindTexture(Texture2D, -1) -> DONE
glActiveTexture(0) -> DONE
glClientActiveTexture(0) -> DONE
glViewport(0, 0, 800, 600) -> DONE
// Initializing
glGenBuffers() -> 1
glBindBuffer(VertexArray, 1) -> DONE
glBufferData(VertexArray, java.nio.DirectFloatBufferU[pos=0 lim=9 cap=9], Static) -> DONE
glGenBuffers() -> 2
glBindBuffer(VertexArray, 2) -> DONE
glBufferData(VertexArray, java.nio.DirectFloatBufferU[pos=0 lim=6 cap=6], Static) -> DONE
glGenBuffers() -> 3
glBindBuffer(VertexArray, 3) -> DONE
glBufferData(VertexArray, java.nio.DirectFloatBufferU[pos=0 lim=9 cap=9], Static) -> DONE
glGenBuffers() -> 4
glBindBuffer(ElementArray, 4) -> DONE
glBufferData(ElementArray, java.nio.DirectIntBufferU[pos=0 lim=3 cap=3], Static) -> DONE
glClear(ColorAndDepth) -> DONE
glLoadIdentity() -> DONE
glMatrixMode(Projection) -> DONE
glLoadIdentity() -> DONE
gluPerspective(60.0, 1.3333334, 0.001, 999999.0) -> DONE
glMatrixMode(ModelView) -> DONE
glBindBuffer(VertexArray, -1) -> DONE
glBindBuffer(ElementArray, -1) -> DONE
glPushMatrix() -> DONE
glTranslatef(0.0, 0.0, 0.0) -> DONE
glScalef(1.0, 1.0, 1.0) -> DONE
glMultMatrix(java.nio.DirectFloatBufferU[pos=0 lim=16 cap=16]) -> DONE
glPolygonMode(FrontAndBack, Line) -> DONE
glColor3f(1.0, 0.0, 0.0) -> DONE
glBindBuffer(VertexArray, 1) -> DONE
glVertexPointer(3, Float, 0, 0) -> DONE
glBindBuffer(VertexArray, 3) -> DONE
glNormalPointer(Float, 0, 0) -> DONE
glBindBuffer(ElementArray, 4) -> DONE
glDrawElements(Triangles, 3, UnsignedInt, 0) -> DONE
glPopMatrix() -> DONE
// Cycle end
// Updating
glBindBuffer(VertexArray, 1) -> DONE
glBufferData(VertexArray, java.nio.DirectFloatBufferU[pos=0 lim=18 cap=18], Static) -> DONE
glBindBuffer(VertexArray, 2) -> DONE
glBufferData(VertexArray, java.nio.DirectFloatBufferU[pos=0 lim=12 cap=12], Static) -> DONE
glBindBuffer(VertexArray, 3) -> DONE
glBufferData(VertexArray, java.nio.DirectFloatBufferU[pos=0 lim=18 cap=18], Static) -> DONE
glBufferData(ElementArray, java.nio.DirectIntBufferU[pos=0 lim=6 cap=6], Static) -> DONE
glClear(ColorAndDepth) -> DONE
glLoadIdentity() -> DONE
glMatrixMode(Projection) -> DONE
glLoadIdentity() -> DONE
gluPerspective(60.0, 1.3333334, 0.001, 999999.0) -> DONE
glMatrixMode(ModelView) -> DONE
glPolygonMode(FrontAndBack, Fill) -> DONE
glBindBuffer(VertexArray, -1) -> DONE
glBindBuffer(ElementArray, -1) -> DONE
glPushMatrix() -> DONE
glTranslatef(0.0, 0.0, 0.0) -> DONE
glScalef(1.0, 1.0, 1.0) -> DONE
glMultMatrix(java.nio.DirectFloatBufferU[pos=0 lim=16 cap=16]) -> DONE
glPolygonMode(FrontAndBack, Line) -> DONE
glColor3f(1.0, 0.0, 0.0) -> DONE
glBindBuffer(VertexArray, 1) -> DONE
glVertexPointer(3, Float, 0, 0) -> DONE
glBindBuffer(VertexArray, 3) -> DONE
glNormalPointer(Float, 0, 0) -> DONE
glBindBuffer(ElementArray, 4) -> DONE
glDrawElements(Triangles, 6, UnsignedInt, 0) -> DONE
glPopMatrix() -> DONE
0 - 这是我想要的结果。它在使用新缓冲区设置时有效 1 - 这是一个源三角形。
答案 0 :(得分:0)
好!我终于找到了问题的根源。细分过程后,所有指数都变为0.谢谢!并且不要忘记检查您发送的实际数据!