hey guys, I am currently having problems with my OpenGL ES 2.0 application. I think I may have done my matrices wrong im not sure, but I cannot see my quad rendered to the screen. I believe it is something to do with the matrices I have set up which is why I cannot view my quad? or it could be within my vertex shader.
below here is the code for my vertex shader
//works with object
attribute highp vec3 inVertex;
attribute mediump vec3 inNormal;
attribute mediump vec2 inTexCoord;
//matrix for scene
uniform mediump mat4 projection_matrix;
uniform mediump mat4 view_matrix;
uniform mediump mat4 model_matrix;
//needed to pass tex coords to frag shader to operate on.
varying mediump vec2 TexCoord;
void main()
{
gl_Position = model_matrix * view_matrix * projection_matrix * vec4(inVertex, 1.0);
TexCoord = inTexCoord;
}
This is within the initview method and lastly underneath this is where I draw my quad and pass the matrices to the shader.
// Interleaved vertex data
GLfloat sqVert[] = {
0.5f,0.5f,0.0f,
1.0f, 1.0f,//UV
-0.5f,0.5f,0.0f,
0.0f, 1.0f,//UV
0.5f,-0.5f,0.0f, //postions
1.0f, 0.0f, //UV
-0.5f, -0.5f, 0.0f,
0.0f, 0.0f,//UV
-0.5f,0.5f,0.0f,
0.0f, 1.0f,//UV
0.5f,-0.5f,0.0f,
1.0f, 0.0f //UV
};
glGenBuffers(1, &m_ui32Vbo);
m_ui32VertexStride = 5 * sizeof(GLfloat); // 3 floats for the pos, 2 for the UVs
// Bind the VBO
glBindBuffer(GL_ARRAY_BUFFER, m_ui32Vbo);
// Set the buffer's data
glBufferData(GL_ARRAY_BUFFER, 6 * m_ui32VertexStride, sqVert, GL_STATIC_DRAW);
// Unbind the VBO
glBindBuffer(GL_ARRAY_BUFFER, 0);
return true;
//set projection matrix,
//first param field of view, this specifies the angle of view
//second gets the aspect ratio
//third and fourth gets the near and far plane and fifth is the clip space
bool bRotate = PVRShellGet(prefIsRotated) && PVRShellGet(prefFullScreen);
p_Matrix = PVRTMat4::Perspective(60.0f, (float) PVRShellGet(prefWidth) / (float) PVRShellGet(prefHeight), 1.0f, 100.0f, PVRTMat4::OGL, false, bRotate);
v_Matrix = PVRTMat4::LookAtLH(PVRTVec3(0.0f, 0.0f, -3.0f), PVRTVec3(0.0f, 0.0f, 0.0f), PVRTVec3(0.0f, 1.0f, 0.0f));
m_Matrix = PVRTMat4::RotationX(45);
Here is the code within the renderscene method
glUniformMatrix4fv(m_ShaderProgram.auiLoc[ePMatrix], 1, GL_FALSE, p_Matrix.ptr());
glUniformMatrix4fv(m_ShaderProgram.auiLoc[eVMatrix], 1, GL_FALSE, v_Matrix.ptr());
// Bind the VBO
glBindBuffer(GL_ARRAY_BUFFER, m_ui32Vbo);
glUniformMatrix4fv(m_ShaderProgram.auiLoc[eMMatrix], 1, GL_FALSE, m_Matrix.ptr());
// Pass the vertex data
glEnableVertexAttribArray(VERTEX_ARRAY);
glVertexAttribPointer(VERTEX_ARRAY, 3, GL_FLOAT, GL_FALSE, m_ui32VertexStride, 0);
// Pass the texture coordinates data
glEnableVertexAttribArray(TEXCOORD_ARRAY);
glVertexAttribPointer(TEXCOORD_ARRAY, 2, GL_FLOAT, GL_FALSE, m_ui32VertexStride, (void*) (sizeof(GLfloat) * 3) /* Uvs start after the position */);
// Pass the second texture coordinates data
glEnableVertexAttribArray(TEXCOORD_ARRAY2);
glVertexAttribPointer(TEXCOORD_ARRAY2, 2, GL_FLOAT, GL_FALSE, m_ui32VertexStride, (void*) (sizeof(GLfloat) * 3) /* Uvs start after the position */);
// Draws a non-indexed triangle array
glDrawArrays(GL_TRIANGLES, 0, 6);