如何将 lwjgl 应用程序放入 Javafx/swing canvas
How to put an lwjgl app into a Javafx/swing canvas
是否可以将 lwjgl 显示放到在 Jframe 窗体中创建的 canvas 上?我正在使用 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();
}
是的,通过 org.lwjgl.opengl.Display.setParent(java.awt.Canvas).
是否可以将 lwjgl 显示放到在 Jframe 窗体中创建的 canvas 上?我正在使用 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();
}
是的,通过 org.lwjgl.opengl.Display.setParent(java.awt.Canvas).