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