OpenGLException: Cannot use Buffers when Array Buffer Object is enabled

Hello,



I'm using latest CVS release and having troubles running several of the tests (not all of them though). The

exception I get on the failing ones is:


2007-sep-16 23:31:41 class jmetest.flagrushtut.lesson9.Lesson9 start()
ALLVARLIG: Exception in game loop
org.lwjgl.opengl.OpenGLException: Cannot use Buffers when Array Buffer Object is enabled
   at org.lwjgl.opengl.GLChecks.ensureArrayVBOdisabled(GLChecks.java:84)
   at org.lwjgl.opengl.GL11.glVertexPointer(GL11.java:2528)
   at com.jme.renderer.lwjgl.LWJGLRenderer.predrawGeometry(LWJGLRenderer.java:1293)
   at com.jme.renderer.lwjgl.LWJGLRenderer.draw(LWJGLRenderer.java:1000)
   at com.jme.scene.batch.TriangleBatch.draw(TriangleBatch.java:255)
   at com.jme.renderer.RenderQueue.renderOpaqueBucket(RenderQueue.java:250)
   at com.jme.renderer.RenderQueue.renderBuckets(RenderQueue.java:238)
   at com.jme.renderer.Renderer.renderQueue(Renderer.java:452)
   at com.jme.renderer.pass.ShadowedRenderPass.renderScene(ShadowedRenderPass.java:420)
   at com.jme.renderer.pass.ShadowedRenderPass.doRender(ShadowedRenderPass.java:310)
   at com.jme.renderer.pass.Pass.renderPass(Pass.java:90)
   at com.jme.renderer.pass.BasicPassManager.renderPasses(BasicPassManager.java:89)
   at jmetest.flagrushtut.lesson9.Lesson9.render(Lesson9.java:204)
   at com.jme.app.BaseGame.start(BaseGame.java:82)
   at jmetest.flagrushtut.lesson9.Lesson9.main(Lesson9.java:134)
2007-sep-16 23:31:41 com.jme.app.BaseGame start
INFO: Application ending.



I searched the forum and did not find any references to the issue, anyone have ideas as to the cause?

update and try again

thanks, working now  XD


SEVERE: Exception in game loop
org.lwjgl.opengl.OpenGLException: Cannot use Buffers when Element Array Buffer Object is enabled
   at org.lwjgl.opengl.GLChecks.ensureElementVBOdisabled(GLChecks.java:96)
   at org.lwjgl.opengl.GL11.glDrawElements(GL11.java:1074)
   at com.jme.renderer.lwjgl.LWJGLRenderer.draw(Unknown Source)
   at com.jme.scene.batch.TriangleBatch.draw(Unknown Source)
   at com.jme.renderer.RenderQueue.renderOpaqueBucket(Unknown Source)
   at com.jme.renderer.RenderQueue.renderBuckets(Unknown Source)
   at com.jme.renderer.Renderer.renderQueue(Unknown Source)
   at com.jme.renderer.lwjgl.LWJGLRenderer.displayBackBuffer(Unknown Source)
   at com.jme.app.BaseGame.start(Unknown Source)
   at org.jcrpg.threed.J3DCore.initCore(J3DCore.java:1148)
   at org.jcrpg.apps.Jcrpg.start(Jcrpg.java:156)
   at org.jcrpg.apps.Jcrpg.main(Jcrpg.java:55)



This is exactly the same thing I received just today when trying to run my project jcrpg with CVS version. What was the modification that solved this problem? What is possibly wrong in my code, why I receive such an exception, what should I look for?

bump. Can someone give some hint about it?

This one is a serious blocker for me, can someone give a hint about it?

i hope renanse can answer this soon…



are you using vbo for indeces?

Basically the error comes up if you try to use one while the other is enabled.  Are you setting up VBOInfo with some true and some false (not sure how tested that is…)?  Or perhaps you are using GL outside of jME?  I can't think of any other reasons this might not be in the right state.

renanse said:

Basically the error comes up if you try to use one while the other is enabled.  Are you setting up VBOInfo with some true and some false (not sure how tested that is...)?  Or perhaps you are using GL outside of jME?  I can't think of any other reasons this might not be in the right state.


Right, I've just found that I set on some of the quads a new VBOInfo (i tried to search for VBO before posting here but I used case sensitive search  :) ). Interestingly  before 1.0 this didn't give error. Removed it and now it is working fine! Thanks!

I can confirm that using vbo for indices on some batches and not on others produces this error.



Something like this is a possible fix (I have been playing around in the renderer for fun lately, so I'm afraid I can't give you a good patch):

        // We do not need to set a limit() since this is done in draw(TriMesh)
        if ((t.getType() & SceneElement.TRIANGLEBATCH) != 0) {
           if ((supportsVBO && vbo != null && vbo.getVBOIndexID() > 0)) { // use VBO
               indicesVBO = true;
               /*ARBBufferObject.glBindBufferARB(
                        ARBVertexBufferObject.GL_ELEMENT_ARRAY_BUFFER_ARB, vbo
                               .getVBOIndexID());*/
                    rendRecord.setBoundElementVBO(vbo.getVBOIndexID());
           } else if(supportsVBO) {
                    rendRecord.setBoundElementVBO(0);
                }
        }



That is, by forcibly setting the bound VBO to 0 if it is not used for the batch. The setBoundElementVBO method already prevents unnecessary GL-calls, so this should not cause noticeable overhead.

<Edit>
I should perhaps at least mention that the code above belongs in the LWJGLRenderer class. ;)
</Edit>

Cool, nice find.  :)  Should be in cvs soon

super! i got this error with indices as well earlier…