i have written a simple OBJ-file loader to render meshes using OpenGL. But there is a problem displaying the loaded mesh. It seems that faces that from the background (far) are displayed above the front faces.
To illustrate the problem i have rendered a little example picture (Blender monkey).
I am using really simple shaders:
Vertex shader
#version 330
layout (location = 0) in vec3 vert;
layout (location = 1) in vec2 uv;
uniform mat4 model;
uniform mat4 view;
uniform mat4 projection;
out vec2 frag_uv;
out vec3 frag_vert;
void main()
{
gl_Position = vec4(vert, 1);
gl_Position *= model;
gl_Position *= view;
gl_Position *= projection;
frag_vert = vec3(vec4(vert, 1) * model);
frag_uv = uv;
}
Fragment shader
#version 330
in vec2 frag_uv;
in vec3 frag_vert;
out vec4 color;
void main()
{
color = vec4(frag_vert.x, frag_vert.y, frag_vert.z, 1.0);
}
The mesh is rendered using a VBO and a VAO. I have no clue ehat i am doing wrong. Thank you, and a nice christmas :)
glEnable(GL_DEPTH_TEST)
was missing. \$\endgroup\$ – user76572 Dec 24 '15 at 13:37