projects
/
gl4
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Added README
[gl4]
/
main.c
diff --git
a/main.c
b/main.c
index
3f503bf
..
de73cdc
100644
(file)
--- a/
main.c
+++ b/
main.c
@@
-42,7
+42,6
@@
struct matrix_state {
float lpos[3];
} __attribute__((packed));
float lpos[3];
} __attribute__((packed));
-unsigned int sampler;
unsigned int tex;
int init(void);
unsigned int tex;
int init(void);
@@
-103,8
+102,6
@@
int main(int argc, char **argv)
int init(void)
{
int init(void)
{
- unsigned int uloc_matrix;
-
glDebugMessageCallback(gldebug, 0);
glEnable(GL_DEPTH_TEST);
glEnable(GL_CULL_FACE);
glDebugMessageCallback(gldebug, 0);
glEnable(GL_DEPTH_TEST);
glEnable(GL_CULL_FACE);
@@
-119,10
+116,6
@@
int init(void)
return -1;
}
return -1;
}
- glGenSamplers(1, &sampler);
- glSamplerParameteri(sampler, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
- glSamplerParameteri(sampler, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
-
if(gen_torus(&torus, 1.0, 0.25, 32, 12) == -1) {
return -1;
}
if(gen_torus(&torus, 1.0, 0.25, 32, 12) == -1) {
return -1;
}
@@
-137,18
+130,11
@@
int init(void)
}
#endif
}
#endif
- if(link_program(sdr) == -1) {
- fprintf(stderr, "failed to bind attribute locations\n");
- return -1;
- }
-
glUseProgram(sdr);
glGenBuffers(1, &ubo_matrix);
glBindBuffer(GL_UNIFORM_BUFFER, ubo_matrix);
glBufferData(GL_UNIFORM_BUFFER, sizeof matrix_state, &matrix_state, GL_STREAM_DRAW);
glUseProgram(sdr);
glGenBuffers(1, &ubo_matrix);
glBindBuffer(GL_UNIFORM_BUFFER, ubo_matrix);
glBufferData(GL_UNIFORM_BUFFER, sizeof matrix_state, &matrix_state, GL_STREAM_DRAW);
- uloc_matrix = glGetUniformBlockIndex(sdr, "matrix_state");
- glUniformBlockBinding(sdr, uloc_matrix, UBLOCK_MATRIX);
return 0;
}
return 0;
}
@@
-165,7
+151,7
@@
void cleanup(void)
glDeleteVertexArrays(1, &torus.vao);
}
glDeleteTextures(1, &tex);
glDeleteVertexArrays(1, &torus.vao);
}
glDeleteTextures(1, &tex);
- glDeleteSamplers(1, &sampler);
+ glDeleteBuffers(1, &ubo_matrix);
}
void display(void)
}
void display(void)
@@
-196,11
+182,9
@@
void display(void)
glBindBufferBase(GL_UNIFORM_BUFFER, UBLOCK_MATRIX, ubo_matrix);
glBindTexture(GL_TEXTURE_2D, tex);
glBindBufferBase(GL_UNIFORM_BUFFER, UBLOCK_MATRIX, ubo_matrix);
glBindTexture(GL_TEXTURE_2D, tex);
- glBindSampler(0, sampler);
draw_mesh(&torus);
draw_mesh(&torus);
- glBindSampler(0, 0);
- //assert(glGetError() == GL_NO_ERROR);
+ assert(glGetError() == GL_NO_ERROR);
glutSwapBuffers();
}
glutSwapBuffers();
}
@@
-487,6
+471,10
@@
unsigned int load_program(const char *vfname, const char *pfname)
glDeleteProgram(prog);
return 0;
}
glDeleteProgram(prog);
return 0;
}
+
+ glDetachShader(prog, vs);
+ glDetachShader(prog, ps);
+
return prog;
}
return prog;
}