在jogl中渲染大型VBO对象

时间:2022-07-21 03:52:36

I am trying to render large VBO array objects, containing ~700000 values and I have ~1500000 values in my element_array buffer. But what I am getting is a blank screen. On the other hand if I just use only the VAO, my code works correctly. My code is as follows:

我试图渲染大型VBO数组对象,包含~70万个值,我的element_array缓冲区中有~1500000个值。但我得到的是一个空白屏幕。另一方面,如果我只使用VAO,我的代码可以正常工作。我的代码如下:

    //Data buffers
    FloatBuffer vertexBuffer = GLBuffers.newDirectFloatBuffer(this.coordCount);
    vertexBuffer.put(Vertices);
    vertexBuffer.rewind();

    IntBuffer indexBuffer = GLBuffers.newDirectIntBuffer(this.indexCount);
    indexBuffer.put(index);
    indexBuffer.rewind();

    //setting up the VBO
    int nVBO = 2;
    int[] VBO = new int[nVBO];

    gl.glGenBuffers(nVBO, VBO,0);

    gl.glBindBuffer(GL.GL_ARRAY_BUFFER, VBO[0]);
    gl.glBindBuffer(GL.GL_ELEMENT_ARRAY_BUFFER,VBO[1]);

    gl.glBufferData(GL.GL_ARRAY_BUFFER, this.coordCount*Float.SIZE, vertexBuffer, GL.GL_STATIC_DRAW);
    gl.glBufferData(GL.GL_ELEMENT_ARRAY_BUFFER, this.indexCount*Integer.SIZE, indexBuffer, GL.GL_STATIC_DRAW);

    gl.glBindBuffer(GL.GL_ARRAY_BUFFER, VBO[0]);
    gl.glBindBuffer(GL.GL_ELEMENT_ARRAY_BUFFER, VBO[1]);

    gl.glEnableClientState(GLPointerFunc.GL_VERTEX_ARRAY);

    gl.glVertexPointer(3, GL.GL_FLOAT, 0, 0);
    //gl.glVertexPointer(3, GL.GL_FLOAT, 0, vertexBuffer);


    //gl.glDrawArrays(GL.GL_TRIANGLE_STRIP, 0, 4);
    gl.glDrawElements(GL.GL_TRIANGLES, this.indexCount, GL.GL_UNSIGNED_INT, 0);
    //gl.glDrawElements(GL.GL_TRIANGLES, this.indexCount, GL.GL_UNSIGNED_INT, indexBuffer);


    gl.glDisableClientState(GLPointerFunc.GL_VERTEX_ARRAY);
    gl.glBindBuffer(GL.GL_ARRAY_BUFFER, 0);
    gl.glBindBuffer(GL.GL_ELEMENT_ARRAY_BUFFER, 0);

Any clues/suggestions on how I can fix this?

关于我如何解决这个问题的任何线索/建议?

1 个解决方案

#1


Is this code block called each time when the loop runs? If it is, you should divide your vbo phases into different blocks.This sample code may help you how to divide. (In the link that I post, you should just focus initVBO and renderVbo functions) I guess your initializing your vbo's sequentially, which it may make your program unresponsive.

每次循环运行时是否调用此代码块?如果是,您应该将您的vbo阶段划分为不同的块。此示例代码可以帮助您划分。 (在我发布的链接中,你应该只关注initVBO和renderVbo函数)我猜你按顺序初始化你的vbo,这可能会使你的程序无响应。

#1


Is this code block called each time when the loop runs? If it is, you should divide your vbo phases into different blocks.This sample code may help you how to divide. (In the link that I post, you should just focus initVBO and renderVbo functions) I guess your initializing your vbo's sequentially, which it may make your program unresponsive.

每次循环运行时是否调用此代码块?如果是,您应该将您的vbo阶段划分为不同的块。此示例代码可以帮助您划分。 (在我发布的链接中,你应该只关注initVBO和renderVbo函数)我猜你按顺序初始化你的vbo,这可能会使你的程序无响应。