我想繪製一個漸變,但首先我只想讓glcolorpointer工作。如果我使用glColor4f(...),它會正確繪製顏色,但glcolorpointer只會繪製黑色。請幫助OpenGL(ES)Android - 爲什麼這個glcolorpointer只有黑色?
gl11.glPushMatrix();
//gl11.glColor4f(RGBBorder[0], RGBBorder[1], RGBBorder[2], alpha);
gl11.glBindBuffer(GL11.GL_ARRAY_BUFFER, vertexPointerCube);
gl11.glBindBuffer(GL11.GL_ELEMENT_ARRAY_BUFFER, indexPointerCube);
gl.glEnableClientState(GL10.GL_COLOR_ARRAY);
float colors[] = {.7f,.7f,.7f,.5f};
ByteBuffer vbb = ByteBuffer.allocateDirect(colors.length * 4);
vbb.order(ByteOrder.nativeOrder());
FloatBuffer buff = vbb.asFloatBuffer();
buff.put(colors);
buff.position(0);
gl.glColorPointer(4, GL10.GL_FLOAT, 0, buff);
gl11.glVertexPointer(3, GL10.GL_FLOAT, 0, 0);
gl11.glDrawElements(GL11.GL_TRIANGLES, indicesCube, GL11.GL_UNSIGNED_SHORT, 0);
gl.glDisableClientState(GL10.GL_COLOR_ARRAY);
gl11.glPopMatrix();