[英]Screen width and height LWJGL
I am making a simple LWJGL program and would like to be able to use the width and height of the window.我正在制作一个简单的 LWJGL 程序,并希望能够使用 window 的宽度和高度。 I can do it now I just have to use
Display.getDisplayMode().getWidth()
but I have seen people use just Display.getWidth()
我现在可以做到我只需要使用
Display.getDisplayMode().getWidth()
但我看到人们只使用Display.getWidth()
So my question is why is this happening, and what do I need to change for it to just use Display.getWidth();
所以我的问题是为什么会发生这种情况,我需要改变什么才能使用
Display.getWidth();
The latest version of LWJGL according to the documentation says that it has a static method called getWidth. 根据文档的最新版本的LWJGL表示,它具有一个称为getWidth的静态方法。 Make sure you're invoking it by it's class name and not on an object - as it's static.
确保您是通过类名而不是对象来调用它的-因为它是静态的。
In LWJGL, there are two display classes, one in:在 LWJGL 中,有两种显示类,一种在:
and the other in:另一个在:
If you import from the opengl package, you don't need getDisplayMode() and if you import from the util package you do.如果从 opengl package 导入,则不需要 getDisplayMode(),如果从实用程序 package 导入,则需要。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.