Hello Guest

Texture and intervaling VBO

  • 3 Replies
  • 5334 Views
Texture and intervaling VBO
« on: April 21, 2014, 14:53:53 »

*

Offline abcdef

  • ****
  • 336
Re: Texture and intervaling VBO
« Reply #1 on: April 22, 2014, 10:09:43 »
I have no idea what your error is but looking at your vertex attrib code things look to be wrong

You have

GL20.glVertexAttribPointer(0, positionFloatCount, GL11.GL_FLOAT, false,vertexFloatSizeInBytes, 0);
int byteOffset = floatByteSize * positionFloatCount;
GL20.glVertexAttribPointer(1, positionFloatCount, GL11.GL_FLOAT, false,vertexFloatSizeInBytes, byteOffset);

I don't think you understand the variables here

The first parameter is the id which you reference in your shader. You have the right values here.
The second parameter is the size of the parameter, in your case this is 3 for the vertex (x,y,x) and 2 for the texture coordinate (s,t), you have the positionFloatCount and this is wrong.
The third parameter describes the the type for the data, you have the right value here.
The forth parameter says whether you want to normalise the data (which you don't most of the time)
The fifth parameter is the offset which says where in the data to start finding this data. It looks to me that vertex data starts at 0 and the texture coordinates start at 9 because your data is tightly packed. If it wan't tightly packed you you provide the offset for where the data is per stride.
The sixth parameter is stride, if the data is tightly packed then this should be 0 (Tightly packed = V V V T T T (V=Vertex T=Tecture Coordinate), non tightly packed would be V T V T V T)

So I'd change

GL20.glVertexAttribPointer(0, positionFloatCount, GL11.GL_FLOAT, false,vertexFloatSizeInBytes, 0); to
GL20.glVertexAttribPointer(0, 3, GL11.GL_FLOAT, false,0, 0);

and

GL20.glVertexAttribPointer(1, positionFloatCount, GL11.GL_FLOAT, false,vertexFloatSizeInBytes, byteOffset); to
GL20.glVertexAttribPointer(1, 2, GL11.GL_FLOAT, false,9, 0);

Re: Texture and intervaling VBO
« Reply #2 on: April 22, 2014, 10:50:20 »
Hi !

First of all, thank you for the answer, you've help me to understand a little bit more on the VBO and it's now a little less messy. I've tried what you suggest and still nothing is happening (the display appear but nothing on it, just the infinite black screen of my despair).

Considering it's bytebuffer, should i not multiply by 4 (the size of a float in bytes) ?

Thank you again for taking the time the respond to me.

*

Offline abcdef

  • ****
  • 336
Re: Texture and intervaling VBO
« Reply #3 on: April 22, 2014, 13:31:43 »
You also don't clear the depth and color bits during the render cycle

You don't have a shader that can intepret what indexes 0 and 1 are in your vertex attrib pointer and that can take your texture and render it.

There is quite a lot wrong and probably more that my quick second look :) I'd recommend reading some opengl tutorials to learn how the flow works and what you need to fill in to get things to work.