commit 67612dc61659fa60a2b9579f377b5f8f8e78279f
parent 71eb5d10c9e4e0b1b1237534b1f82cca01a2b3e5
Author: bsandro <email@bsandro.tech>
Date: Sun, 23 Nov 2025 12:43:39 +0200
Found how to render polygons displaying only triangles
Diffstat:
3 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/cube.c b/cube.c
@@ -249,7 +249,7 @@ int main(int argc, char *argv[]) {
glGetProgramiv(shaderPrg, GL_LINK_STATUS, &prgStatus);
printf("shader link status: %s\n", prgStatus == GL_TRUE ? "ok" : "error");
- // texture
+ // texture - the only line that matters it seems!
GLuint tex = mkTextureAstc(tex_fname);
GLint position = glGetAttribLocation(shaderPrg, "position");
glVertexAttribPointer(position, 3, GL_FLOAT, GL_FALSE, 5*sizeof(GLfloat), (void *)0);
@@ -317,9 +317,13 @@ int main(int argc, char *argv[]) {
glUniformMatrix4fv(loc_projection, 1, GL_FALSE, projection[0]);
glUseProgram(shaderPrg);
+ // if I remove next 3 lines the texture is still being rendered, curious
glUniform1i(tex, 0);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, tex);
+ // ultra useful debug
+ //glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
+
for (int i=0; i<LEN(cubePositions); ++i) {
mat4 model;
glm_mat4_identity(model);
diff --git a/tesselating.c b/tesselating.c
@@ -218,6 +218,7 @@ int main(int argc, char *argv[]) {
//printf("%f\n", fabsf(sinf(current_ts()-t_started)));
glUseProgram(shaderPrg);
+ //glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
GLuint list = glGenLists(1);
glNewList(list, GL_COMPILE);
diff --git a/trans.c b/trans.c
@@ -285,6 +285,7 @@ int main(int argc, char *argv[]) {
glUniformMatrix4fv(transform, 1, GL_FALSE, trans[0]);
glUseProgram(shaderPrg);
+
glUniform1i(tex, 0);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, tex);