0

So far I tried to render mesh using vertex buffer and index buffer.

Using packed buffer with data order : PosX,PosY,PosZ,NormX,NormY,NormZ,TexX,TexY

but when it comes to render low poly model like triangle or plane doesn't render and cube renders weirdly (triangles are deformed and drawn from various points :D).

Where I think is problem is that GLES is moving with bad STRIDE. I double checked the data order coming into vbo and ibo.

STRIDE = 8;
POSITION_DATA_SIZE = 3;
BYTES_PER_FLOAT = 4;
BYTES_PER_SHORT = 2;
elementsCount = 6; // When drawing plane
if (vbos[0] > 0 && ibos[0] > 0) {

        GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, vbos[0]);


        vbo.position(0);
        ibo.position(0);

        // Bind Attributes
        GLES20.glVertexAttribPointer(getParamHandle("a_Position"),     

        // Position data and offset in one stride
        BufferData.POSITION_DATA_SIZE, GLES20.GL_FLOAT, false,
                BufferData.STRIDE, 0);


        GLES20.glEnableVertexAttribArray(getParamHandle("a_Position"));

        // Draw
        GLES20.glBindBuffer(GLES20.GL_ELEMENT_ARRAY_BUFFER, ibos[0]);

        GLES20.glDrawElements(GLES20.GL_TRIANGLE_STRIP, elementsCount, 
        GLES20.GL_UNSIGNED_SHORT, 0);

        GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, 0);
        GLES20.glBindBuffer(GLES20.GL_ELEMENT_ARRAY_BUFFER, 0);
    }
Cœur
  • 37,241
  • 25
  • 195
  • 267
user2977027
  • 105
  • 1
  • 10

0 Answers0