简体   繁体   English

在jogl中渲染大型VBO对象

[英]Rendering large VBO objects in jogl

I am trying to render large VBO array objects, containing ~700000 values and I have ~1500000 values in my element_array buffer. 我正在尝试渲染大型VBO数组对象,其中包含〜700000个值,并且我的element_array缓冲区中有〜1500000个值。 But what I am getting is a blank screen. 但是我得到的是空白屏幕。 On the other hand if I just use only the VAO, my code works correctly. 另一方面,如果我仅使用VAO,则我的代码可以正常工作。 My code is as follows: 我的代码如下:

    //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? 关于如何解决此问题的任何线索/建议?

Is this code block called each time when the loop runs? 每次循环运行时都会调用此代码块吗? If it is, you should divide your vbo phases into different blocks. 如果是这样,则应将vbo阶段划分为不同的块。 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. (在我发布的链接中,您应该只关注initVBO和renderVbo函数)我猜您是按顺序初始化vbo的,这可能会使您的程序无响应。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM