fix grid bounds calculation issue with float framebuffer
This commit is contained in:
@@ -2221,6 +2221,12 @@ void Canvas::draw_objects(std::function<void(const glm::mat4& camera, const glm:
|
||||
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT24, layer.w, layer.h);
|
||||
glBindRenderbuffer(GL_RENDERBUFFER, 0);
|
||||
|
||||
RTT rtt;
|
||||
rtt.create(layer.w, layer.h);
|
||||
rtt.bindFramebuffer();
|
||||
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, rboID);
|
||||
rtt.unbindFramebuffer();
|
||||
|
||||
// allocate action to add to history
|
||||
auto action = new ActionStroke;
|
||||
action->was_saved = !m_unsaved;
|
||||
@@ -2229,14 +2235,12 @@ void Canvas::draw_objects(std::function<void(const glm::mat4& camera, const glm:
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
glm::mat4 plane_camera = glm::lookAt(glm::vec3(0), m_plane_origin[i], m_plane_tangent[i]);
|
||||
m_tmp[i].bindFramebuffer();
|
||||
m_tmp[i].clear({ 1, 1, 1, 0 });
|
||||
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, rboID);
|
||||
rtt.bindFramebuffer();
|
||||
rtt.clear({ 1, 1, 1, 0 });
|
||||
observer(plane_camera, proj, i);
|
||||
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, 0);
|
||||
m_tmp[i].unbindFramebuffer();
|
||||
rtt.unbindFramebuffer();
|
||||
|
||||
glm::vec4 bounds = m_tmp[i].calc_bounds();
|
||||
glm::vec4 bounds = rtt.calc_bounds();
|
||||
|
||||
layer.m_rtt[i].bindFramebuffer();
|
||||
|
||||
@@ -2246,9 +2250,9 @@ void Canvas::draw_objects(std::function<void(const glm::mat4& camera, const glm:
|
||||
{
|
||||
action->m_image[i] = std::make_unique<uint8_t[]>(box_sz.x * box_sz.y * 4);
|
||||
glReadPixels(bounds.x, bounds.y, box_sz.x, box_sz.y, GL_RGBA, GL_UNSIGNED_BYTE, action->m_image[i].get());
|
||||
action->m_box[i] = bounds;
|
||||
}
|
||||
|
||||
action->m_box[i] = bounds;
|
||||
action->m_old_box[i] = layer.m_dirty_box[i];
|
||||
action->m_old_dirty[i] = layer.m_dirty_face[i];
|
||||
|
||||
@@ -2258,9 +2262,9 @@ void Canvas::draw_objects(std::function<void(const glm::mat4& camera, const glm:
|
||||
ShaderManager::u_mat4(kShaderUniform::MVP, glm::ortho(-0.5f, 0.5f, -0.5f, 0.5f));
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
m_sampler_nearest.bind(0);
|
||||
m_tmp[i].bindTexture();
|
||||
rtt.bindTexture();
|
||||
m_plane.draw_fill();
|
||||
m_tmp[i].unbindTexture();
|
||||
rtt.unbindTexture();
|
||||
|
||||
layer.m_rtt[i].unbindFramebuffer();
|
||||
|
||||
@@ -2275,6 +2279,7 @@ void Canvas::draw_objects(std::function<void(const glm::mat4& camera, const glm:
|
||||
ActionManager::add(action);
|
||||
|
||||
glDeleteRenderbuffers(1, &rboID);
|
||||
rtt.destroy();
|
||||
|
||||
// restore viewport and clear color states
|
||||
blend ? glEnable(GL_BLEND) : glDisable(GL_BLEND);
|
||||
|
||||
Reference in New Issue
Block a user