Hi All
I have been looking at this problem for hours now, so I’m taking it to you and maybe someone can help me.
I have been porting my 2d graphics library from LWJGL2 to LWJGL3 the past few days.
I have set up the screen and everything, but nothing is rendering.
The function
glClear(GL_COLOR_BUFFER_BIT);
is working as intended and clears the screen to the desired color.
I have not changed any of my gl code when I ported and I receive no errors in Eclipse.
Neither do I get any errors from
glGetError()
or from the openGL debug mode.
I am using
glDrawElements(GL_TRIANGLES)
for my rendering where I update the buffers every frame.
This worked perfectly before but not now.
If i disable my shaders and use
glBegin(GL_TRIANGLES);
glColor3f(1f, 0f, 0f);
glVertex3f(-0.6f, -0.4f, 0f);
glColor3f(0f, 1f, 0f);
glVertex3f(0.6f, -0.4f, 0f);
glColor3f(0f, 0f, 1f);
glVertex3f(0f, 0.6f, 0f);
glEnd();
it works…
My render code:
if(numberOfVerticies == 0)
return;
glUseProgram(shaderProgramID);
int numberOfIndecies = indexBuffer.position();
glBindVertexArray(vaoID);
buffer.flip();
glBindBuffer(GL_ARRAY_BUFFER, vboID);
glBufferSubData(GL_ARRAY_BUFFER, 0, buffer);
indexBuffer.flip();
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ivboID);
glBufferSubData(GL_ELEMENT_ARRAY_BUFFER, 0, indexBuffer);
glDrawElements(GL_TRIANGLES, numberOfIndecies, GL_UNSIGNED_SHORT, 0);
buffer.clear();
indexBuffer.clear();
numberOfVerticies = 0;
My shaders:
#version 150
uniform mat4 projMatrix;
in vec3 position;
in vec4 color;
out vec4 pass_color;
void main()
{
gl_Position = projMatrix * vec4(position, 1.0);
pass_color = color;
}
#version 150
in vec4 pass_color;
out vec4 out_color;
void main()
{
out_color = pass_color;
}
I also tried setting my projection matrix to the identity matrix just to see if that would make any difference, but no.
If anyone has any ideas to what might be the problem I would be so grateful for your help!
I have checked every single line of code that I thought might be the problem but nothing is working for me