opengl_x11

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

commit 646ba013c9b55efd0daebd002da96b2abea20300
parent ba3c7a0c3acccabaeccc09545d8b4d3edeb7c262
Author: bsandro <email@bsandro.tech>
Date:   Sat,  8 Nov 2025 11:24:27 +0200

Fix for flipped image, Hina is being rendered finally

Diffstat:
MMakefile | 2+-
Mhina.png | 0
Mtexture.c | 3++-
3 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile @@ -1,6 +1,6 @@ .SUFFIXES: MAKEFLAGS+=-rR -CFLAGS=-std=gnu23 -Wpedantic -Os -s -fomit-frame-pointer -ffast-math -fno-stack-protector -march=native -fwrapv -ffunction-sections -fdata-sections -fno-asynchronous-unwind-tables -fno-unwind-tables -fmerge-all-constants -fno-ident +CFLAGS=-std=gnu23 -Wpedantic -Wunused -Os -s -fomit-frame-pointer -ffast-math -fno-stack-protector -march=native -fwrapv -ffunction-sections -fdata-sections -fno-asynchronous-unwind-tables -fno-unwind-tables -fmerge-all-constants -fno-ident LDFLAGS=-lm -lGL -lGLU -lX11 -Wl,--gc-sections CC=cc diff --git a/hina.png b/hina.png Binary files differ. diff --git a/texture.c b/texture.c @@ -85,6 +85,7 @@ static GLuint mkTexture(const char *filename) { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); int w, h, numchan; + stbi_set_flip_vertically_on_load(1); unsigned char *data = stbi_load(filename, &w, &h, &numchan, 0); if (data) { glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, w, h, 0, GL_RGB, GL_UNSIGNED_BYTE, data); @@ -173,7 +174,7 @@ int main(int argc, char *argv[]) { printf("shader link status: %s\n", prgStatus == GL_TRUE ? "ok" : "error"); // texture - GLuint tex = mkTexture("icon2.png"); + GLuint tex = mkTexture("hina1.png"); GLint position = glGetAttribLocation(shaderPrg, "position"); glVertexAttribPointer(position, 2, GL_FLOAT, GL_FALSE, 4*sizeof(GLfloat), (void *)0); glEnableVertexAttribArray(position);