lwjgl - 全屏闪烁:LWJGL
问题描述
我已经看到有关 LWJGL 窗口在渲染期间闪烁的问题,但我在这里谈论的是全屏闪烁,而不仅仅是窗口。闪烁是正常计算机屏幕的约 1.5 秒长,然后是全黑约 1.5 秒。
我不想全屏运行应用程序。
我正在使用本教程中的代码,我在 Kotlin 中重写了该代码:
fun main(args: Array<String>){
SharedLibraryLoader.load()
thread {
Main.run()
}
}
object Main: Runnable {
val window: Long
init {
if (glfwInit() != GL_TRUE)
throw RuntimeException("Couldn't initialize GLFW...")
glfwWindowHint(GLFW_RESIZABLE, GL_TRUE)
window = glfwCreateWindow(800, 600, "Test", NULL, NULL)
if (window == NULL)
throw RuntimeException("Couldn't create the window...")
val videoMode = glfwGetVideoMode(glfwGetPrimaryMonitor())
glfwSetWindowPos(window, 100, 100)
glfwMakeContextCurrent(window)
glfwShowWindow(window)
}
fun update() {
glfwPollEvents()
}
fun render() {
glfwSwapBuffers(window)
}
override fun run() {
while (glfwWindowShouldClose(window) != GL_TRUE){
update()
render()
}
}
}
使用 Gradle 依赖项:
val lwjglVersion = "3.0.0a"
compile("org.lwjgl:lwjgl:${lwjglVersion}")
compile("org.lwjgl:lwjgl-platform:${lwjglVersion}:natives-windows")
compile("org.lwjgl:lwjgl-platform:${lwjglVersion}:natives-linux")
compile("org.lwjgl:lwjgl-platform:${lwjglVersion}:natives-osx")
我在 Debian 9 机器(Linux)上。这是显卡问题吗?还是代码错了?
解决方案
推荐阅读
- batch-file - 行与批次的比较
- reactjs - reactjs中兄弟组件的通信
- java - Java -> 2 个具有相同内容的列表不匹配
- javascript - vue2禁用多个组件的输入
- node.js - POST 端点不适用于 Express
- javascript - JS函数调用在onclick按钮的jade文件中不起作用?
- reactjs - 反应获取和设置状态
- c++ - constexpr 静态成员何时停止成为 constexpr?
- javascript - 通过 iframe 的画布键盘焦点(抵抗制表符切换)
- python-3.x - 根据 Pandas 中的条件匹配两个数据框