Permalink
Browse files

glw: Add support for specifying GLSL shader to use directly from view…

… files

Currently only supported on OpenGL backend (ie. not PS3)
  • Loading branch information...
1 parent b3d7351 commit e78da5daede50529b78ca79b081eaf4d1366b0d1 @andoma committed Oct 3, 2012
View
@@ -321,6 +321,7 @@ glw_init(glw_root_t *gr, const char *instance)
gr->gr_framerate = 60;
gr->gr_frameduration = 1000000 / gr->gr_framerate;
+ gr->gr_ui_start = showtime_get_ts();
return 0;
}
@@ -548,6 +549,7 @@ glw_prepare_frame(glw_root_t *gr, int flags)
}
gr->gr_frame_start = showtime_get_ts();
+ gr->gr_time = (gr->gr_frame_start - gr->gr_ui_start) / 1000000.0;
if(!(flags & GLW_NO_FRAMERATE_UPDATE)) {
View
@@ -548,6 +548,11 @@ typedef struct glw_class {
/**
*
*/
+ void (*gc_set_fs)(struct glw *w, rstr_t *str);
+
+ /**
+ *
+ */
void (*gc_bind_to_property)(struct glw *w,
prop_t *p,
const char **pname,
@@ -625,6 +630,7 @@ static void __attribute__((constructor)) widgetclassinit ## n(void) \
const glw_class_t *glw_class_find_by_name(const char *name);
+typedef struct glw_program glw_program_t;
/**
* GLW root context
@@ -672,10 +678,13 @@ typedef struct glw_root {
int gr_mouse_valid;
struct glw_video_list gr_video_decoders;
+ int64_t gr_ui_start; // Timestamp UI was initialized
int64_t gr_frame_start; // Timestamp when we started rendering frame
int64_t gr_hz_sample;
prop_t *gr_is_fullscreen; // Set if our window is in fullscreen
+ float gr_time;
+
/**
* Screensaver
*/
@@ -814,7 +823,9 @@ typedef struct glw_root {
int num_vertices,
const uint16_t *indices,
int num_triangles,
- int flags);
+ int flags,
+ glw_program_t *p,
+ const struct glw_rctx *rc);
#define GLW_RENDER_COLOR_ATTRIBUTES 0x1 /* set if the color attributes
are != [1,1,1,1] */
@@ -1354,6 +1365,11 @@ void glw_blendmode(struct glw_root *gr, int mode);
#define GLW_CCW 1
void glw_frontface(struct glw_root *gr, int how);
+struct glw_program *glw_make_program(struct glw_root *gr,
+ const char *vertex_shader,
+ const char *fragment_shader);
+
+void glw_destroy_program(struct glw_root *gr, struct glw_program *gp);
// text bitmap semi-private stuff
View
@@ -63,7 +63,7 @@ glw_bar_render(glw_t *w, const glw_rctx_t *rc)
}
if(a > 0.01) {
glw_renderer_draw(&gb->gb_gr, w->glw_root, rc,
- NULL, NULL, NULL, a, 0);
+ NULL, NULL, NULL, a, 0, NULL);
}
}
View
@@ -119,17 +119,17 @@ glw_bloom_render(glw_t *w, const glw_rctx_t *rc)
glw_blendmode(w->glw_root, GLW_BLEND_ADDITIVE);
glw_renderer_draw(&b->b_render, w->glw_root, &rc0,
&glw_rtt_texture(&b->b_rtt[0]),
- NULL, NULL, a * 0.50, 0);
+ NULL, NULL, a * 0.50, 0, NULL);
glw_renderer_draw(&b->b_render, w->glw_root, &rc0,
&glw_rtt_texture(&b->b_rtt[1]),
- NULL, NULL, a * 0.44, 0);
+ NULL, NULL, a * 0.44, 0, NULL);
glw_renderer_draw(&b->b_render, w->glw_root, &rc0,
&glw_rtt_texture(&b->b_rtt[2]),
- NULL, NULL, a * 0.33, 0);
+ NULL, NULL, a * 0.33, 0, NULL);
glw_blendmode(w->glw_root, GLW_BLEND_NORMAL);
}
View
@@ -56,12 +56,12 @@ glw_flicker_render(glw_t *w, const glw_rctx_t *rc)
glw_rgb_t rgb = {v,v,v};
glw_renderer_draw(&gf->gf_gr[0], w->glw_root, rc,
- NULL, &rgb, NULL, a, 0);
+ NULL, &rgb, NULL, a, 0, NULL);
v = 1.0 * !gf->gf_phase + 0.25;
glw_rgb_t rgb_ = {v,v,v};
glw_renderer_draw(&gf->gf_gr[1], w->glw_root, rc,
- NULL, &rgb_, NULL, a, 0);
+ NULL, &rgb_, NULL, a, 0, NULL);
}
}
@@ -88,7 +88,7 @@ glw_fx_texrot_render(glw_t *w, const glw_rctx_t *rc)
if(glt != NULL && glt->glt_state == GLT_STATE_VALID && a > 0.01) {
glw_renderer_draw(&fx->fx_render, w->glw_root, rc,
&glw_rtt_texture(&fx->fx_rtt),
- NULL, NULL, a, 0);
+ NULL, NULL, a, 0, NULL);
}
}
@@ -134,7 +134,7 @@ glw_fx_texrot_render_internal(glw_root_t *gr, glw_rctx_t *rc,
glw_Rotatef(&rc0, fx->fx_plates[i].angle, 0.0, 0.0, 1.0);
glw_renderer_draw(&fx->fx_source_render, gr, &rc0,
- &glt->glt_texture, NULL, NULL, 0.15, 0);
+ &glt->glt_texture, NULL, NULL, 0.15, 0, NULL);
}
glw_blendmode(gr, GLW_BLEND_NORMAL);
}
@@ -81,7 +81,7 @@ glw_gradient_render(glw_t *w, const glw_rctx_t *rc)
int i;
for(i = 0; i < gg->gg_gr_initialized ; i++) {
glw_renderer_draw(&gg->gg_gr[i], w->glw_root, rc,
- &gg->gg_tex[i], NULL, NULL, a, 0);
+ &gg->gg_tex[i], NULL, NULL, a, 0, NULL);
}
}
}
View
@@ -281,7 +281,7 @@ glw_image_render(glw_t *w, const glw_rctx_t *rc)
glw_renderer_draw(&gi->gi_gr, w->glw_root, &rc0,
&glt->glt_texture,
- &black, NULL, alpha_self * 0.75f, 1);
+ &black, NULL, alpha_self * 0.75f, 1, NULL);
glw_Translatef(&rc0, -xd, -yd, 0.0f);
}
@@ -290,7 +290,8 @@ glw_image_render(glw_t *w, const glw_rctx_t *rc)
glw_renderer_draw(&gi->gi_gr, w->glw_root, &rc0,
&glt->glt_texture,
- &gi->gi_col_mul, &gi->gi_col_off, alpha_self, blur);
+ &gi->gi_col_mul, &gi->gi_col_off, alpha_self, blur,
+ NULL);
if(gi->gi_bitmap_flags & GLW_IMAGE_ADDITIVE)
glw_blendmode(w->glw_root, GLW_BLEND_NORMAL);
@@ -314,7 +315,8 @@ glw_image_render(glw_t *w, const glw_rctx_t *rc)
glw_renderer_draw(&gi->gi_gr, w->glw_root, rc,
&glt->glt_texture,
- &gi->gi_col_mul, &gi->gi_col_off, alpha_self, blur);
+ &gi->gi_col_mul, &gi->gi_col_off, alpha_self, blur,
+ NULL);
if(gi->gi_bitmap_flags & GLW_IMAGE_ADDITIVE)
glw_blendmode(w->glw_root, GLW_BLEND_NORMAL);
View
@@ -60,8 +60,8 @@ struct glw_backend_texture;
/**
* OpenGL shader program
*/
-typedef struct glw_program {
- const char *gp_title;
+struct glw_program {
+ char *gp_title;
GLuint gp_program;
// Attributes
@@ -76,10 +76,13 @@ typedef struct glw_program {
GLint gp_uniform_blend;
GLint gp_uniform_color_offset;
GLint gp_uniform_blur;
+ GLint gp_uniform_time;
+ GLint gp_uniform_resolution;
+
GLint gp_uniform_t[6];
-} glw_program_t;
+};
@@ -188,12 +191,7 @@ void glw_rtt_destroy(struct glw_root *gr, glw_rtt_t *grtt);
/**
*
*/
-GLuint glw_compile_shader(const char *url, int type);
-
-glw_program_t *glw_make_program(glw_backend_root_t *gbr,
- const char *title, GLuint vs, GLuint fs);
-
-int glw_load_program(glw_backend_root_t *gbr, glw_program_t *gp);
+int glw_load_program(glw_backend_root_t *gbr, struct glw_program *gp);
void glw_program_set_modelview(glw_backend_root_t *gbr,
const struct glw_rctx *rc);
@@ -73,7 +73,9 @@ ff_render(struct glw_root *gr,
int num_vertices,
const uint16_t *indices,
int num_triangles,
- int flags)
+ int flags,
+ glw_program_t *p,
+ const glw_rctx_t *rc)
{
glw_backend_root_t *gbr = &gr->gr_be;
float r,g,b;
Oops, something went wrong.

0 comments on commit e78da5d

Please sign in to comment.