GLFW获取屏幕高度/宽度? [英] GLFW get screen height/width?

查看:349
本文介绍了GLFW获取屏幕高度/宽度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用freeglut库,我决定使用GLFW作为我的下一个培训项目,因为我被告知GLUT只是为学习目的而设计,不应该被专业使用。我没有问题,链接lib到我的NetBeans项目,它编译很好,使用mingw32 4.6.2。



但是,我试图将窗口放在屏幕中央时遇到困难。
在freeglut下,我以前使用:

  glutInitWindowPosition(
(glutGet(GLUT_SCREEN_WIDTH)-RES_X) 2,
(glutGet(GLUT_SCREEN_HEIGHT)-RES_Y)/ 2
);

我找不到任何会返回屏幕大小或宽度的glfw函数。

解决方案

glfwGetDesktopMode ,我想这是你想要的。



示例:

  GLFWvidmode return_struct; 

glfwGetDesktopMode(& return_struct);

int height = return_struct.Height;


Playing around with OpenGL for a while, using the freeglut library, I decided that I will use GLFW for my next training project instead, since I was told that GLUT was only designed for learning purposes and should not be used professionally. I had no problems with linking the lib to my NetBeans project and it compiles just fine, using mingw32 4.6.2.

However, I am running into difficulties trying to position the window at the center of the screen. Under freeglut, I previously used:

glutInitWindowPosition ( 
                         (glutGet(GLUT_SCREEN_WIDTH)-RES_X)  / 2,
                         (glutGet(GLUT_SCREEN_HEIGHT)-RES_Y) / 2 
                       );

I can't find any glfw function that would return the screen size or width. Is such a function simply not implemented?

解决方案

How about glfwGetDesktopMode, I think this is what you want.

Example:

GLFWvidmode return_struct;

glfwGetDesktopMode( &return_struct );

int height = return_struct.Height;

这篇关于GLFW获取屏幕高度/宽度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆