Getting error with GL20.glVertexAttribPointer()

Started by elias4444, July 21, 2009, 18:42:59

Previous topic - Next topic

elias4444

I'm trying to implement Bump Mapping (a.k.a. normal mapping) in my engine. In order to do so, I have to pass the tangent vector to the shader along with the VBO draw routine. I'm using this command:

GL20.glVertexAttribPointer(Globals.tangentUniform, verticeFrames.get(0).length, true, 3, tangentsArray);

right before the GL11.glDrawArrays() command;
tangentUniform is the attribute location from the shader, and tangentsArray is a FloatBuffer.

But I get this error:
org.lwjgl.opengl.OpenGLException: Cannot use Buffers when Array Buffer Object is enabled
	at org.lwjgl.opengl.GLChecks.ensureArrayVBOdisabled(GLChecks.java:90)
	at org.lwjgl.opengl.GL20.glVertexAttribPointer(GL20.java:697)
	at com.tommyengine.meshes.MeshAnimation.bindTangents(MeshAnimation.java:505)
	at com.tommyengine.meshes.MeshAnimation.opengldraw(MeshAnimation.java:541)


Any ideas? My VBOs draw just fine if I don't call glVertexAttribPointer(), but then of course, I don't get my bump mapping working right either.  :P
=-=-=-=-=-======-=-=-=-=-=-
http://www.tommytwisters.com

Kai

Hi,

you cannot specify the source of vertex data with a direct FloatBuffer when on the other hand you source some data out of Buffer Objects.
You either need to disable VBOs and source each and every vertex data from direct FloatBuffers or use only VBOs (source data from Buffer Objects).

elias4444

Right, I tried this too:
ARBVertexBufferObject.glBindBufferARB( ARBVertexBufferObject.GL_ARRAY_BUFFER_ARB, tangentsVBOID );
ARBVertexShader.glVertexAttribPointerARB(Globals.tangentUniform, 3, false, 0, (FloatBuffer)null);


But I get the same error.  ???
=-=-=-=-=-======-=-=-=-=-=-
http://www.tommytwisters.com

Kai

Yes, that's basically the same method that you called before.

This is the way to go:
void org.lwjgl.opengl.ARBVertexProgram.glVertexAttribPointerARB(int index, int size, int type, boolean normalized, int stride, long buffer_buffer_offset)

elias4444

Ah found it!

I was using the wrong function call. I needed to use:

ARBVertexShader.glVertexAttribPointerARB(Globals.tangentUniform, 3, GL11.GL_FLOAT, false, 0, 0);

instead. Go figure.  :P

Thanks for the help!

Edit: LOL... tied for the posting!  ;D
=-=-=-=-=-======-=-=-=-=-=-
http://www.tommytwisters.com