Can VBOs be used at the same time as Vertex Arrays?

Hi All,

Well my problem is simple but i can not figure out some workaround, or the reason of the problem.
I have a scene in which i have a parchment unscrolling itself. Therefore i have kept its data in vertex arrays to be able to modify it dynamically to produce the unscrolling effect.
Once unscrolled i am draying fixed objects on it (trees cows etc…) which are completely fixed and therefore i am keeping them in VBOs.
Now the problem is, when i draw my VBO, my vertex array do not redraw anymore. Below you can find the bits of code used to draw the map and its objects:

 
public void Draw(GL gl)
	{
	gl.glVertexPointer(3, GL.GL_FLOAT, 0, verticesB); 
	gl.glTexCoordPointer(2, GL.GL_FLOAT, 0, texCoords); 
	gl.glNormalPointer(GL.GL_FLOAT, 0, normalsB);
	gl.glBindTexture(GL.GL_TEXTURE_2D,textures[empire]);
	gl.glPushMatrix();
	gl.glTranslatef(0.75f,0.5f+pos,0);
	gl.glRotatef(angle,0,0,1);
	gl.glTranslatef(-0.75f,-0.5f,0);
	gl.glDrawArrays(GL.GL_QUADS, 0, 592);
	gl.glFrontFace(GL.GL_CW);
	gl.glBindTexture(GL.GL_TEXTURE_2D,textures[3]);
	gl.glDrawArrays(GL.GL_QUADS, 0, 592);
	gl.glFrontFace(GL.GL_CCW);
	gl.glDisable(GL.GL_TEXTURE_2D);
	for(int i=0;i<size[empire];i++)
		{
		gl.glPushMatrix();
		gl.glTranslatef(fiefs[empire][i][0],fiefs[empire][i][1],0);
		if(ressources[empire][i].equals("bois"))
			{
			gl.glScalef(0.08f,0.08f,0.08f);
			gl.glRotatef(90,1,0,0);
			Objets.arbre(gl);
			}
		if(ressources[empire][i].equals("betail"))
			{
			gl.glScalef(0.06f,0.06f,0.06f);
			gl.glRotatef(90,1,0,0);
			Objets.betail(gl);
			}
		if(ressources[empire][i].equals("cereales"))
			{
			gl.glScalef(0.03f,0.03f,0.02f);
			gl.glRotatef(90,1,0,0);
			Objets.cereales(gl);
			}
		if(ressources[empire][i].equals("roche"))
			{
			gl.glScalef(0.04f,0.04f,0.04f);
			gl.glRotatef(90,1,0,0);
			Objets.roche(gl);
			}
		gl.glPopMatrix();
		}
	gl.glEnable(GL.GL_TEXTURE_2D);

In turn each Objets.* will call a drawing method looking like this one.

	if(VBOs!=null)
		{
		gl.glBindBufferARB(GL.GL_ARRAY_BUFFER_ARB, VBOs[0]);
		gl.glVertexPointer(3, GL.GL_FLOAT, 0, null);
		gl.glBindBufferARB(GL.GL_ARRAY_BUFFER_ARB, VBOs[1]);
		gl.glTexCoordPointer(2, GL.GL_FLOAT, 0, null);	
		gl.glBindBufferARB(GL.GL_ARRAY_BUFFER_ARB, VBOs[2]);
		gl.glNormalPointer(GL.GL_FLOAT, 0, null);	
		}
	else
		{
		gl.glVertexPointer(3, GL.GL_FLOAT, 0, vertices); 
		gl.glTexCoordPointer(2, GL.GL_FLOAT, 0, texCoords); coordonees de texture
		gl.glNormalPointer(GL.GL_FLOAT, 0, normals); 
		}
          ...   Draw stuff ....

So each times i am turning my pointers to the vertex arrays before drawing the vertex array and to the VBOs before drawing VBOs, so i am not clear to why my the content of my vertex arrays is not drawn anymore. Is there a need for me to “unbind the buffer” before drawing a vertex array structure? If so how?

Thanks for your help

LWJGL has some nice checks for this, but JOGL appearantly don’t force you to release your VBOs before doing VA calls.

To unset the VBO:
gl.glBindBufferARB(GL.GL_ARRAY_BUFFER_ARB, 0);
note the zero as last argument.

You might have to reset the GL_ELEMENT_BUFFER_ARB too, incase you’re rendering indexed geometry

The JSR Jogl version generates exceptions if you use VBO and VA calls incorrectly. From your code however it seems like you’re still using a pre JSR version of jogl, that did not have these checks in place yet.
In the JSR version gl*Pointer style methods are overloaded. One version takes a Buffer, the other a long. The Buffer version should be used for VAs, the long version for VBOs.

Yes i am still using the pre JSR one, but i am going to shift to it as soon as next version is out. Mainly because i fancy the FPSanimator :-p

gl.glBindBufferARB(GL.GL_ARRAY_BUFFER_ARB, 0);

It solved it right away, i guessed there was surely a simple way now i know which one :stuck_out_tongue:

Thanks