diff --git a/Sources/src/Visnode/prog b/Sources/src/Visnode/prog index c0ca0c8..0e457cd 100755 Binary files a/Sources/src/Visnode/prog and b/Sources/src/Visnode/prog differ diff --git a/Sources/src/Visnode/threadweaver/debugging.hpp b/Sources/src/Visnode/threadweaver/debugging.hpp index 8c7ff1a..ca714eb 100644 --- a/Sources/src/Visnode/threadweaver/debugging.hpp +++ b/Sources/src/Visnode/threadweaver/debugging.hpp @@ -9,6 +9,4 @@ #define DEBUG_LOG(x) std::cout << "-DEBUG: " << x << std::endl; #else #define DEBUG_LOG(x) -#endif - -//#define DBGPRINT(x) do { if (DBGMODE) { std::cerr << x << std::endl; }} while (0) \ No newline at end of file +#endif \ No newline at end of file diff --git a/Sources/src/Visnode/ui/CMakeLists.txt b/Sources/src/Visnode/ui/CMakeLists.txt index 9cfda5e..bfe4112 100644 --- a/Sources/src/Visnode/ui/CMakeLists.txt +++ b/Sources/src/Visnode/ui/CMakeLists.txt @@ -11,12 +11,19 @@ MESSAGE(STATUS "building ui") SET("OpenCV_DIR" "/usr/local/lib/") find_package( OpenCV REQUIRED ) +find_package(OpenGL REQUIRED) +find_package(GLUT REQUIRED) + +include_directories( ${OPENGL_INCLUDE_DIRS} ${GLUT_INCLUDE_DIRS} ) + MESSAGE(STATUS "OpenCV_INCLUDE_DIRS : ${OpenCV_INCLUDE_DIRS}") MESSAGE(STATUS "Opencv_LINK_DIRS : ${Opencv_LINK_DIRS}") add_library(ui ${ui_source_files}) +target_link_libraries(ui ${OPENGL_LIBRARIES}) +target_link_libraries(ui ${GLUT_INCLUDE_DIRS}) target_link_libraries(ui ${OpenCV_LIBS}) target_link_libraries(ui psvr) target_link_libraries(ui cameras) diff --git a/Sources/src/Visnode/ui/_ui.hpp b/Sources/src/Visnode/ui/_ui.hpp index df1311a..a76c19b 100644 --- a/Sources/src/Visnode/ui/_ui.hpp +++ b/Sources/src/Visnode/ui/_ui.hpp @@ -5,6 +5,8 @@ #include #include +#include + #include "../cameras/_cam.hpp" #include "../psvr/_psvr.hpp" #include diff --git a/Sources/src/Visnode/ui/ui.cpp b/Sources/src/Visnode/ui/ui.cpp index 6cc5bdc..d31d07e 100644 --- a/Sources/src/Visnode/ui/ui.cpp +++ b/Sources/src/Visnode/ui/ui.cpp @@ -2,17 +2,22 @@ void ui::Ui::draw(){ fcheckManager::fcShow.tickBegin(); + UiManager::accessLocks.at(this->id)->lock(); if(drawSurface.empty()){ - //fcheckManager::fcShow.fps = 0; + UiManager::accessLocks.at(this->id)->unlock(); return; } - UiManager::accessLocks.at(this->id)->lock(); drawBuffer = drawSurface; UiManager::accessLocks.at(this->id)->unlock(); - //drawTexture = cv::ogl::Texture2D(drawBuffer); - //cv::ogl::convertToGLTexture2D(drawBuffer, drawTexture); - - imshow(this->myWindow, this->drawBuffer); - waitKey(1); + #ifdef OGLWIN + UMat blk1920x1080(cv::Size(1920, 1080), CV_8UC3,Scalar(0,0,0)); + drawTexture = Texture2D(1920,1080,cv::ogl::Texture2D::Format::RGBA,false); + //cv::ogl::convertToGLTexture2D(drawBuffer, drawTexture); + //imshow(this->myWindow, this->drawTexture); + #else + imshow(this->myWindow, this->drawBuffer); + #endif + + waitKey(10); fcheckManager::fcShow.tickUpdate(); } \ No newline at end of file diff --git a/Sources/src/Visnode/ui/uiDrawer.cpp b/Sources/src/Visnode/ui/uiDrawer.cpp index ef97093..33ef865 100644 --- a/Sources/src/Visnode/ui/uiDrawer.cpp +++ b/Sources/src/Visnode/ui/uiDrawer.cpp @@ -52,6 +52,7 @@ namespace ui{ VideoCapture cap("./media/hud_startup.gif"); cout << "opened video"<< endl; UMat overlay = imread("./media/hud_fixed.png",-1).getUMat(ACCESS_READ); + cout << "read overlay" << endl; ui::UiDrawer::OverlayMat = overlay; if(!cap.isOpened()){ diff --git a/Sources/src/Visnode/ui/uiManager.cpp b/Sources/src/Visnode/ui/uiManager.cpp index 06fe9ed..9f9a29b 100644 --- a/Sources/src/Visnode/ui/uiManager.cpp +++ b/Sources/src/Visnode/ui/uiManager.cpp @@ -12,6 +12,31 @@ namespace ui{ } } + void on_opengl(void* param) +{ + glLoadIdentity(); + glTranslated(0.0, 0.0, -1.0); + glRotatef( 55, 1, 0, 0 ); + glRotatef( 45, 0, 1, 0 ); + glRotatef( 0, 0, 0, 1 ); + static const int coords[6][4][3] = { + { { +1, -1, -1 }, { -1, -1, -1 }, { -1, +1, -1 }, { +1, +1, -1 } }, + { { +1, +1, -1 }, { -1, +1, -1 }, { -1, +1, +1 }, { +1, +1, +1 } }, + { { +1, -1, +1 }, { +1, -1, -1 }, { +1, +1, -1 }, { +1, +1, +1 } }, + { { -1, -1, -1 }, { -1, -1, +1 }, { -1, +1, +1 }, { -1, +1, -1 } }, + { { +1, -1, +1 }, { -1, -1, +1 }, { -1, -1, -1 }, { +1, -1, -1 } }, + { { -1, -1, +1 }, { +1, -1, +1 }, { +1, +1, +1 }, { -1, +1, +1 } } + }; + for (int i = 0; i < 6; ++i) { + glColor3ub( i*20, 100+i*10, i*42 ); + glBegin(GL_QUADS); + for (int j = 0; j < 4; ++j) { + glVertex3d(0.2 * coords[i][j][0], 0.2 * coords[i][j][1], 0.2 * coords[i][j][2]); + } + glEnd(); + } +} + //initializes the ui manager, following default values void UiManager::init(){ uiShouldRun = false; @@ -23,16 +48,15 @@ namespace ui{ #ifdef OGLWIN DEBUG_LOG("created opengl window") namedWindow(newUI->myWindow,WINDOW_OPENGL); + cv::setOpenGlContext(newUI->myWindow); + setOpenGlDrawCallback(newUI->myWindow, on_opengl); #else DEBUG_LOG("created cpu-based window") namedWindow(newUI->myWindow); #endif moveWindow(newUI->myWindow,DEFAULT_UI_OFFSET_X+i*960,DEFAULT_UI_OFFSET_Y); resizeWindow(newUI->myWindow,DEFAULT_UI_SIZE_X,DEFAULT_UI_SIZE_Y); - setWindowProperty(newUI->myWindow, cv::WND_PROP_FULLSCREEN, cv::WINDOW_FULLSCREEN); - #ifdef OGLWIN - cv::setOpenGlContext(newUI->myWindow); - #endif + //setWindowProperty(newUI->myWindow, cv::WND_PROP_FULLSCREEN, cv::WINDOW_FULLSCREEN); cout << "window: " << newUI->myWindow << " created at " << DEFAULT_UI_OFFSET_X+i*960 << " , " << DEFAULT_UI_OFFSET_Y << endl;