Get screen width and height after fullscreen started
This commit is contained in:
parent
801a56a78f
commit
0f42160ee9
32
main.cpp
32
main.cpp
|
@ -20,9 +20,27 @@ using namespace std;
|
||||||
|
|
||||||
Mat image;
|
Mat image;
|
||||||
GLuint imageTexture;
|
GLuint imageTexture;
|
||||||
|
GLint screenWidth = 0;
|
||||||
|
GLint screenHeight = 0;
|
||||||
|
|
||||||
void displayMe(void)
|
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.
|
// Set every pixel in the frame buffer to the current clear color.
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
glBegin(GL_POLYGON);
|
glBegin(GL_POLYGON);
|
||||||
|
@ -38,23 +56,15 @@ void displayMe(void)
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
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);
|
glutInit(&argc, argv);
|
||||||
glutInitDisplayMode(GLUT_SINGLE);
|
glutInitDisplayMode(GLUT_SINGLE);
|
||||||
glutInitWindowSize(1920, 1080);
|
|
||||||
glutInitWindowPosition(0, 0);
|
|
||||||
glutCreateWindow("opengl_opencv_example");
|
glutCreateWindow("opengl_opencv_example");
|
||||||
glutFullScreen();
|
glutFullScreen();
|
||||||
|
|
||||||
glutDisplayFunc(displayMe);
|
glutDisplayFunc(displayMe);
|
||||||
glutMainLoop();
|
glutMainLoop();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
Loading…
Reference in New Issue