int
glw_opengl_shaders_init(glw_root_t *gr)
{
  glw_backend_root_t *gbr = &gr->gr_be;

  GLuint vs, fs;

  vs = glw_compile_shader("bundle://src/ui/glw/glsl/v1.glsl",
			  GL_VERTEX_SHADER);

  fs = glw_compile_shader("bundle://src/ui/glw/glsl/f_tex.glsl",
			  GL_FRAGMENT_SHADER);
  gbr->gbr_renderer_tex = glw_make_program(gbr, "Texture", vs, fs);
  glDeleteShader(fs);

  fs = glw_compile_shader("bundle://src/ui/glw/glsl/f_tex_blur.glsl",
			  GL_FRAGMENT_SHADER);
  gbr->gbr_renderer_tex_blur = glw_make_program(gbr, "Texture", vs, fs);
  glDeleteShader(fs);

  fs = glw_compile_shader("bundle://src/ui/glw/glsl/f_flat.glsl",
			  GL_FRAGMENT_SHADER);
  gbr->gbr_renderer_flat = glw_make_program(gbr, "Flat", vs, fs);
  glDeleteShader(fs);

  glDeleteShader(vs);

  //    gbr->gbr_renderer_draw = glw_renderer_shader;


  // Video renderer

  vs = glw_compile_shader("bundle://src/ui/glw/glsl/yuv2rgb_v.glsl",
			  GL_VERTEX_SHADER);


  fs = glw_compile_shader("bundle://src/ui/glw/glsl/yuv2rgb_1f_norm.glsl",
			  GL_FRAGMENT_SHADER);
  gbr->gbr_yuv2rgb_1f = glw_make_program(gbr, "yuv2rgb_1f_norm", vs, fs);
  glDeleteShader(fs);

  fs = glw_compile_shader("bundle://src/ui/glw/glsl/yuv2rgb_2f_norm.glsl",
			  GL_FRAGMENT_SHADER);
  gbr->gbr_yuv2rgb_2f = glw_make_program(gbr, "yuv2rgb_2f_norm", vs, fs);
  glDeleteShader(fs);

  glDeleteShader(vs);

  gr->gr_render = shader_render;

  prop_set_string(prop_create(gr->gr_uii.uii_prop, "rendermode"),
		  "OpenGL VP/FP shaders");
  return 0;
}
Exemple #2
0
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);
}