我正在尝试纹理贴图一些四边形.我可以用纯色渲染四边形.我一直在关注这个页面:http: //www.learnopengles.com/android-lesson-four-introducing-basic-texturing/
一切都编译并运行,但纹理根本没有被应用.我的代码和链接页面之间的唯一区别是我不做glBindAttribLocation,而是使用glDrawElements而不是glDrawArrays.
编辑:转换我的顶点和tex coord数据使用glDrawArrays没有修复任何东西.
我的所有着色器手柄似乎都是正确的.问题必须出在我的一个平局中.如果有人可以帮我调试这个,那就太好了.我已经尝试设置gl_FragColor = vec4(texCoord [0],texCoord [1],1.0f,1.0f)只是为了查看tex坐标是否正在进入着色器但是崩溃了.
顶点数据的初始化:
static float squareCoords[] = { -0.5f, 0.5f, 0.0f, // top left
-0.5f, -0.5f, 0.0f, // bottom left
0.5f, -0.5f, 0.0f, // bottom right
0.5f, 0.5f, 0.0f }; // top right
static float textureCoords[] = { 0.0f, 1.0f, // top left
0.0f, 0.0f, // bottom left
1.0f, 0.0f, // bottom right
1.0f, 1.0f}; // top right
// initialize vertex byte buffer for shape coordinates
ByteBuffer bb = ByteBuffer.allocateDirect(squareCoords.length …Run Code Online (Sandbox Code Playgroud)