glfwGetVideoMode(glfwGetPrimaryMonitor())不起作用 [英] glfwGetVideoMode(glfwGetPrimaryMonitor()) not working

查看:387
本文介绍了glfwGetVideoMode(glfwGetPrimaryMonitor())不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我正在观看有关如何使用Lwjgl创建窗口的Java教程,并且我进入了获得主监视器的这一部分:

So i was watching a tutorial for java on how to create a window using Lwjgl and i got to this part where you get the primary monitor:

    ByteBuffer vidmode = glfwGetVideoMode(glfwGetPrimaryMonitor());

    glfwSetWindowPos(
            window,
            (GLFWVidMode.width(vidmode) - width) / 2,
            (GLFWVidMode.height(vidmode) - height) / 2
        ); 

但是我在eclipse上遇到此错误:类型不匹配:无法从GLFWVidMode转换为ByteBuffer"

However i get this error on eclipse : "Type mismatch: cannot convert from GLFWVidMode to ByteBuffer"

这导致不允许这样做: GLFWVidMode.width GLFWVidMode.height(它表示:类型为GLFWVidMode的方法height()不适用于参数(ByteBuffer)")

which results in this not being allowed: GLFWVidMode.width GLFWVidMode.height (it says: "The method height() in the type GLFWVidMode is not applicable for the arguments (ByteBuffer)")

我搜索了另一个教程,并且它也按该顺序使用方法,所以我不确定应该替换什么以使其正常工作,或者它们是否更新了Lwjgl 3.0中的某些内容.

I have searched for another tutorial and it also uses the methods in that order so I'm not sure what should i replace for it to work or if they updated something in Lwjgl 3.0.

推荐答案

没关系,我检查了源站点,看来实际上他们已经对其进行了更改,所以现在是这样:

Never mind, i checked the source site and it appears that in fact they changed it so it's now this:

GLFWVidMode vidmode = glfwGetVideoMode(glfwGetPrimaryMonitor());

    glfwSetWindowPos(
            window,
             (vidmode.width() - width) / 2,
            (vidmode.height() - height) / 2
        ); 

这篇关于glfwGetVideoMode(glfwGetPrimaryMonitor())不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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