加载没有顶点缓冲区对象的法线无法使用OpenGL ES

问题描述

当我使用顶点缓冲对象(VBO)将普通数据加载到顶点着色器中时,一切正常:

GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER,VBO[2]);
GLES20.glVertexAttribPointer(normalLink,3,GLES20.GL_FLOAT,false,3 * 4,0);
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER,0);

但是当我尝试在没有VBO的情况下加载法线时:

GLES20.glVertexAttribPointer(normalLink,buffernormals);

然后,将完全停止显示3D对象。我尝试了另一个大步,但没有帮助。

同时,将没有VBO的顶点和纹理坐标加载到着色器孔中:

GLES30.glVertexAttribPointer(positionLink,GLES30.GL_FLOAT,bufferVertices);
...
GLES20.glVertexAttribPointer(textureCoordinatesLink,2,bufferTextureCoordinates);

GLES20.glEnabLevertexAttribArray(positionLink); 
GLES20.glEnabLevertexAttribArray(textureCoordinatesLink);
GLES20.glEnabLevertexAttribArray(normalLink);

问题:任何人都可以提出问题所在吗?感谢您的任何回答/评论

注意:要创建bufferVertices,bufferTextureCoordinates和buffernormals变量,我使用了以下方法

public static FloatBuffer floatBuffer(float[] data) {
    ByteBuffer byteBuffer = ByteBuffer.allocateDirect(data.length * 4)
                        .order(ByteOrder.nativeOrder());
    FloatBuffer returnBuffer = byteBuffer.asFloatBuffer();
    returnBuffer.put(data).position(0);
    return returnBuffer;
}

float[] normals = modelData.getnormals();
FloatBuffer buffernormals = floatBuffer(normals);

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)