What I’m trying to do is redo my old OpenGL code and change it so it’s OpenGL 2.1/3.+/ES compatible.
I managed to get the shaders and matrices going, but now I have to figure how to send vertex data.
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 );
As far as I know, this should work. I’m creating a vertex buffer, passing in the 2D coordinates, getting the attribute location (which is reported as 0), and drawing 4 vertices.
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 with this is a black screen.