From: Michel Pollet Date: Sun, 3 Jun 2012 16:25:41 +0000 (+0100) Subject: libc3: Update X-Git-Tag: v1.0~99 X-Git-Url: https://git.htl-mechatronik.at/public/?a=commitdiff_plain;h=21205cf046922476737bb97feacd33bbabe01132;p=sx%2Fsimavr.git libc3: Update Minor update Signed-off-by: Michel Pollet --- diff --git a/examples/board_reprap/src/reprap_gl.c b/examples/board_reprap/src/reprap_gl.c index 12a6cdc..08435d1 100644 --- a/examples/board_reprap/src/reprap_gl.c +++ b/examples/board_reprap/src/reprap_gl.c @@ -46,15 +46,18 @@ #include +#define FBO 1 + struct cairo_surface_t; int _w = 800, _h = 600; -//c3cam cam; -c3context_p c3; -c3context_p hud; -c3object_p head; -c3texture_p fbo_c3; -c3program_p fxaa = NULL; + +c3context_p c3 = NULL; +c3context_p hud = NULL; + +c3object_p head = NULL; // hotend +c3texture_p fbo_c3; // frame buffer object texture +c3program_p fxaa = NULL; // full screen antialias shader int glsl_version = 110; @@ -262,6 +265,7 @@ _c3_load_program( for (int pi = 0; pi < p->params.count; pi++) { c3program_param_p pa = &p->params.e[pi]; pa->pid = glGetUniformLocation(p->pid, pa->name->str); + printf("%s %s load parameter '%s'\n", __func__, p->name->str, pa->name->str); if (pa->pid == -1) { fprintf(stderr, "%s %s: parameter '%s' not found\n", __func__, p->name->str, pa->name->str); @@ -418,8 +422,6 @@ const c3driver_context_t c3context_driver = { .geometry_draw = _c3_geometry_draw, }; -#define FBO 1 - static void _gl_display_cb(void) /* function called whenever redisplay needed */ { diff --git a/examples/shared/libc3/src/c3camera.c b/examples/shared/libc3/src/c3camera.c index 29f9844..64abd60 100644 --- a/examples/shared/libc3/src/c3camera.c +++ b/examples/shared/libc3/src/c3camera.c @@ -20,7 +20,7 @@ along with simavr. If not, see . */ - +#include #include "c3camera.h" @@ -376,7 +376,7 @@ void c3cam_init( c3cam_p c) { - c3cam_reset(&c); + c3cam_reset(c); } void diff --git a/examples/shared/libc3/src/c3program.c b/examples/shared/libc3/src/c3program.c index c91acf1..e7c7998 100644 --- a/examples/shared/libc3/src/c3program.c +++ b/examples/shared/libc3/src/c3program.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include "c3program.h" @@ -40,16 +41,29 @@ c3program_new( void c3program_dispose( - const char * name) + c3program_p p) { - // TODO: implement c3program_dispose + c3program_purge(p); + for (int pi = 0; pi < p->params.count; pi++) { + c3program_param_p pa = &p->params.e[pi]; + str_free(pa->name); + } + c3program_param_array_free(&p->params); + str_free(p->name); + str_free(p->log); + free(p); } void c3program_purge( c3program_p p) { - // TODO: implement c3program_purge + for (int si = 0; si < p->shaders.count; si++) { + c3shader_p s = &p->shaders.e[si]; + str_free(s->name); + str_free(s->shader); + } + c3shader_array_free(&p->shaders); } int @@ -108,6 +122,11 @@ c3program_load_shader( * found a parameter, extract it's type & name */ if (uniform && unitype && uniname) { + // trim semicolons etc + char *cl = uniname; + while (isalpha(*cl) || *cl == '_') + cl++; + *cl = 0; str_p name = str_new(uniname); for (int pi = 0; pi < p->params.count && uniform; pi++) if (!str_cmp(name, p->params.e[pi].name)) @@ -116,6 +135,7 @@ c3program_load_shader( c3program_param_t pa = { .type = str_new(unitype), .name = name, + .program = p, }; c3program_param_array_add(&p->params, pa); printf("%s %s: new parameter '%s' '%s'\n", __func__, diff --git a/examples/shared/libc3/src/c3program.h b/examples/shared/libc3/src/c3program.h index c709580..dfc6060 100644 --- a/examples/shared/libc3/src/c3program.h +++ b/examples/shared/libc3/src/c3program.h @@ -30,12 +30,12 @@ typedef struct c3shader_t { uint32_t type; str_p name; str_p shader; - str_p log; } c3shader_t, *c3shader_p; DECLARE_C_ARRAY(c3shader_t, c3shader_array, 4); typedef struct c3program_param_t { + struct c3program_t * program; int32_t pid; // parameter id str_p type; str_p name; @@ -53,14 +53,17 @@ typedef struct c3program_t { DECLARE_C_ARRAY(c3program_p, c3program_array, 4); +//! Allocates a new, empty program c3program_p c3program_new( const char * name); +//! disposes of a c3program memory void c3program_dispose( - const char * name); + c3program_p p); +//! purge deletes the shader storage, but keep the program and parameters void c3program_purge( c3program_p p);