【问题标题】:How to put an lwjgl app into a Javafx/swing canvas如何将 lwjgl 应用程序放入 Javafx/swing 画布中
【发布时间】:2018-11-27 21:24:54
【问题描述】:

是否可以将 lwjgl 显示放在以 Jframe 表单创建的画布上?我正在使用 Netbeans IDE v8.2 和 lwjgl 2.9.3。谢谢您的帮助!这是我从 MainLoop 调用的 DisplayManager 中的一些代码。

public class DisplayManager{

private static final int WIDTH = 800;
private static final int HEIGHT = 600;
private static final int FPS_CAP = 120;

private static long lastFrameTime;
private static float delta;

public static void createDisplay() {

    ContextAttribs attribs = new ContextAttribs(3,2).withForwardCompatible(true).withProfileCore(true);


    try { 

        Display.setDisplayMode(new DisplayMode(WIDTH, HEIGHT));
        Display.create(new PixelFormat(), attribs);
        Display.setTitle("Coffee Beans V1");
        Display.setParent(EditorGUI.canvas1);
        new EditorGUI().setVisible(true);



    } catch (LWJGLException e) {
       e.printStackTrace();
    }

    GL11.glViewport(0,0,WIDTH,HEIGHT);
    lastFrameTime = getCurrentTime();

}

【问题讨论】:

  • 请展示您尝试过的内容以及效果不佳的原因。

标签: java javafx netbeans jframe lwjgl


【解决方案1】:

是的,通过 org.lwjgl.opengl.Display.setParent(java.awt.Canvas)。

【讨论】:

  • 我将画布设置为可见,然后我使用了 Display.setParent(canvas),但 lwjgl 窗口只是在 gui 窗口旁边打开,而不是在它里面。我将更新我的帖子,从我的 DisplayManager 添加一些代码。
  • 哈哈我修好了,这是我犯的一个愚蠢的错误。我只是错误地订购了一些东西。感谢您的帮助!
猜你喜欢
  • 1970-01-01
  • 2013-05-29
  • 1970-01-01
  • 1970-01-01
  • 2014-04-12
  • 2010-11-23
  • 1970-01-01
  • 2016-08-25
  • 1970-01-01
相关资源
最近更新 更多