3

在我的 OpenGL 程序中,为了在全屏模式下运行它,我使用了 GLUT 函数 glutGameModeString(const char *string)。
(其中“字符串”指定屏幕宽度、高度、像素深度和刷新率)

为了使其在任何系统中工作,我需要在调用“glutGameModeString”之前动态确定主机系统的屏幕宽度和屏幕高度功能。
我怎么做?

4

2 回答 2

4

我认为你错了,有以下常量:

GLUT_SCREEN_HEIGHT
GLUT_SCREEN_WIDTH

我已经测试过了,它可以工作。

于 2013-12-08T13:46:50.050 回答
1

刚刚在 Linux Mint 18 上测试过

std::cout << "glut screen width(DEFUALT): " << GLUT_SCREEN_WIDTH << std::endl;
std::cout << "glut screen height(DEFAULT): " << GLUT_SCREEN_HEIGHT << std::endl;
std::cout << "glut screen width: " << glutGet(GLUT_SCREEN_WIDTH) << std::endl;
std::cout << "glut screen height: " << glutGet(GLUT_SCREEN_HEIGHT) << std::endl;

输出:

glut screen width(DEFAULT): 200
glut screen height(DEFAULT): 201
glut screen width: 1366
glut screen height: 768

将您的窗口大小设置为glutGet(GLUT_SCREEN_WIDTH/HEIGHT);将最大化您的窗口,仍然有顶部栏和边框。

只需glutFullScreen();在初始化窗口后调用即可使其全屏无边框或任何内容,无需上述获取屏幕大小的内容。

于 2018-11-09T02:03:13.447 回答