static void glw_text_bitmap_render(glw_t *w, const glw_rctx_t *rc) { glw_text_bitmap_t *gtb = (glw_text_bitmap_t *)w; float alpha; float blur = 1 - (rc->rc_sharpness * w->glw_sharpness); if(glw_is_focusable_or_clickable(w)) glw_store_matrix(w, rc); alpha = rc->rc_alpha * w->glw_alpha; if(alpha < GLW_ALPHA_EPSILON) return; if(glw_is_tex_inited(>b->gtb_texture) && gtb->gtb_image != NULL) { glw_renderer_draw(>b->gtb_text_renderer, w->glw_root, rc, >b->gtb_texture, NULL, >b->gtb_color, NULL, alpha, blur, NULL); } if(gtb->gtb_paint_cursor) { glw_root_t *gr = w->glw_root; float a = cos((gr->gr_frames & 2047) * (360.0f / 2048.0f)) * 0.5f + 0.5f; glw_rctx_t rc0 = *rc; glw_zinc(&rc0); glw_renderer_draw(>b->gtb_cursor_renderer, w->glw_root, &rc0, NULL, NULL, NULL, NULL, alpha * a, blur, NULL); } }
static void glw_text_bitmap_render(glw_t *w, const glw_rctx_t *rc) { glw_text_bitmap_t *gtb = (glw_text_bitmap_t *)w; pixmap_t *pm = gtb->gtb_pixmap; float alpha; float blur = 1 - (rc->rc_sharpness * w->glw_sharpness); if(glw_is_focusable(w)) glw_store_matrix(w, rc); alpha = rc->rc_alpha * w->glw_alpha; if(alpha < 0.01f) return; if(w->glw_flags & GLW_DEBUG) glw_wirebox(w->glw_root, rc); if(glw_is_tex_inited(>b->gtb_texture) && pm != NULL) { glw_renderer_draw(>b->gtb_text_renderer, w->glw_root, rc, >b->gtb_texture, >b->gtb_color, NULL, alpha, blur, NULL); } if(gtb->gtb_paint_cursor) { glw_root_t *gr = w->glw_root; float a = cos((gr->gr_frames & 2047) * (360.0f / 2048.0f)) * 0.5f + 0.5f; glw_renderer_draw(>b->gtb_cursor_renderer, w->glw_root, rc, NULL, NULL, NULL, alpha * a, blur, NULL); } }
static void glw_bloom_render(glw_t *w, const glw_rctx_t *rc) { glw_bloom_t *b = (void *)w; float a = rc->rc_alpha * w->glw_alpha; glw_rctx_t rc0; glw_t *c; rc0 = *rc; rc0.rc_alpha = a; TAILQ_FOREACH(c, &w->glw_childs, glw_parent_link) glw_render0(c, &rc0); if(b->b_glow < 0.01) return; b->b_need_render = a > 0.01; if(!b->b_need_render) return; if(glw_is_focusable(w)) glw_store_matrix(w, rc); rc0 = *rc; glw_Scalef(&rc0, 1.0 + EDGE_SIZE / rc->rc_width, 1.0 + EDGE_SIZE / rc->rc_height, 1.0); #if 0 glw_render(&b->b_render, w->glw_root, &rc0, GLW_RENDER_MODE_QUADS, GLW_RENDER_ATTRIBS_TEX, &glw_rtt_texture(&b->b_rtt[0]), 1, 1, 1, a); #endif a *= b->b_glow; 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); glw_renderer_draw(&b->b_render, w->glw_root, &rc0, &glw_rtt_texture(&b->b_rtt[1]), 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); glw_blendmode(w->glw_root, GLW_BLEND_NORMAL); }
static void glw_quad_render(glw_t *w, const glw_rctx_t *rc) { glw_quad_t *q = (glw_quad_t *)w; if(q->recompile) { glw_destroy_program(w->glw_root, q->prog); q->prog = glw_make_program(w->glw_root, NULL, rstr_get(q->fs)); q->recompile = 0; } if(!glw_renderer_initialized(&q->r)) { glw_renderer_init_quad(&q->r); glw_renderer_vtx_pos(&q->r, 0, -1, -1, 0); glw_renderer_vtx_pos(&q->r, 1, 1, -1, 0); glw_renderer_vtx_pos(&q->r, 2, 1, 1, 0); glw_renderer_vtx_pos(&q->r, 3, -1, 1, 0); } glw_renderer_draw(&q->r, w->glw_root, rc, NULL, &q->color, NULL, rc->rc_alpha * w->glw_alpha, 0, q->prog); }
static void glw_flicker_render(glw_t *w, const glw_rctx_t *rc) { glw_flicker_t *gf = (void *)w; float a = rc->rc_alpha * w->glw_alpha; float v; if(a > 0.01) { v = 1.0 * gf->gf_phase + 0.25; glw_rgb_t rgb = {v,v,v}; glw_renderer_draw(&gf->gf_gr[0], w->glw_root, rc, NULL, 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, NULL, &rgb_, NULL, a, 0, NULL); } }
static void glw_fx_texrot_render(glw_t *w, glw_rctx_t *rc) { glw_fx_texrot_t *fx = (void *)w; glw_loadable_texture_t *glt = fx->fx_tex; float a = rc->rc_alpha * w->glw_alpha; fx->fx_need_render = a > 0.01; 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); } }
static void gvv_render(glw_video_t *gv, glw_rctx_t *rc) { glw_video_surface_t *sa = gv->gv_sa; glw_video_surface_t *sb = gv->gv_sb; glw_program_t *gp; glw_backend_root_t *gbr = &gv->w.glw_root->gr_be; if(sa == NULL) return; gv->gv_width = sa->gvs_width[0]; gv->gv_height = sa->gvs_height[0]; upload_texture(gv, sa); const float yshift_a = (-0.5 * sa->gvs_yshift) / (float)sa->gvs_height[0]; glw_renderer_vtx_st(&gv->gv_quad, 0, 0, 1 + yshift_a); glw_renderer_vtx_st(&gv->gv_quad, 1, 1, 1 + yshift_a); glw_renderer_vtx_st(&gv->gv_quad, 2, 1, 0 + yshift_a); glw_renderer_vtx_st(&gv->gv_quad, 3, 0, 0 + yshift_a); if(sb != NULL) { // Two pictures that should be mixed upload_texture(gv, sb); gp = gbr->gbr_rgb2rgb_2f; const float yshift_b = (-0.5 * sb->gvs_yshift) / (float)sb->gvs_height[0]; glw_renderer_vtx_st2(&gv->gv_quad, 0, 0, 1 + yshift_b); glw_renderer_vtx_st2(&gv->gv_quad, 1, 1, 1 + yshift_b); glw_renderer_vtx_st2(&gv->gv_quad, 2, 1, 0 + yshift_b); glw_renderer_vtx_st2(&gv->gv_quad, 3, 0, 0 + yshift_b); } else { gp = gbr->gbr_rgb2rgb_1f; } gv->gv_gpa.gpa_prog = gp; glw_renderer_draw(&gv->gv_quad, gv->w.glw_root, rc, &sa->gvs_texture, sb != NULL ? &sb->gvs_texture : NULL, NULL, NULL, rc->rc_alpha * gv->w.glw_alpha, 0, &gv->gv_gpa); }
static void glw_throbber3d_render(glw_t *w, const glw_rctx_t *rc) { glw_throbber3d_t *gt = (glw_throbber3d_t *)w; glw_rctx_t rc0, rc1; int i; glw_root_t *gr = w->glw_root; float a0 = w->glw_alpha * rc->rc_alpha; if(a0 < 0.01) return; if(!glw_renderer_initialized(>->renderer)) { glw_renderer_init(>->renderer, 16, 12, surfaces); for(i = 0; i < 16; i++) { glw_renderer_vtx_pos(>->renderer, i, pinvtx(i & 7)); if(i < 8) glw_renderer_vtx_col(>->renderer, i, 1,1,1,1); else glw_renderer_vtx_col(>->renderer, i, 0.25, 0.25, 0.25, 1); } } rc0 = *rc; glw_scale_to_aspect(&rc0, 1.0); glw_blendmode(gr, GLW_BLEND_ADDITIVE); #define NUMPINS 15 for(i = 1; i < NUMPINS; i++) { float alpha = (1 - ((float)i / NUMPINS)) * rc->rc_alpha * w->glw_alpha; rc1 = rc0; glw_Rotatef(&rc1, 0.1 * gt->angle - i * ((360 / NUMPINS) / 3), 0, 1, 0); glw_Rotatef(&rc1, gt->angle - i * (360 / NUMPINS), 0, 0, 1); glw_renderer_draw(>->renderer, gr, &rc1, NULL, NULL, NULL, alpha, 0, NULL); } glw_blendmode(gr, GLW_BLEND_NORMAL); }
static void glw_bar_render(glw_t *w, const glw_rctx_t *rc) { glw_bar_t *gb = (void *)w; float a = rc->rc_alpha * w->glw_alpha; if(gb->gb_col1[0] < 0.001 && gb->gb_col1[1] < 0.001 && gb->gb_col1[2] < 0.001 && gb->gb_col2[0] < 0.001 && gb->gb_col2[1] < 0.001 && gb->gb_col2[2] < 0.001) { return; } if(a > GLW_ALPHA_EPSILON) { glw_renderer_draw(&gb->gb_gr, w->glw_root, rc, NULL, NULL, NULL, NULL, a, 0, NULL); } }
static void glw_raster_render(glw_t *w, const glw_rctx_t *rc) { glw_raster_t *q = (void *)w; #if 0 printf("RASTER W=%d H=%d\n", rc->rc_width, rc->rc_height); int i; for(i = 0; i < 16; i++) { printf("%f%c", rc->rc_be.gbr_mtx[i], "\t\t\t\n"[i&3]); } #endif if(!glw_is_tex_inited(&q->tex)) glw_tex_upload(w->glw_root, &q->tex, rastermap, GLW_TEXTURE_FORMAT_RGB, RASTER_TILE_SIZE, RASTER_TILE_SIZE, GLW_TEX_REPEAT); if(!glw_renderer_initialized(&q->r)) glw_renderer_init_quad(&q->r); if(q->width != rc->rc_width || q->height != rc->rc_height) { q->width = rc->rc_width; q->height = rc->rc_height; glw_renderer_vtx_pos(&q->r, 0, -1, -1, 0); glw_renderer_vtx_st (&q->r, 0, 0, rc->rc_height / (float)RASTER_TILE_SIZE); glw_renderer_vtx_pos(&q->r, 1, 1, -1, 0); glw_renderer_vtx_st (&q->r, 1, rc->rc_width / (float)RASTER_TILE_SIZE, rc->rc_height / (float)RASTER_TILE_SIZE); glw_renderer_vtx_pos(&q->r, 2, 1, 1, 0); glw_renderer_vtx_st (&q->r, 2, rc->rc_width / (float)RASTER_TILE_SIZE, 0); glw_renderer_vtx_pos(&q->r, 3, -1, 1, 0); glw_renderer_vtx_st (&q->r, 3, 0, 0); } glw_renderer_draw(&q->r, w->glw_root, rc, &q->tex, &q->color, NULL, rc->rc_alpha * w->glw_alpha, 0, NULL); }
static void glw_throbber_render(glw_t *w, const glw_rctx_t *rc) { glw_throbber_t *gt = (glw_throbber_t *)w; glw_rctx_t rc0, rc1; int i; glw_root_t *gr = w->glw_root; float a0 = w->glw_alpha * rc->rc_alpha; int spokes = 16; if(a0 < 0.01) return; if(!glw_renderer_initialized(>->renderer)) { glw_renderer_init_quad(>->renderer); glw_renderer_vtx_pos(>->renderer, 0, -0.05, 0.4, 0); glw_renderer_vtx_pos(>->renderer, 1, 0.05, 0.4, 0); glw_renderer_vtx_pos(>->renderer, 2, 0.05, 1, 0); glw_renderer_vtx_pos(>->renderer, 3, -0.05, 1, 0); } rc0 = *rc; glw_scale_to_aspect(&rc0, 1.0); for(i = 0; i < spokes; i++) { float a = i * 360.0 / 16; float alpha = 1 - (((i + (gt->o / 6)) % spokes) / 16.0); alpha = MAX(alpha, 0.1); rc1 = rc0; glw_Rotatef(&rc1, -gt->angle - a, 0, 0, -1); glw_renderer_draw(>->renderer, gr, &rc1, NULL, >->color, NULL, a0 * alpha, 0, NULL); } }
static void glw_gradient_render(glw_t *w, const glw_rctx_t *rc) { glw_gradient_t *gg = (void *)w; float a = rc->rc_alpha * w->glw_alpha * gg->gg_alpha_self; if(gg->gg_col1[0] < 0.001 && gg->gg_col1[1] < 0.001 && gg->gg_col1[2] < 0.001 && gg->gg_col2[0] < 0.001 && gg->gg_col2[1] < 0.001 && gg->gg_col2[2] < 0.001) { return; } if(a > 0.01) { 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, NULL); } } }
static void glw_fx_texrot_render_internal(glw_root_t *gr, glw_rctx_t *rc, glw_fx_texrot_t *fx, glw_loadable_texture_t *glt) { int i; glw_rctx_t rc0; glw_blendmode(gr, GLW_BLEND_ADDITIVE); glw_Scalef(rc, 2.0, 2.0, 1.0); for(i = 0; i < FX_NPLATES; i++) { rc0 = *rc; fx->fx_plates[i].angle += fx->fx_plates[i].inc; glw_Translatef(&rc0, fx->fx_plates[i].x, fx->fx_plates[i].y, 0.0); 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); } glw_blendmode(gr, GLW_BLEND_NORMAL); }
static void glw_image_render(glw_t *w, const glw_rctx_t *rc) { glw_image_t *gi = (void *)w; const glw_loadable_texture_t *glt = gi->gi_current; float alpha_self; float blur = 1 - (rc->rc_sharpness * w->glw_sharpness); glw_rctx_t rc0; alpha_self = rc->rc_alpha * w->glw_alpha * gi->gi_alpha_self * gi->gi_autofade; if(gi->gi_mode == GI_MODE_NORMAL || gi->gi_mode == GI_MODE_ALPHA_EDGES) { if(glt == NULL || !glw_is_tex_inited(&glt->glt_texture)) return; rc0 = *rc; glw_align_1(&rc0, w->glw_alignment); if(gi->gi_bitmap_flags & GLW_IMAGE_FIXED_SIZE) glw_scale_to_pixels(&rc0, glt->glt_xs, glt->glt_ys); else if(w->glw_class == &glw_image || w->glw_class == &glw_icon) glw_scale_to_aspect(&rc0, glt->glt_aspect); if(gi->gi_angle != 0) glw_Rotatef(&rc0, -gi->gi_angle, 0, 0, 1); glw_align_2(&rc0, w->glw_alignment); if(glw_is_focusable(w)) glw_store_matrix(w, &rc0); if(w->glw_class == &glw_frontdrop) render_child_simple(w, &rc0); if(alpha_self > 0.01f) { if(w->glw_flags2 & GLW2_SHADOW && !rc0.rc_inhibit_shadows) { float xd = 6.0f / rc0.rc_width; float yd = -6.0f / rc0.rc_height; glw_Translatef(&rc0, xd, yd, 0.0f); static const glw_rgb_t black = {0,0,0}; glw_renderer_draw(&gi->gi_gr, w->glw_root, &rc0, &glt->glt_texture, &black, NULL, alpha_self * 0.75f, 1); glw_Translatef(&rc0, -xd, -yd, 0.0f); } if(gi->gi_bitmap_flags & GLW_IMAGE_ADDITIVE) glw_blendmode(w->glw_root, GLW_BLEND_ADDITIVE); glw_renderer_draw(&gi->gi_gr, w->glw_root, &rc0, &glt->glt_texture, &gi->gi_col_mul, &gi->gi_col_off, alpha_self, blur); if(gi->gi_bitmap_flags & GLW_IMAGE_ADDITIVE) glw_blendmode(w->glw_root, GLW_BLEND_NORMAL); } if(w->glw_class != &glw_frontdrop) render_child_simple(w, &rc0); } else { if(glw_is_focusable(w)) glw_store_matrix(w, rc); if(w->glw_class == &glw_frontdrop) render_child_autocentered(gi, rc); if(glt && glw_is_tex_inited(&glt->glt_texture) && alpha_self > 0.01f) { if(gi->gi_bitmap_flags & GLW_IMAGE_ADDITIVE) glw_blendmode(w->glw_root, GLW_BLEND_ADDITIVE); glw_renderer_draw(&gi->gi_gr, w->glw_root, rc, &glt->glt_texture, &gi->gi_col_mul, &gi->gi_col_off, alpha_self, blur); if(gi->gi_bitmap_flags & GLW_IMAGE_ADDITIVE) glw_blendmode(w->glw_root, GLW_BLEND_NORMAL); } if(w->glw_class != &glw_frontdrop) render_child_autocentered(gi, rc); } }