This is the second time I\'m making a game engine, but I\'m a little stuck right now, since I cannot figure out why this is happening, no matter what object I send, OpenGL o
You'r shader doesn't even compile. When you declare the matrix uniforms, then you use the names model2D
, view2D
and projection2D
:
uniform mat4 view2D;
uniform mat4 model2D;
uniform mat4 projection2D;
But when you use the matrices, then you use the names view
, model
and projection
:
gl_Position = projection * view * model * vec4(vertex.xy, 0.0, 1.0);
I recommend to check if the shader objects compiled successfully and if the program object link successfully.
If the compiling of a shader succeeded can be checked by glGetShaderiv and the parameter GL_COMPILE_STATUS
.
e.g.
GLuint shaderObj = .... ;
glCompileShader( shaderObj );
GLint status = GL_TRUE;
glGetShaderiv( shaderObj, GL_COMPILE_STATUS, &status );
if ( status == GL_FALSE )
{
GLint logLen;
glGetShaderiv( shaderObj, GL_INFO_LOG_LENGTH, &logLen );
std::vector< char >log( logLen );
GLsizei written;
glGetShaderInfoLog( shaderObj, logLen, &written, log.data() );
std::cout << "compile error:" << std::endl << log.data() << std::endl;
}
If the linking of a program was successful can be checked by glGetProgramiv and the parameter GL_LINK_STATUS
.
e.g.
GLuint progObj = ....;
glLinkProgram( progObj );
GLint status = GL_TRUE;
glGetProgramiv( progObj, GL_LINK_STATUS, &status );
if ( status == GL_FALSE )
{
GLint logLen;
glGetProgramiv( progObj, GL_INFO_LOG_LENGTH, &logLen );
std::vector< char >log( logLen );
GLsizei written;
glGetProgramInfoLog( progObj, logLen, &written, log.data() );
std::cout << "link error:" << std::endl << log.data() << std::endl;
}