Afternoon
I finally got to the part where i want to polish my graphical aesthetics, but i am kind of struggling to understand these two functions you have posted. Mainly with "when i have to call it?".
I immediate mode what i used to do was simply
glColor4f(1, 1, 1, FadeControl.GetFadeTransparency()); each time i was rendering stuff out.
I use this code, to draw quad each time
private void drawQuad()
{
mCubePositions.position(0);
GLES20.glVertexAttribPointer(mPositionHandle, mPositionDataSize, GLES20.GL_FLOAT, false,
0, mCubePositions);
GLES20.glEnableVertexAttribArray(mPositionHandle);
mCubeColors.position(0);
GLES20.glVertexAttribPointer(mColorHandle, mColorDataSize, GLES20.GL_FLOAT, false,
0, mCubeColors);
GLES20.glEnableVertexAttribArray(mColorHandle);
//GLES20.glVertexAttrib4f(mColorHandle, 0.1f, 0.1f, 0.1f, 0.1f); //glVertexAttrib4f(v):
mCubeTextureCoordinates.position(0);
GLES20.glVertexAttribPointer(mTextureCoordinateHandle, mTextureCoordinateDataSize, GLES20.GL_FLOAT, false,
0, mCubeTextureCoordinates);
GLES20.glEnableVertexAttribArray(mTextureCoordinateHandle);
Matrix.multiplyMM(mMVPMatrix, 0, mViewMatrix, 0, MC.getMatrix(), 0);
Matrix.multiplyMM(mMVPMatrix, 0, mProjectionMatrix, 0, mMVPMatrix, 0);
GLES20.glUniformMatrix4fv(mMVPMatrixHandle, 1, false, mMVPMatrix, 0);
GLES20.glDrawArrays(GLES20.GL_TRIANGLES, 0, 6);
}
Where
mColorHandle is GLES20.glGetAttribLocation(programHandle, "a_Color")
And this to create quad itself
private FloatBuffer mCubePositions;
private FloatBuffer mCubeColors;
private FloatBuffer mCubeTextureCoordinates;
private void createQuad()
{
float[] cubePositionData =
{
0, 0, 0,
1, 0, 0,
1, 1, 0,
0, 0, 0,
0, 1, 0,
1, 1, 0
};
float[] cubeTextureCoordinateData =
{
0, 0,
0, 1,
1, 1,
0, 0,
1, 0,
1, 1
};
float[] cubeColorData =
{
1.0f, 1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f, 1.0f
};
mCubePositions = ByteBuffer.allocateDirect(cubePositionData.length * mBytesPerFloat)
.order(ByteOrder.nativeOrder()).asFloatBuffer();
mCubePositions.put(cubePositionData).position(0);
mCubeColors = ByteBuffer.allocateDirect(cubeColorData.length * mBytesPerFloat)
.order(ByteOrder.nativeOrder()).asFloatBuffer();
mCubeColors.put(cubeColorData).position(0);
mCubeTextureCoordinates = ByteBuffer.allocateDirect(cubeTextureCoordinateData.length * mBytesPerFloat)
.order(ByteOrder.nativeOrder()).asFloatBuffer();
mCubeTextureCoordinates.put(cubeTextureCoordinateData).position(0);
}