From 0f42160ee9b6fa9b0fe7fa650f34fbccc07d87ae Mon Sep 17 00:00:00 2001 From: mmcwilliams Date: Mon, 1 Apr 2024 11:09:59 -0400 Subject: [PATCH] Get screen width and height after fullscreen started --- main.cpp | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/main.cpp b/main.cpp index 3dac895..3d36cf2 100644 --- a/main.cpp +++ b/main.cpp @@ -20,9 +20,27 @@ using namespace std; Mat image; GLuint imageTexture; +GLint screenWidth = 0; +GLint screenHeight = 0; void displayMe(void) { + if (screenWidth == 0 && screenHeight == 0) { + GLint dims[4] = {0}; + glGetIntegerv(GL_VIEWPORT, dims); + screenWidth = dims[2]; + screenHeight = dims[3]; + cout << screenWidth << "," << screenHeight << endl; + } + + string image_path = samples::findFile("chart.png"); + Mat image = imread(image_path, IMREAD_COLOR); + #if (CV_VERSION_MAJOR >= 4) + cvtColor(image, image, cv::COLOR_BGR2RGB); + #else + cvtColor(image, image, CV_BGR2RGB); + #endif + // Set every pixel in the frame buffer to the current clear color. glClear(GL_COLOR_BUFFER_BIT); glBegin(GL_POLYGON); @@ -38,23 +56,15 @@ void displayMe(void) int main(int argc, char** argv) { - string image_path = samples::findFile("chart.png"); - Mat image = imread(image_path, IMREAD_COLOR); - -#if (CV_VERSION_MAJOR >= 4) - cvtColor(image, image, cv::COLOR_BGR2RGB); -#else - cvtColor(image, image, CV_BGR2RGB); -#endif glutInit(&argc, argv); glutInitDisplayMode(GLUT_SINGLE); - glutInitWindowSize(1920, 1080); - glutInitWindowPosition(0, 0); glutCreateWindow("opengl_opencv_example"); glutFullScreen(); - glutDisplayFunc(displayMe); glutMainLoop(); + + + return 0; } \ No newline at end of file