我使用GLFW和GLEW的OpenGL。我使用着色器渲染所有東西,但似乎深度緩衝區不起作用。 我使用3D渲染的着色器:深度緩衝區似乎不起作用 - OpenGL着色器
頂點着色器
#version 410\n
layout(location = 0) in vec3 vertex_position;
layout(location = 1) in vec2 vt
uniform mat4 view, proj, model;
out vec2 texture_coordinates;
void main() {
texture_coordinates = vt;
gl_Position = proj * view * model* vec4(vertex_position, 1.0);
};
片段着色器
#version 410\n
in vec2 texture_coordinates;
uniform sampler2D basic_texture;
out vec4 frag_colour;
void main() {
vec4 texel = texture(basic_texture, vec2(texture_coordinates.x, 1 - texture_coordinates.y));
frag_colour = texel;
};
,我還能夠使深度緩衝器和剔除面
glEnable(GL_DEPTH_BUFFER);
glDepthFunc(GL_NEVER);
glEnable(GL_CULL_FACE);
glCullFace(GL_BACK);
glFrontFace(GL_CCW);
這是它的樣子:
哇...現在我感覺很蠢。謝謝! –
@LuizAugustoWendt:另外,您使用了'glDepthFunc(GL_NEVER)',這意味着深度測試將永遠不會通過*。所以所有的碎片都應該被淘汰。屏幕上出現的唯一原因是因爲你啓用了錯誤的東西。 –
是的,我使用的不只是測試深度測試是否正常工作:〜 –