glw_program_t * glw_make_program(glw_root_t *gr, const char *vertex_shader, const char *fragment_shader) { GLuint vs, fs; char path[512]; glw_program_t *p; SHADERPATH("v1.glsl"); vs = glw_compile_shader(vertex_shader ?: path, GL_VERTEX_SHADER, gr); if(vs == 0) return NULL; fs = glw_compile_shader(fragment_shader, GL_FRAGMENT_SHADER, gr); if(fs == 0) { glDeleteShader(vs); return NULL; } p = glw_link_program(&gr->gr_be, "user shader", vs, fs); glDeleteShader(vs); glDeleteShader(fs); return p; }
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; }
int glw_opengl_shaders_init(glw_root_t *gr, int delayed) { glw_backend_root_t *gbr = &gr->gr_be; char path[512]; GLuint vs, fs; SHADERPATH("v1.glsl"); vs = glw_compile_shader(path, GL_VERTEX_SHADER, gr); SHADERPATH("f_tex.glsl"); fs = glw_compile_shader(path, GL_FRAGMENT_SHADER, gr); gbr->gbr_renderer_tex = glw_link_program(gbr, "Texture", vs, fs); glDeleteShader(fs); SHADERPATH("f_tex_simple.glsl"); fs = glw_compile_shader(path, GL_FRAGMENT_SHADER, gr); gbr->gbr_renderer_tex_simple = glw_link_program(gbr, "TextureSimple", vs, fs); glDeleteShader(fs); SHADERPATH("f_tex_stencil.glsl"); fs = glw_compile_shader(path, GL_FRAGMENT_SHADER, gr); gbr->gbr_renderer_tex_stencil = glw_link_program(gbr, "TextureStencil", vs, fs); glDeleteShader(fs); SHADERPATH("f_tex_blur.glsl"); fs = glw_compile_shader(path, GL_FRAGMENT_SHADER, gr); gbr->gbr_renderer_tex_blur = glw_link_program(gbr, "TextureBlur", vs, fs); glDeleteShader(fs); SHADERPATH("f_tex_stencil_blur.glsl"); fs = glw_compile_shader(path, GL_FRAGMENT_SHADER, gr); gbr->gbr_renderer_tex_stencil_blur = glw_link_program(gbr, "TextureStencilBlur", vs, fs); glDeleteShader(fs); SHADERPATH("f_flat.glsl"); fs = glw_compile_shader(path, GL_FRAGMENT_SHADER, gr); gbr->gbr_renderer_flat = glw_link_program(gbr, "Flat", vs, fs); glDeleteShader(fs); SHADERPATH("f_flat_stencil.glsl"); fs = glw_compile_shader(path, GL_FRAGMENT_SHADER, gr); gbr->gbr_renderer_flat_stencil = glw_link_program(gbr, "FlatStencil", vs, fs); glDeleteShader(fs); glDeleteShader(vs); // gbr->gbr_renderer_draw = glw_renderer_shader; // yuv2rgb Video renderer SHADERPATH("yuv2rgb_v.glsl"); vs = glw_compile_shader(path, GL_VERTEX_SHADER, gr); SHADERPATH("yuv2rgb_1f_norm.glsl"); fs = glw_compile_shader(path, GL_FRAGMENT_SHADER, gr); gbr->gbr_yuv2rgb_1f = glw_link_program(gbr, "yuv2rgb_1f_norm", vs, fs); glDeleteShader(fs); SHADERPATH("yuv2rgb_2f_norm.glsl"); fs = glw_compile_shader(path, GL_FRAGMENT_SHADER, gr); gbr->gbr_yuv2rgb_2f = glw_link_program(gbr, "yuv2rgb_2f_norm", vs, fs); glDeleteShader(fs); glDeleteShader(vs); // rgb2rgb Video renderer SHADERPATH("rgb2rgb_v.glsl"); vs = glw_compile_shader(path, GL_VERTEX_SHADER, gr); SHADERPATH("rgb2rgb_1f_norm.glsl"); fs = glw_compile_shader(path, GL_FRAGMENT_SHADER, gr); gbr->gbr_rgb2rgb_1f = glw_link_program(gbr, "rgb2rgb_1f_norm", vs, fs); glDeleteShader(fs); SHADERPATH("rgb2rgb_2f_norm.glsl"); fs = glw_compile_shader(path, GL_FRAGMENT_SHADER, gr); gbr->gbr_rgb2rgb_2f = glw_link_program(gbr, "rgb2rgb_2f_norm", vs, fs); glDeleteShader(fs); glDeleteShader(vs); gr->gr_be_render_unlocked = render_unlocked; glGenBuffers(1, &gbr->gbr_vbo); glEnableVertexAttribArray(0); glEnableVertexAttribArray(1); glEnableVertexAttribArray(2); prop_set_string(prop_create(gr->gr_prop_ui, "rendermode"), "OpenGL VP/FP shaders"); #if ENABLE_GLW_BACKEND_OPENGL glMatrixMode(GL_PROJECTION); glLoadMatrixf(projection); glMatrixMode(GL_MODELVIEW); #endif return 0; }
int glw_opengl_shaders_init(glw_root_t *gr, int delayed) { glw_backend_root_t *gbr = &gr->gr_be; char path[512]; GLuint vs, fs; SHADERPATH("v1.glsl"); vs = glw_compile_shader(path, GL_VERTEX_SHADER, gr); SHADERPATH("f_tex.glsl"); fs = glw_compile_shader(path, GL_FRAGMENT_SHADER, gr); gbr->gbr_renderer_tex = glw_link_program(gbr, "Texture", vs, fs); glDeleteShader(fs); SHADERPATH("f_tex_simple.glsl"); fs = glw_compile_shader(path, GL_FRAGMENT_SHADER, gr); gbr->gbr_renderer_tex_simple = glw_link_program(gbr, "TextureSimple", vs, fs); glDeleteShader(fs); SHADERPATH("f_tex_stencil.glsl"); fs = glw_compile_shader(path, GL_FRAGMENT_SHADER, gr); gbr->gbr_renderer_tex_stencil = glw_link_program(gbr, "TextureStencil", vs, fs); glDeleteShader(fs); SHADERPATH("f_tex_blur.glsl"); fs = glw_compile_shader(path, GL_FRAGMENT_SHADER, gr); gbr->gbr_renderer_tex_blur = glw_link_program(gbr, "TextureBlur", vs, fs); glDeleteShader(fs); SHADERPATH("f_tex_stencil_blur.glsl"); fs = glw_compile_shader(path, GL_FRAGMENT_SHADER, gr); gbr->gbr_renderer_tex_stencil_blur = glw_link_program(gbr, "TextureStencilBlur", vs, fs); glDeleteShader(fs); SHADERPATH("f_flat.glsl"); fs = glw_compile_shader(path, GL_FRAGMENT_SHADER, gr); gbr->gbr_renderer_flat = glw_link_program(gbr, "Flat", vs, fs); glDeleteShader(fs); SHADERPATH("f_flat_stencil.glsl"); fs = glw_compile_shader(path, GL_FRAGMENT_SHADER, gr); gbr->gbr_renderer_flat_stencil = glw_link_program(gbr, "FlatStencil", vs, fs); glDeleteShader(fs); glDeleteShader(vs); // gbr->gbr_renderer_draw = glw_renderer_shader; // Video renderer SHADERPATH("yuv2rgb_v.glsl"); vs = glw_compile_shader(path, GL_VERTEX_SHADER, gr); SHADERPATH("yuv2rgb_1f_norm.glsl"); fs = glw_compile_shader(path, GL_FRAGMENT_SHADER, gr); gbr->gbr_yuv2rgb_1f = glw_link_program(gbr, "yuv2rgb_1f_norm", vs, fs); glDeleteShader(fs); SHADERPATH("yuv2rgb_2f_norm.glsl"); fs = glw_compile_shader(path, GL_FRAGMENT_SHADER, gr); gbr->gbr_yuv2rgb_2f = glw_link_program(gbr, "yuv2rgb_2f_norm", vs, fs); glDeleteShader(fs); glDeleteShader(vs); if(!delayed) { gr->gr_render = shader_render; } else { gr->gr_render = shader_render_delayed; gr->gr_be_prepare = prepare_delayed; gr->gr_be_render_unlocked = render_unlocked; gbr->gbr_delayed_rendering = 1; glGenBuffers(1, &gbr->gbr_vbo); } glEnableVertexAttribArray(0); glEnableVertexAttribArray(1); glEnableVertexAttribArray(2); prop_set_string(prop_create(gr->gr_prop_ui, "rendermode"), "OpenGL VP/FP shaders"); return 0; }