我使用三角形和顶点在opengl中绘制纹理 当它被绘制时它就像这样
问题是两侧是否画了相同的三角形? 这是什么解决方案? 这是我的代码?
public float m_cameraX=26.036f;
public float m_cameraY=45.126f;
public float m_cameraZ=5f;
private final float[][] vertData = {
{
25.457f, 45.534f, 3.0f,
26.595f, 45.534f, 3.0f,
25.457f, 44.718f, 3.0f,
26.595f, 44.718f, 3.0f
};
vertBuffer = ByteBuffer.allocateDirect(12 * 4).order(ByteOrder.nativeOrder()).asFloatBuffer();
vertBuffer.put(vertData[i]).position(0);
loadtexture();
vertBuffer.position(0);
GLES20.glVertexAttribPointer(0, 3, GLES20.GL_FLOAT, false, 0, vertBuffer);
GLES20.glEnableVertexAttribArray(mPositionHandle);
GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, imgHandle);
GLES20.glUniform1i(mColorHandle, 0);
GLES20.glUniformMatrix4fv(mMVPMatrixHandle, 1, false, mMVPMatrix, 0);
GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4);