added render target and bezier classes, added stroke settings panel

This commit is contained in:
2017-03-24 03:15:29 +00:00
parent 03a5212e56
commit a2cb0ecafe
16 changed files with 798 additions and 67 deletions

View File

@@ -5,14 +5,6 @@ using namespace ui;
App App::I; // singleton
#ifdef __APPLE__
#define SHADER_VERSION "#version 300 es\n"
#elif __ANDROID__
#define SHADER_VERSION "#version 300 es\n"
#elif _WIN32
#define SHADER_VERSION "#version 150\n"
#endif
void App::create()
{
width = 800;
@@ -192,15 +184,30 @@ void App::initLayout()
NodeBorder::static_init();
NodeImage::static_init();
NodeIcon::static_init();
NodeCanvas2D::static_init();
layout.on_loaded = [&] {
LOG("initializing layout updating after load");
layout[main_id]->update(width, height, zoom);
LOG("initializing layout components");
sidebar = layout[main_id]->find<NodeBorder>("sidebar");
brushes = layout[main_id]->find<NodePanelBrushes>("panel-brushes");
layers = layout[main_id]->find<NodePanelLayers>("panel-layers");
brushes = layout[main_id]->find<NodePanelBrush>("panel-brush");
layers = layout[main_id]->find<NodePanelLayer>("panel-layer");
color = layout[main_id]->find<NodePanelColor>("panel-color");
stroke = layout[main_id]->find<NodePanelStroke>("panel-stroke");
brushes->on_brush_changed = [this](Node* target, int index) {
auto tid = brushes->get_texture_id(index);
stroke->m_canvas->m_tex_id = tid;
stroke->m_canvas->draw_stroke();
};
color->on_color_changed = [this](Node* target, glm::vec4 color) {
stroke->m_canvas->m_tip_color = color;
stroke->m_canvas->draw_stroke();
};
if (auto* button = layout[main_id]->find<NodeButton>("btn-close"))
{
button->on_click = [](Node*) { exit(0); };
@@ -271,7 +278,8 @@ void App::initLayout()
};
LOG("initializing layout xml");
#ifdef _WIN32
layout.load("C:\\Users\\omar\\Desktop\\new_engine\\data\\layout.xml");
//layout.load("C:\\Users\\omar\\Desktop\\new_engine\\data\\layout.xml");
layout.load("data/layout.xml");
#else
layout.load("data/layout.xml");
#endif
@@ -307,8 +315,6 @@ void App::init()
glEnable(GL_TEXTURE_2D);
glDisable(GL_DEPTH_TEST);
//glPointSize(5);
glLineWidth(2);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glBlendEquation(GL_FUNC_ADD);
@@ -336,16 +342,16 @@ void App::update(float dt)
//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)
{
if (n && n->m_display)
{
auto box = n->m_clip;
glm::vec4 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 - 1, (int)(height / zoom - box.y - box.w) - 1, (int)box.z + 2, (int)box.w + 2) * zoom;
glScissor(c.x, c.y, c.z, c.w);
n->draw();
}