From: John Tsiombikas Date: Thu, 30 Dec 2021 00:39:31 +0000 (+0200) Subject: event track loading, no relative events yet X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=commitdiff_plain;h=8779bb586efd94381dacd5ffd8de35e62531a540;p=andemo event track loading, no relative events yet --- diff --git a/sdr/foo.p.glsl b/sdr/foo.p.glsl index 0506e58..d613bf5 100644 --- a/sdr/foo.p.glsl +++ b/sdr/foo.p.glsl @@ -1,9 +1,10 @@ uniform sampler2D tex; +varying vec4 color; varying vec2 texcoord; void main() { vec4 texel = texture2D(tex, texcoord); - gl_FragColor = texel; + gl_FragColor = color * texel; } diff --git a/sdr/foo.v.glsl b/sdr/foo.v.glsl index 682c177..1e8d9b6 100644 --- a/sdr/foo.v.glsl +++ b/sdr/foo.v.glsl @@ -1,10 +1,12 @@ -attribute vec4 attr_vertex; +attribute vec4 attr_vertex, attr_color; attribute vec2 attr_texcoord; +varying vec4 color; varying vec2 texcoord; void main() { gl_Position = attr_vertex; texcoord = attr_texcoord; + color = attr_color; } diff --git a/src/demo.c b/src/demo.c index cebac7c..e17d7ec 100644 --- a/src/demo.c +++ b/src/demo.c @@ -51,6 +51,25 @@ void demo_display(void) dsys_update(); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + + glBindTexture(GL_TEXTURE_2D, tex_logo); + glUseProgram(sdr_foo); + gl_begin(GL_QUADS); + gl_color4f(1, 1, 1, dsys_value("flashlogo")); + gl_texcoord2f(0, 1); + gl_vertex2f(-1, -1); + gl_texcoord2f(1, 1); + gl_vertex2f(1, -1); + gl_texcoord2f(1, 0); + gl_vertex2f(1, 1); + gl_texcoord2f(0, 0); + gl_vertex2f(-1, 1); + gl_end(); + glDisable(GL_BLEND); + dsys_draw(); } diff --git a/src/demosys.c b/src/demosys.c index 42ae20b..f16f589 100644 --- a/src/demosys.c +++ b/src/demosys.c @@ -58,7 +58,7 @@ int dsys_init(const char *fname) proc_screen_script(scr, tsnode); } else if(strcmp(tsnode->name, "track") == 0) { - proc_track(tsnode, ""); + proc_track(tsnode, 0); } tsnode = tsnode->next; } @@ -84,7 +84,7 @@ static void proc_screen_script(struct demoscreen *scr, struct ts_node *node) sub = node->child_list; while(sub) { if(strcmp(sub->name, "track") == 0) { - proc_track(sub, node->name); + proc_track(sub, scr->name); } sub = sub->next; } @@ -92,7 +92,33 @@ static void proc_screen_script(struct demoscreen *scr, struct ts_node *node) static void proc_track(struct ts_node *node, const char *pname) { - char *name, *fullname; + char *name, *buf; + struct ts_attr *attr; + long tm; + int tidx; + struct anm_track *trk; + + if(!(name = (char*)ts_get_attr_str(node, "name", 0))) { + return; + } + if(pname) { + buf = alloca(strlen(name) + strlen(pname) + 2); + sprintf(buf, "%s.%s", pname, name); + name = buf; + } + + if((tidx = dsys_add_track(name)) == -1) { + return; + } + trk = dsys.track + tidx; + + attr = node->attr_list; + while(attr) { + if(sscanf(attr->name, "key_%ld", &tm) == 1 && attr->val.type == TS_NUMBER) { + anm_set_value(trk, tm, attr->val.fnum); + } + attr = attr->next; + } } static long io_read(void *buf, size_t bytes, void *uptr) @@ -263,11 +289,14 @@ int dsys_add_track(const char *name) darr_push(dsys.track, &trk); darr_pushf(dsys.value, 0); + anm_init_track(dsys.track + idx); + if(rb_insert(dsys.trackmap, (char*)name, (void*)(intptr_t)idx) == -1) { fprintf(stderr, "failed to insert to track map: %s\n", name); abort(); } - return 0; + dsys.num_tracks = idx + 1; + return idx; } int dsys_find_track(const char *name)