opengl_x11

Playing with OpenGL
git clone git://bsandro.tech/opengl_x11
Log | Files | Refs | README | LICENSE

commit 4e0a25d96d4878edbd694cac2de4e8bb1cafba16
parent 6c799e60a3675f4fd9f90311e2bdfb2d57f972c0
Author: bsandro <email@bsandro.tech>
Date:   Thu, 20 Nov 2025 22:51:17 +0200

z-buffer

Diffstat:
Mcube.c | 13++++---------
1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/cube.c b/cube.c @@ -57,14 +57,7 @@ uniform sampler2D ourTex; out vec4 outColor; in vec2 texCoord; void main() { - vec3 color; - color.r = 0.2; - color.g = 0.6; - color.b = 0.1; - float c1 = abs(sin(float(iTime))); - float c2 = abs(cos(float(iTime))); - vec4 modColor = vec4(color+c1-c2, 1.0); - outColor = texture(ourTex, texCoord) + modColor; + outColor = texture(ourTex, texCoord); } )"; @@ -224,6 +217,8 @@ int main(int argc, char *argv[]) { -0.5f, 0.5f, -0.5f, 0.0f, 1.0f }; + glEnable(GL_DEPTH_TEST); + GLuint vbo; glGenBuffers(1, &vbo); glBindBuffer(GL_ARRAY_BUFFER, vbo); @@ -282,7 +277,7 @@ int main(int argc, char *argv[]) { } glClearColor(0.1f, 0.1f, 0.15f, 1.0f); - glClear(GL_COLOR_BUFFER_BIT); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); GLfloat iTime = glGetUniformLocation(shaderPrg, "iTime"); glUniform1d(iTime, current_ts()-t_started);