diff --git a/engine/canvas.cpp b/engine/canvas.cpp index 2124a7e..98e4e1a 100644 --- a/engine/canvas.cpp +++ b/engine/canvas.cpp @@ -705,9 +705,9 @@ bool ui::Canvas::create(int width, int height) m_tex[i].create(width, height); m_tex2[i].create(width, height); // TODO: destroy before recreating } - m_sampler.create(); - m_sampler_bg.create(); - m_sampler_mask.create(); + m_sampler.create(GL_NEAREST); + m_sampler_bg.create(GL_NEAREST); + m_sampler_mask.create(GL_NEAREST); m_plane.create<1>(1, 1); m_plane_brush.create<1>(1, 1); m_mesh.create(); @@ -781,36 +781,27 @@ void ui::Canvas::export_equirectangular(std::string data_path) GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, // top GL_TEXTURE_CUBE_MAP_POSITIVE_Y, // bottom }; + + ShaderManager::use(ui::kShader::TextureAlpha); + ShaderManager::u_int(kShaderUniform::Highlight, false); + ShaderManager::u_int(kShaderUniform::Tex, 0); + ShaderManager::u_mat4(kShaderUniform::MVP, glm::ortho(-.5f, .5f, -.5f, .5f, -1.f, 1.f)); + for (int i = 0; i < 6; i++) { m_tmp[i].bindFramebuffer(); m_tmp[i].clear({ 1, 1, 1, 1 }); + glActiveTexture(GL_TEXTURE0); // TODO: maybe remove this line + m_sampler.bind(0); for (auto layer_index : m_order) { - // copy to tmp2 for layer blending - glActiveTexture(GL_TEXTURE0); // TODO: maybe remove this line -// m_tex2[i].bind(); -// glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, m_width, m_height); -// m_tex2[i].unbind(); - - m_layers[layer_index].m_rtt[i].bindTexture(); - glActiveTexture(GL_TEXTURE1); - m_tex2[i].bind(); - m_sampler.bind(0); - m_sampler_bg.bind(1); - ShaderManager::use(ui::kShader::TextureAlpha); - //ShaderManager::u_int(kShaderUniform::TexBG, 1); ShaderManager::u_float(kShaderUniform::Alpha, m_layers[layer_index].m_opacity); - ShaderManager::u_int(kShaderUniform::Highlight, false); - ShaderManager::u_int(kShaderUniform::Tex, 0); - ShaderManager::u_mat4(kShaderUniform::MVP, glm::ortho(-.5f, .5f, -.5f, .5f, -1.f, 1.f)); + m_layers[layer_index].m_rtt[i].bindTexture(); m_plane.draw_fill(); - m_sampler.unbind(); - m_sampler_bg.unbind(); - m_tex2[i].unbind(); m_layers[layer_index].m_rtt[i].unbindTexture(); } + m_sampler.unbind(); // copy result to cubemap glBindTexture(GL_TEXTURE_CUBE_MAP, cube_id);