From a3f3ff9c922534bf0937033bd58ae9603dceb3cb Mon Sep 17 00:00:00 2001 From: brunoherbelin Date: Tue, 2 Jun 2020 23:12:10 +0200 Subject: [PATCH] Fixed for OSX. --- Decorations.cpp | 4 ++-- Primitives.cpp | 14 +++++++++++--- RenderingManager.cpp | 15 ++++++++++++--- RenderingManager.h | 3 +++ Scene.cpp | 6 ++++-- SearchVisitor.cpp | 5 ++++- Source.cpp | 3 +++ UserInterfaceManager.cpp | 7 +++++-- View.cpp | 1 + main.cpp | 3 +++ 10 files changed, 48 insertions(+), 13 deletions(-) diff --git a/Decorations.cpp b/Decorations.cpp index 4830e4b..de8329d 100644 --- a/Decorations.cpp +++ b/Decorations.cpp @@ -13,11 +13,11 @@ Frame::Frame(Type type) : Node(), type_(type), side_(nullptr), top_(nullptr), sh color = glm::vec4( 1.f, 1.f, 1.f, 1.f); switch (type) { case SHARP_LARGE: - square_ = new LineSquare(color, 2.f ); + square_ = new LineSquare(color, 3 ); shadow_ = new Mesh("mesh/shadow.ply", "images/shadow.png"); break; case SHARP_THIN: - square_ = new LineSquare(color, 2.f ); + square_ = new LineSquare(color, 3 ); break; case ROUND_LARGE: side_ = new Mesh("mesh/border_large_round.ply"); diff --git a/Primitives.cpp b/Primitives.cpp index a76b754..0e278db 100644 --- a/Primitives.cpp +++ b/Primitives.cpp @@ -250,11 +250,19 @@ void LineStrip::draw(glm::mat4 modelview, glm::mat4 projection) if ( !initialized() ) init(); - glLineWidth(linewidth_ * Rendering::manager().mainWindow().dpiScale()); + // glLineWidth(linewidth_ * 2.f * Rendering::manager().mainWindow().dpiScale()); - Primitive::draw(modelview, projection); + glm::mat4 mv = modelview; + glm::mat4 scale = glm::scale(glm::identity(), glm::vec3(1.001f, 1.001f, 1.f)); - glLineWidth(1); + for (uint i = 0 ; i < linewidth_ ; ++i ) { + Primitive::draw(mv, projection); + mv *= scale; + } + + + + // glLineWidth(1); } void LineStrip::accept(Visitor& v) diff --git a/RenderingManager.cpp b/RenderingManager.cpp index 41927b1..b84c8cb 100644 --- a/RenderingManager.cpp +++ b/RenderingManager.cpp @@ -176,13 +176,20 @@ bool Rendering::init() glfwSetKeyCallback( output_.window(), WindowEscapeFullscreen); glfwSetMouseButtonCallback( output_.window(), WindowToggleFullscreen); + return true; +} + + +void Rendering::show() +{ // show output window output_.show(); // show main window main_.show(); - return true; + // show menu on first show + UserInterface::manager().showPannel(); } bool Rendering::isActive() @@ -520,7 +527,8 @@ bool RenderingWindow::init(int id, GLFWwindow *share) // set position glfwSetWindowPos(window_, winset.x, winset.y); // window position and resize callbacks - glfwSetFramebufferSizeCallback( window_, WindowResizeCallback ); + glfwSetWindowSizeCallback( window_, WindowResizeCallback ); +// glfwSetFramebufferSizeCallback( window_, WindowResizeCallback ); glfwSetWindowPosCallback( window_, WindowMoveCallback ); // take opengl context ownership @@ -577,12 +585,13 @@ bool RenderingWindow::init(int id, GLFWwindow *share) void RenderingWindow::show() { + glfwShowWindow(window_); + if ( Settings::application.windows[id_].fullscreen ) { GLFWmonitor *mo = monitorNamed(Settings::application.windows[id_].monitor); setFullscreen(mo); } - glfwShowWindow(window_); } // custom surface with a new VAO diff --git a/RenderingManager.h b/RenderingManager.h index f9689b1..7f04af7 100644 --- a/RenderingManager.h +++ b/RenderingManager.h @@ -94,6 +94,9 @@ public: // Initialization OpenGL and GLFW window creation bool init(); + + void show(); + // true if active rendering window bool isActive(); // draw one frame diff --git a/Scene.cpp b/Scene.cpp index 7d7badd..b2012e3 100644 --- a/Scene.cpp +++ b/Scene.cpp @@ -19,13 +19,15 @@ #include #include +static int global_index_ = 0; // Node Node::Node() : initialized_(false), visible_(true), refcount_(0) { // create unique id - auto duration = std::chrono::system_clock::now().time_since_epoch(); - id_ = std::chrono::duration_cast(duration).count() % 100000000; +// auto duration = std::chrono::high_resolution_clock::now().time_since_epoch(); +// id_ = std::chrono::duration_cast(duration).count() % 100000000; + id_ = global_index_ < INT_MAX ? global_index_++ : 0; transform_ = glm::identity(); scale_ = glm::vec3(1.f); diff --git a/SearchVisitor.cpp b/SearchVisitor.cpp index 6879d3e..881e7e2 100644 --- a/SearchVisitor.cpp +++ b/SearchVisitor.cpp @@ -4,7 +4,10 @@ SearchVisitor::SearchVisitor(Node *node) : Visitor(), node_(node), id_(0), found_(false) { - id_ = node->id(); + if (node != nullptr) + id_ = node->id(); + else + id_ = -1; } SearchVisitor::SearchVisitor(int id) : Visitor(), node_(nullptr), id_(id), found_(false) diff --git a/Source.cpp b/Source.cpp index 3c2822d..46f8c6e 100644 --- a/Source.cpp +++ b/Source.cpp @@ -224,6 +224,9 @@ FrameBuffer *Source::frame() const bool Source::contains(Node *node) const { + if ( node == nullptr ) + return false; + hasNode tester(node); return tester(this); } diff --git a/UserInterfaceManager.cpp b/UserInterfaceManager.cpp index 27a348a..4808620 100644 --- a/UserInterfaceManager.cpp +++ b/UserInterfaceManager.cpp @@ -901,10 +901,13 @@ void UserInterface::RenderShaderEditor() } - void UserInterface::showPannel() { - navigator.showPannelSource(Mixer::manager().indexCurrentSource()); + int s = Mixer::manager().indexCurrentSource(); + if (s > -1) + navigator.showPannelSource(s); + else + navigator.togglePannelMenu(); } Navigator::Navigator() diff --git a/View.cpp b/View.cpp index bb6a16c..d58df30 100644 --- a/View.cpp +++ b/View.cpp @@ -106,6 +106,7 @@ MixingView::MixingView() : View(MIXING) // no settings found: store application default Settings::application.views[mode_].name = "Mixing"; scene.root()->scale_ = glm::vec3(2.4f, 2.4f, 1.0f); + scene.root()->translation_ = glm::vec3(1.0f, 0.0f, 0.0f); saveSettings(); } diff --git a/main.cpp b/main.cpp index fd5d478..e9afc85 100644 --- a/main.cpp +++ b/main.cpp @@ -73,6 +73,9 @@ int main(int, char**) // draw the scene Rendering::manager().pushFrontDrawCallback(drawScene); + // show all windows + Rendering::manager().show(); + /// /// Main LOOP ///