diff --git a/src/CMakeFiles/prog.dir/compiler_depend.internal b/src/CMakeFiles/prog.dir/compiler_depend.internal index 7191d8d..601ebc6 100644 --- a/src/CMakeFiles/prog.dir/compiler_depend.internal +++ b/src/CMakeFiles/prog.dir/compiler_depend.internal @@ -626,6 +626,7 @@ CMakeFiles/prog.dir/main.cpp.o /usr/include/GL/glext.h /usr/include/KHR/khrplatform.h /usr/include/GL/glu.h + /home/kanken/code/AHRS_core/src/threadweaver/debugging.hpp /home/kanken/code/AHRS_core/src/pipeline/members/uiDrawerNode.hpp /home/kanken/code/AHRS_core/src/model/controllers/ui/uiController.hpp /home/kanken/code/AHRS_core/src/model/hardware/psvr/_psvr.hpp @@ -1261,6 +1262,7 @@ CMakeFiles/prog.dir/topLevelManager.cpp.o /usr/include/GL/glext.h /usr/include/KHR/khrplatform.h /usr/include/GL/glu.h + /home/kanken/code/AHRS_core/src/threadweaver/debugging.hpp /home/kanken/code/AHRS_core/src/pipeline/members/uiDrawerNode.hpp /home/kanken/code/AHRS_core/src/model/controllers/ui/uiController.hpp /home/kanken/code/AHRS_core/src/model/hardware/psvr/_psvr.hpp diff --git a/src/CMakeFiles/prog.dir/compiler_depend.make b/src/CMakeFiles/prog.dir/compiler_depend.make index 025528e..fd2c582 100644 --- a/src/CMakeFiles/prog.dir/compiler_depend.make +++ b/src/CMakeFiles/prog.dir/compiler_depend.make @@ -625,6 +625,7 @@ CMakeFiles/prog.dir/main.cpp.o: main.cpp \ /usr/include/GL/glext.h \ /usr/include/KHR/khrplatform.h \ /usr/include/GL/glu.h \ + threadweaver/debugging.hpp \ pipeline/members/uiDrawerNode.hpp \ model/controllers/ui/uiController.hpp \ model/hardware/psvr/_psvr.hpp \ @@ -1259,6 +1260,7 @@ CMakeFiles/prog.dir/topLevelManager.cpp.o: topLevelManager.cpp \ /usr/include/GL/glext.h \ /usr/include/KHR/khrplatform.h \ /usr/include/GL/glu.h \ + threadweaver/debugging.hpp \ pipeline/members/uiDrawerNode.hpp \ model/controllers/ui/uiController.hpp \ model/hardware/psvr/_psvr.hpp \ diff --git a/src/model/windows/CMakeFiles/windows.dir/compiler_depend.internal b/src/model/windows/CMakeFiles/windows.dir/compiler_depend.internal index 272053c..6e3fc60 100644 --- a/src/model/windows/CMakeFiles/windows.dir/compiler_depend.internal +++ b/src/model/windows/CMakeFiles/windows.dir/compiler_depend.internal @@ -323,6 +323,8 @@ model/windows/CMakeFiles/windows.dir/window.cpp.o /usr/include/GL/glext.h /usr/include/KHR/khrplatform.h /usr/include/GL/glu.h + /home/kanken/code/AHRS_core/src/threadweaver/debugging.hpp + /usr/include/c++/11/iostream model/windows/CMakeFiles/windows.dir/windowManager.cpp.o /home/kanken/code/AHRS_core/src/model/windows/windowManager.cpp @@ -647,6 +649,8 @@ model/windows/CMakeFiles/windows.dir/windowManager.cpp.o /usr/include/GL/glext.h /usr/include/KHR/khrplatform.h /usr/include/GL/glu.h + /home/kanken/code/AHRS_core/src/threadweaver/debugging.hpp + /usr/include/c++/11/iostream /usr/include/c++/11/thread /usr/include/c++/11/bits/std_thread.h /usr/include/c++/11/bits/this_thread_sleep.h diff --git a/src/model/windows/CMakeFiles/windows.dir/compiler_depend.make b/src/model/windows/CMakeFiles/windows.dir/compiler_depend.make index 10e8ba4..0f2782c 100644 --- a/src/model/windows/CMakeFiles/windows.dir/compiler_depend.make +++ b/src/model/windows/CMakeFiles/windows.dir/compiler_depend.make @@ -321,7 +321,9 @@ model/windows/CMakeFiles/windows.dir/window.cpp.o: model/windows/window.cpp \ /usr/include/GL/gl.h \ /usr/include/GL/glext.h \ /usr/include/KHR/khrplatform.h \ - /usr/include/GL/glu.h + /usr/include/GL/glu.h \ + threadweaver/debugging.hpp \ + /usr/include/c++/11/iostream model/windows/CMakeFiles/windows.dir/windowManager.cpp.o: model/windows/windowManager.cpp \ /usr/include/stdc-predef.h \ @@ -645,6 +647,8 @@ model/windows/CMakeFiles/windows.dir/windowManager.cpp.o: model/windows/windowMa /usr/include/GL/glext.h \ /usr/include/KHR/khrplatform.h \ /usr/include/GL/glu.h \ + threadweaver/debugging.hpp \ + /usr/include/c++/11/iostream \ /usr/include/c++/11/thread \ /usr/include/c++/11/bits/std_thread.h \ /usr/include/c++/11/bits/this_thread_sleep.h @@ -652,6 +656,8 @@ model/windows/CMakeFiles/windows.dir/windowManager.cpp.o: model/windows/windowMa model/windows/windowManager.cpp: +threadweaver/debugging.hpp: + /usr/include/GL/glu.h: /usr/include/KHR/khrplatform.h: @@ -1246,6 +1252,8 @@ model/windows/window.cpp: /usr/include/x86_64-linux-gnu/bits/fp-logb.h: +/usr/include/c++/11/iostream: + /usr/include/c++/11/bits/node_handle.h: /usr/include/x86_64-linux-gnu/bits/fp-fast.h: diff --git a/src/model/windows/window.cpp b/src/model/windows/window.cpp index ef2d704..96ae9dd 100644 --- a/src/model/windows/window.cpp +++ b/src/model/windows/window.cpp @@ -1,5 +1,24 @@ #include "window.hpp" +void glDrawTextureCallback(void* userdata) +{ + cv::ogl::Texture2D* texObj = static_cast(userdata); + cv::ogl::render(*texObj); +} + +Window::Window(std::string windowName){ + this->myWindow = windowName; +} + +void Window::glInit(){ + cv::namedWindow(this->myWindow, cv::WINDOW_OPENGL); + setWindowProperty(this->myWindow, cv::WND_PROP_FULLSCREEN, cv::WINDOW_FULLSCREEN); + cv::setOpenGlContext(this->myWindow); + cv::moveWindow(this->myWindow, DEFAULT_UI_OFFSET_X + 960, DEFAULT_UI_OFFSET_Y); + cv::setOpenGlContext(this->myWindow); + cv::setOpenGlDrawCallback(this->myWindow, glDrawTextureCallback, &this->drawTexture); +} + void Window::draw(){ try{ drawAccess.lock(); @@ -12,7 +31,7 @@ void Window::draw(){ #ifdef OGLWIN drawTexture.copyFrom(drawBuffer); - cv::imshow(this->myWindow, this->drawTexture); + cv::updateWindow(this->myWindow); #else cv::imshow(this->myWindow, drawBuffer); #endif @@ -20,5 +39,6 @@ void Window::draw(){ } catch(...){ drawAccess.unlock(); + std::cout << "Caught draw window thread exception" << std::endl; } } \ No newline at end of file diff --git a/src/model/windows/window.hpp b/src/model/windows/window.hpp index f781a76..603d09c 100644 --- a/src/model/windows/window.hpp +++ b/src/model/windows/window.hpp @@ -10,10 +10,12 @@ class Window { public: + Window(std::string windowName); cv::UMat drawSurface; // Current frame cv::ogl::Texture2D drawTexture = cv::ogl::Texture2D(); int id; std::mutex drawAccess; std::string myWindow; void draw(); + void glInit(); }; \ No newline at end of file diff --git a/src/model/windows/windowManager.cpp b/src/model/windows/windowManager.cpp index cb6157e..3f8a116 100644 --- a/src/model/windows/windowManager.cpp +++ b/src/model/windows/windowManager.cpp @@ -3,16 +3,18 @@ // initializes the ui manager, following default values WindowManager::WindowManager() { + try{ uiShouldRun = false; for (int i = 0; i < DEFAULT_UI_WINDOW_AMOUNT; i++) { - Window *newWindow = new Window(); - newWindow->myWindow = "project- UI" + std::to_string(i); + Window *newWindow; + std::string name = "project- UI" + std::to_string(i); #ifndef OGLWIN - cv::namedWindow(newWindow->myWindow); //if we're in opengl mode, the window needs to be created in the same thread as the execution, not here + cv::namedWindow(name); //if we're in opengl mode, the window needs to be created in the same thread as the execution, not here + cv::moveWindow(name, DEFAULT_UI_OFFSET_X + i * 960, DEFAULT_UI_OFFSET_Y); + cv::resizeWindow(name, DEFAULT_UI_SIZE_X, DEFAULT_UI_SIZE_Y); #endif - cv::moveWindow(newWindow->myWindow, DEFAULT_UI_OFFSET_X + i * 960, DEFAULT_UI_OFFSET_Y); - cv::resizeWindow(newWindow->myWindow, DEFAULT_UI_SIZE_X, DEFAULT_UI_SIZE_Y); + newWindow = new Window(name); //cout << "window: " << newWindow->myWindow << " created at " << DEFAULT_UI_OFFSET_X + i * 960 << " , " << DEFAULT_UI_OFFSET_Y << endl; @@ -21,6 +23,10 @@ managedUIs.push_back(newWindow); // add new ui in the ui map, mapped to the window's name } uiShouldRun = true; + } + catch(std::exception& e){ + std::cerr << "\033[1;31m caught windowManager::WindowManager thread exception: " << e.what() <<" \033[0m" << std::endl; + } } void WindowManager::cleanup() diff --git a/src/pipeline/CMakeFiles/pipelineLib.dir/compiler_depend.internal b/src/pipeline/CMakeFiles/pipelineLib.dir/compiler_depend.internal index 20e2e71..1e096f3 100644 --- a/src/pipeline/CMakeFiles/pipelineLib.dir/compiler_depend.internal +++ b/src/pipeline/CMakeFiles/pipelineLib.dir/compiler_depend.internal @@ -1308,6 +1308,7 @@ pipeline/CMakeFiles/pipelineLib.dir/members/displayOutputNode.cpp.o /usr/include/GL/glext.h /usr/include/KHR/khrplatform.h /usr/include/GL/glu.h + /home/kanken/code/AHRS_core/src/threadweaver/debugging.hpp pipeline/CMakeFiles/pipelineLib.dir/members/subNodes/fpsCounter.cpp.o /home/kanken/code/AHRS_core/src/pipeline/members/subNodes/fpsCounter.cpp @@ -4647,6 +4648,7 @@ pipeline/CMakeFiles/pipelineLib.dir/pipeline.cpp.o /usr/include/GL/glext.h /usr/include/KHR/khrplatform.h /usr/include/GL/glu.h + /home/kanken/code/AHRS_core/src/threadweaver/debugging.hpp /home/kanken/code/AHRS_core/src/pipeline/members/uiDrawerNode.hpp /home/kanken/code/AHRS_core/src/model/controllers/ui/uiController.hpp /home/kanken/code/AHRS_core/src/model/hardware/psvr/_psvr.hpp diff --git a/src/pipeline/CMakeFiles/pipelineLib.dir/compiler_depend.make b/src/pipeline/CMakeFiles/pipelineLib.dir/compiler_depend.make index 2aa9702..af72d3c 100644 --- a/src/pipeline/CMakeFiles/pipelineLib.dir/compiler_depend.make +++ b/src/pipeline/CMakeFiles/pipelineLib.dir/compiler_depend.make @@ -1304,7 +1304,8 @@ pipeline/CMakeFiles/pipelineLib.dir/members/displayOutputNode.cpp.o: pipeline/me /usr/include/GL/gl.h \ /usr/include/GL/glext.h \ /usr/include/KHR/khrplatform.h \ - /usr/include/GL/glu.h + /usr/include/GL/glu.h \ + threadweaver/debugging.hpp pipeline/CMakeFiles/pipelineLib.dir/members/subNodes/fpsCounter.cpp.o: pipeline/members/subNodes/fpsCounter.cpp \ /usr/include/stdc-predef.h \ @@ -4637,6 +4638,7 @@ pipeline/CMakeFiles/pipelineLib.dir/pipeline.cpp.o: pipeline/pipeline.cpp \ /usr/include/GL/glext.h \ /usr/include/KHR/khrplatform.h \ /usr/include/GL/glu.h \ + threadweaver/debugging.hpp \ pipeline/members/uiDrawerNode.hpp \ model/controllers/ui/uiController.hpp \ model/hardware/psvr/_psvr.hpp \ diff --git a/src/pipeline/members/displayOutputNode.cpp b/src/pipeline/members/displayOutputNode.cpp index 4a76115..c865ee7 100644 --- a/src/pipeline/members/displayOutputNode.cpp +++ b/src/pipeline/members/displayOutputNode.cpp @@ -16,10 +16,7 @@ void DisplayOutputNode::processFrame() { #ifdef OGLWIN DEBUG_LOG("DisplayOutputNode on thread " << localThread->get_id() << " is creating its opengl UI"); - cv::namedWindow(_managed->myWindow, cv::WINDOW_OPENGL); - setWindowProperty(_managed->myWindow, cv::WND_PROP_FULLSCREEN, cv::WINDOW_FULLSCREEN); - cv::setOpenGlContext(_managed->myWindow); - cv::moveWindow(_managed->myWindow, DEFAULT_UI_OFFSET_X + 960, DEFAULT_UI_OFFSET_Y); + _managed->glInit(); DEBUG_LOG("DisplayOutputNode on thread " << localThread->get_id() << " is done creating its opengl UI"); #endif inited = true; diff --git a/src/prog b/src/prog index 4b627b0..f9d95ba 100755 Binary files a/src/prog and b/src/prog differ