compile for Android, add initial TextInput support
This commit is contained in:
@@ -28,7 +28,7 @@ void App::initShaders()
|
||||
"out vec3 uv;"
|
||||
"void main(){"
|
||||
" uv = vec3(uvs, pos.w);"
|
||||
" gl_Position = mvp * vec4(pos.xyz, 1.f);"
|
||||
" gl_Position = mvp * vec4(pos.xyz, 1.0);"
|
||||
"}";
|
||||
static const char* shader_f =
|
||||
SHADER_VERSION
|
||||
@@ -45,7 +45,7 @@ void App::initShaders()
|
||||
"in vec3 uv;"
|
||||
"out vec4 frag;"
|
||||
"void main(){"
|
||||
" frag = vec4(uv.xy,0,1);"
|
||||
" frag = vec4(uv.xy, 0.0, 1.0);"
|
||||
"}";
|
||||
static const char* shader_atlas_v =
|
||||
SHADER_VERSION
|
||||
@@ -57,7 +57,7 @@ void App::initShaders()
|
||||
"out vec2 uv;"
|
||||
"void main(){"
|
||||
" uv = tof + uvs * tsz;"
|
||||
" gl_Position = mvp * vec4(pos, 0, 1);"
|
||||
" gl_Position = mvp * vec4(pos, 0.0, 1.0);"
|
||||
"}";
|
||||
static const char* shader_atlas_f =
|
||||
SHADER_VERSION
|
||||
@@ -97,8 +97,8 @@ void App::initShaders()
|
||||
"in vec3 uv;"
|
||||
"out vec4 frag;"
|
||||
"void main(){"
|
||||
" vec4 gradient_x = mix(col, vec4(1, 1, 1, 1), uv.x);"
|
||||
" frag = mix(gradient_x, vec4(0, 0, 0, 1), uv.y);"
|
||||
" vec4 gradient_x = mix(col, vec4(1.0, 1.0, 1.0, 1.0), uv.x);"
|
||||
" frag = mix(gradient_x, vec4(0.0, 0.0, 0.0, 1.0), uv.y);"
|
||||
"}";
|
||||
static const char* shader_color_hue_v =
|
||||
SHADER_VERSION
|
||||
@@ -121,7 +121,7 @@ void App::initShaders()
|
||||
" return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);"
|
||||
"}"
|
||||
"void main(){"
|
||||
" frag = vec4(hsv2rgb(vec3(uv.y, 1, 1)), 1);"
|
||||
" frag = vec4(hsv2rgb(vec3(uv.y, 1.0, 1.0)), 1.0);"
|
||||
"}";
|
||||
static const char* shader_font_v =
|
||||
SHADER_VERSION
|
||||
@@ -131,7 +131,7 @@ void App::initShaders()
|
||||
"out vec2 uv;"
|
||||
"void main(){"
|
||||
" uv = uvs;"
|
||||
" gl_Position = mvp * vec4(pos, 0, 1);"
|
||||
" gl_Position = mvp * vec4(pos, 0.0, 1.0);"
|
||||
"}";
|
||||
static const char* shader_font_f =
|
||||
SHADER_VERSION
|
||||
@@ -201,11 +201,20 @@ void App::initLayout()
|
||||
auto tid = brushes->get_texture_id(index);
|
||||
stroke->m_canvas->m_tex_id = tid;
|
||||
stroke->m_canvas->draw_stroke();
|
||||
if (on_brush_select)
|
||||
on_brush_select(index);
|
||||
};
|
||||
|
||||
color->on_color_changed = [this](Node* target, glm::vec4 color) {
|
||||
stroke->m_canvas->m_tip_color = color;
|
||||
stroke->m_canvas->draw_stroke();
|
||||
if (on_color_change)
|
||||
on_color_change(color);
|
||||
};
|
||||
|
||||
stroke->on_stroke_change = [this](Node*target) {
|
||||
if (on_stroke_change)
|
||||
on_stroke_change();
|
||||
};
|
||||
|
||||
if (auto* button = layout[main_id]->find<NodeButton>("btn-close"))
|
||||
@@ -338,13 +347,13 @@ void App::init()
|
||||
|
||||
void App::update(float dt)
|
||||
{
|
||||
//glClearColor(.1f, .1f, .1f, 1.f);
|
||||
//glViewport(0, 0, (GLsizei)width, (GLsizei)height);
|
||||
//glClear(GL_COLOR_BUFFER_BIT);
|
||||
glClearColor(.1f, .1f, .1f, 1.f);
|
||||
glViewport(0, 0, (GLsizei)width, (GLsizei)height);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
// layout.reload();
|
||||
// if (auto* main = layout[main_id])
|
||||
// main->update(width, height, zoom);
|
||||
//layout.reload();
|
||||
if (auto* main = layout[main_id])
|
||||
main->update(width, height, zoom);
|
||||
|
||||
auto observer = [this](Node* n)
|
||||
{
|
||||
@@ -412,5 +421,36 @@ bool App::mouse_up(int button, float x, float y)
|
||||
e.m_pos = { x / zoom, y / zoom };
|
||||
auto ret = layout[main_id]->on_event(&e);
|
||||
layout[main_id]->update();
|
||||
LOG("mouse up button%d pos %f %f\n", button, x, y);
|
||||
return ret == kEventResult::Consumed;
|
||||
}
|
||||
bool App::key_down(int key)
|
||||
{
|
||||
KeyEvent e;
|
||||
e.m_type = kEventType::KeyDown;
|
||||
e.m_key = key;
|
||||
auto ret = layout[main_id]->on_event(&e);
|
||||
layout[main_id]->update();
|
||||
LOG("key down %d '%c'", key, key);
|
||||
return ret == kEventResult::Consumed;
|
||||
}
|
||||
bool App::key_up(int key)
|
||||
{
|
||||
KeyEvent e;
|
||||
e.m_type = kEventType::KeyUp;
|
||||
e.m_key = key;
|
||||
auto ret = layout[main_id]->on_event(&e);
|
||||
layout[main_id]->update();
|
||||
LOG("key up %d '%c'", key, key);
|
||||
return ret == kEventResult::Consumed;
|
||||
}
|
||||
bool App::key_char(int key)
|
||||
{
|
||||
KeyEvent e;
|
||||
e.m_type = kEventType::KeyChar;
|
||||
e.m_key = key;
|
||||
auto ret = layout[main_id]->on_event(&e);
|
||||
layout[main_id]->update();
|
||||
LOG("key up %d '%c'", key, key);
|
||||
return ret == kEventResult::Consumed;
|
||||
}
|
||||
Reference in New Issue
Block a user