more opengl

opengl
yorick 3 years ago
parent b34cae9168
commit 4b34dd374a

Binary file not shown.

@ -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)
#endif

@ -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)

@ -5,6 +5,8 @@
#include <ctime>
#include <functional>
#include <GL/glut.h>
#include "../cameras/_cam.hpp"
#include "../psvr/_psvr.hpp"
#include <opencv2/imgcodecs/imgcodecs.hpp>

@ -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();
}

@ -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()){

@ -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;

Loading…
Cancel
Save