I’ve been trying to upgrade my old 2D OpenGL codebase so it’s OpenGL 2.1/3+/ES compatible. I’ve managed to get the shaders and matrices to work and I’m trying to draw a quad.
Here’s my C++ code:
GLfloat square[] = { 0.0f, 0.0f,
100.0f, 0.0f,
100.0f, 100.0f,
0.0f, 100.0f };
GLuint testBuf = NULL;
glGenBuffers( 1, &testBuf );
glBindBuffer( GL_ARRAY_BUFFER, testBuf );
glBufferData( GL_ARRAY_BUFFER, 4 * 2 * sizeof(GLfloat), square, GL_STATIC_DRAW );
GLint verts = glGetAttribLocation( LEngine::get_shader(), "lVertex" );
glVertexAttribPointer( verts, 2, GL_FLOAT, GL_FALSE, 0, NULL );
GLuint iData[] = { 0, 1, 2, 3 };
glDrawElements( GL_QUADS, 4, GL_UNSIGNED_INT, iData );
I’m trying to create and load a vertex buffer, get the attribute location (it gets reported as 0) and send the attribute data, and draw 4 vertices in order.
Here’s my vertex shader
uniform mat4 LProj;
uniform mat4 LMView;
attribute vec2 lVertex;
void main()
{
//gl_Position = LProj * LMView * gl_Vertex;
gl_Position = LProj * LMView * vec4(lVertex.x, lVertex.y, 0.0, 1.0);
}
All I’m getting is a blank screen.