fix android view resize on keyboard, also allow all device orientations

This commit is contained in:
2019-01-29 16:35:23 +01:00
parent 58502a2457
commit b1d5bdbb8c
7 changed files with 105 additions and 31 deletions

View File

@@ -97,7 +97,7 @@ bool App::request_close()
void App::clear()
{
glClearColor(.1f, .1f, .1f, 1.f);
glViewport(0, 0, (GLsizei)width, (GLsizei)height);
glViewport(off_x, off_y, (GLsizei)width, (GLsizei)height);
glClear(GL_COLOR_BUFFER_BIT);
}
@@ -500,12 +500,13 @@ void App::update(float dt)
//auto box = n->m_clip;
//glm::ivec4 c = glm::vec4((int)box.x - 1, (int)(height / zoom - box.y - box.w) - 1, (int)box.z + 2, (int)box.w + 2) * zoom;
glm::ivec4 c = glm::vec4((int)box.x, (int)(height / zoom - box.y - box.w), (int)box.z, (int)box.w) * zoom;
glScissor(c.x, c.y, c.z, c.w);
glScissor(c.x + off_x, c.y + off_y, c.z, c.w);
n->draw();
return true;
}
return false;
};
/*
uirtt.bindFramebuffer();
uirtt.clear();
glEnable(GL_SCISSOR_TEST);
@@ -514,7 +515,7 @@ void App::update(float dt)
//msgbox->watch(observer);
glDisable(GL_SCISSOR_TEST);
uirtt.unbindFramebuffer();
*/
#if __IOS__
[ios_view->glview bindDrawable];
#else

View File

@@ -79,6 +79,8 @@ public:
std::string doc_filename;
bool has_stylus = false;
bool has_vr = false;
float off_x = 0;
float off_y = 0;
float width;
float height;
bool keys[256];

View File

@@ -70,7 +70,7 @@ void NodeCanvas::draw()
glm::ivec4 c = (glm::ivec4)glm::vec4(box.x, (int)(vp[3] - box.y - box.w), box.z, box.w);
glClearColor(1, 1, 1, 0);
glClear(GL_COLOR_BUFFER_BIT);
glViewport(c.x, c.y, c.z, c.w);
glViewport(c.x + App::I.off_x, c.y + App::I.off_y, c.z, c.w);
//m_canvas->m_cam_rot = m_pan * 0.003f;

View File

@@ -2,6 +2,7 @@
#include "log.h"
#include "node_viewport.h"
#include "shader.h"
#include "app.h"
void NodeViewport::draw()
{
@@ -17,7 +18,7 @@ void NodeViewport::draw()
glClear(GL_COLOR_BUFFER_BIT);
auto box = m_clip * root()->m_zoom;
glm::ivec4 c = (glm::ivec4)glm::vec4(box.x, (int)(vp[3] - box.y - box.w), box.z, box.w);
glViewport(c.x, c.y, c.z, c.w);
glViewport(c.x + App::I.off_x, c.y + App::I.off_y, c.z, c.w);
TextureManager::get(m_tex_id).bind();
m_sampler->bind(0);
glEnable(GL_BLEND);