void CL_Texture::set_mag_filter(CL_TextureFilter filter) { set_mag_filter_gl(filter_to_gl(filter)); }
void Scale_Op::render(const Image & in) throw (Error) { //DJV_DEBUG("Scale_Op::render"); //DJV_DEBUG_PRINT("in = " << in); //DJV_DEBUG_PRINT("size = " << _value.size); //DJV_DEBUG_PRINT("type = " << _value.type); // Initialize. Pixel_Data_Info info = in.info(); begin(); if (DEFAULT == _value.type) { _texture.init( info, filter_to_gl(_value.default_min), filter_to_gl(_value.default_mag)); const State_Default state(_value); if (_state_default != state) { //DJV_DEBUG_PRINT("init"); _render.shader.init(src_default); _state_default = state; } } else { _texture.init(info); _render.texture_tmp.init( Pixel_Data_Info(V2i(_value.size.x, in.h()), info.pixel)); const State_Custom state(_value); if (_state_custom != state) { //DJV_DEBUG_PRINT("init"); _render.offscreen.init(); Pixel_Data contrib; contrib_fnc( in.w(), _value.size.x, _value.custom_min, _value.custom_mag, &contrib); _render.contrib_x.init(contrib); _render.shader_x.init(String_Format(src_custom). arg(contrib.h()). arg(src_x)); contrib_fnc( in.h(), _value.size.y, _value.custom_min, _value.custom_mag, &contrib); _render.contrib_y.init(contrib); _render.shader_y.init(String_Format(src_custom). arg(contrib.h()). arg(src_y)); _state_custom = state; } } // Render. if (DEFAULT == _value.type) { _render.shader.bind(); const GLuint program = _render.shader.program(); glUniform2f(glGetUniformLocation(program, "scale_input"), static_cast<GLfloat>(in.w()), static_cast<GLfloat>(in.h())); glUniform2f(glGetUniformLocation(program, "scale_output"), static_cast<GLfloat>(_value.size.x), static_cast<GLfloat>(_value.size.y)); glActiveTexture(GL_TEXTURE0); glUniform1i(glGetUniformLocation(program, "texture"), 0); _texture.bind(); _texture.copy(in); info = in.info(); info.size = _value.size; Gl_Util::ortho(_value.size); glViewport(0, 0, _value.size.x, _value.size.y); glClear(GL_COLOR_BUFFER_BIT); Util::quad(info); } else { // Horizontal. _render.offscreen.bind(); _render.offscreen.set(_render.texture_tmp); _render.shader_x.bind(); glActiveTexture(GL_TEXTURE0); glUniform1i( glGetUniformLocation(_render.shader_x.program(), "texture"), 0); _texture.bind(); _texture.copy(in); glActiveTexture(GL_TEXTURE1); glUniform1i( glGetUniformLocation(_render.shader_x.program(), "contrib"), 1); _render.contrib_x.bind(); info = in.info(); info.size.x = _value.size.x; Gl_Util::ortho(info.size); glViewport(0, 0, info.size.x, info.size.y); glClear(GL_COLOR_BUFFER_BIT); Util::quad(info); _render.offscreen.unbind(); // Vertical. _render.shader_y.bind(); glActiveTexture(GL_TEXTURE0); glUniform1i( glGetUniformLocation(_render.shader_y.program(), "texture"), 0); _render.texture_tmp.bind(); glActiveTexture(GL_TEXTURE1); glUniform1i( glGetUniformLocation(_render.shader_y.program(), "contrib"), 1); _render.contrib_y.bind(); Gl_Util::ortho(_value.size); glViewport(0, 0, _value.size.x, _value.size.y); glClear(GL_COLOR_BUFFER_BIT); Util::quad(Pixel_Data_Info(_value.size, in.pixel())); } end(); }