fix export blending issue (just disabled blend in equirectangular drawing), and cleanup a bit

This commit is contained in:
2017-08-20 21:46:06 +01:00
parent cc146784c1
commit 1877f1013d
4 changed files with 31 additions and 38 deletions

View File

@@ -75,33 +75,21 @@ void ui::Canvas::pick_update(int plane)
m_tmp[i].bindFramebuffer();
m_tmp[i].clear({ 1, 1, 1, 1 });
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));
glActiveTexture(GL_TEXTURE0);
m_sampler.bind(0);
for (auto layer_index : m_order)
{
// copy to tmp2 for layer blending
glActiveTexture(GL_TEXTURE0); // TODO: maybe remove this line
// #ifndef __IOS__
// m_tex2[i].bind();
// glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, m_width, m_height);
// m_tex2[i].unbind();
// #endif
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();
if (!m_pick_data[plane])
m_pick_data[plane] = std::make_unique<glm::u8vec4[]>(m_width*m_height);
glReadPixels(0, 0, m_width, m_height, GL_RGBA, GL_UNSIGNED_BYTE, m_pick_data[plane].get());
@@ -811,16 +799,17 @@ void ui::Canvas::export_equirectangular(std::string data_path)
m_tmp[i].unbindFramebuffer();
}
// auto data = std::make_unique<uint8_t[]>(m_tmp[0].bytes());
// for (int i = 0; i < 6; i++)
// {
// m_tmp[i].readTextureData(data.get());
// static char name[128];
// sprintf(name, "%s/Face%d.png", data_path.c_str(), i);
// LOG("writing %s", name);
// int ret = stbi_write_png(name, m_tmp[i].getWidth(), m_tmp[i].getHeight(), 4, data.get(), m_tmp[i].stride());
// }
//auto data = std::make_unique<uint8_t[]>(m_tmp[0].bytes());
//for (int i = 0; i < 1; i++)
//{
// m_tmp[i].readTextureData(data.get());
// static char name[128];
// sprintf(name, "%s/Face%d.png", data_path.c_str(), i);
// LOG("writing %s", name);
// int ret = stbi_write_png(name, m_tmp[i].getWidth(), m_tmp[i].getHeight(), 4, data.get(), m_tmp[i].stride());
//}
glDisable(GL_BLEND);
glViewport(0, 0, m_latlong.getWidth(), m_latlong.getHeight());
glActiveTexture(GL_TEXTURE0);
m_latlong.bindFramebuffer();