如何将lwjgl应用程序放入Javafx / swing画布

时间:2018-11-27 21:24:54

标签: java javafx netbeans jframe lwjgl

是否可以将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();

}

1 个答案:

答案 0 :(得分:1)

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