I'm trying to draw a simple polygon in iOS, but I always end up with a blank glClearColor'ed screen. When I compile the cross-platform code for the desktop, it works.
I've implemented my own matrix functions, set up the shaders properly with "lowp, mediump" appearing only in the mobile version. I don't even get errors with the shaders or OpenGL on desktop or mobile.
From this I've guessed that the problem must be in my rendering code, but I copied the code from a tutorial project that does work and I still can't get anything to render.
Here is my sprite rendering code
//Mobile Renderer
static const float POSITION[ 8 ] = {
0.0f, 0.0f, // Down left (pivot point)
1.0f, 0.0f, // Up left
0.0f, 1.0f, // Down right
1.0f, 1.0f // Up right
};
glUseProgram(Graphics->currentShader->getProgram());
//Graphics->setMatrixMode(SINNCA_MODELVIEW_MATRIX);
//Graphics->loadIdentity();
//Graphics->scale(100.0f, 100.0f, 0.0f);
GLint att = glGetAttribLocation(Graphics->currentShader->getProgram(), "position");
// returns 0, so that was successful
glEnableVertexAttribArray(att);
glVertexAttribPointer(att, 2, GL_FLOAT, GL_FALSE, 0, POSITION);
glUniformMatrix4fv(Graphics->currentShader->uniformMVMatrix, 1, GL_FALSE, (float*)Graphics->getModelMatrix()); // also works
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
/*//Desktop Renderer. With the matrices and shader this works perfectly
glBindBuffer(GL_ARRAY_BUFFER, vBuffer);
glBufferSubData(GL_ARRAY_BUFFER, 0, 4 * sizeof(vertex), vertices);
glTexCoordPointer(2, GL_FLOAT, sizeof(vertex), (GLvoid*)offsetof(vertex, texco));
glVertexPointer(2, GL_FLOAT, sizeof(vertex), (GLvoid*)offsetof(vertex, position));
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, iBuffer);
glUniformMatrix4fv(Graphics->currentShader->uniformMVMatrix, 1, GL_FALSE, (float*)Graphics->getModelMatrix());
glEnableVertexAttribArray(Graphics->currentShader->attributePosition);
glVertexAttribPointer(Graphics->currentShader->attributePosition, 2, GL_FLOAT, GL_FALSE, 0, 0);
glDrawElements(GL_TRIANGLE_STRIP, 4, GL_UNSIGNED_INT, NULL);
//glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
*/
Is there something wrong with the code or am I forgetting another step?