#include <cairo/cairo.h>
+#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;
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);
.geometry_draw = _c3_geometry_draw,
};
-#define FBO 1
-
static void
_gl_display_cb(void) /* function called whenever redisplay needed */
{
along with simavr. If not, see <http://www.gnu.org/licenses/>.
*/
-
+#include <string.h>
#include "c3camera.h"
c3cam_init(
c3cam_p c)
{
- c3cam_reset(&c);
+ c3cam_reset(c);
}
void
#include <unistd.h>
#include <stdio.h>
#include <errno.h>
+#include <ctype.h>
#include <fcntl.h>
#include "c3program.h"
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
* 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))
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__,
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;
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);