【问题标题】:Why is my Display method in the opengl class not working为什么我的 opengl 类中的 Display 方法不起作用
【发布时间】:2017-03-21 21:36:40
【问题描述】:

这只是代码的一小部分。我想知道为什么我的 Display 方法
不起作用,即使我使用的是 opengl 库并设置了
本机路径。

import org.lwjgl.opengl.Display;  
import org.lwjgl.opengl.DisplayMode;  

public class Window  
{  
    public static void CreateWindow(int width, int height, String title)  
    {  
        Display.setTitle(title);  
        try  
        {  
            Display.setDisplayMode(new DisplayMode(width, height));  
            Display.create();  
            Keyboard.create();  
            Mouse.create();  
        }  
        catch (LWJGLException e)   
        {  
            e.printStackTrace();  
        }  
    }  
}

错误:

Exception in thread "main" java.lang.Error: Unresolved compilation problems:   
Display cannot be resolved  
Display cannot be resolved  
DisplayMode cannot be resolved to a type  
Display cannot be resolved  
Keyboard cannot be resolved  
Mouse cannot be resolved  
LWJGLException cannot be resolved to a type  

at com.base.engine.rendering.Window.CreateWindow(Window.java:14)  
at com.base.engine.core.CoreEngine.CreateWindow(CoreEngine.java:27)  
at com.base.game.Main.main(Main.java:10)  

【问题讨论】:

  • 可能是因为您使用的是 LWJGL 3,而这些类不存在任何东西。

标签: eclipse opengl lwjgl


【解决方案1】:

这看起来很像 eclipse 编译器在代码中出现编译错误时会产生的东西。它还告诉你错误是什么。

我的猜测是您是在 Eclipse IDE 中运行它并且您有编译错误,因为您没有在 Eclipse 库路径中包含 LWJGL。如果您没有看到任何编译错误并且您确定 LWJGL 包含在库路径中 - 尝试重新构建整个项目(可能某些 IDE 缓存无法正常工作?)。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-10-25
    • 1970-01-01
    • 1970-01-01
    • 2021-01-30
    • 2015-03-14
    • 2014-11-03
    相关资源
    最近更新 更多