I have a Display object from the java lwjgl library: link the one that I have some 3D objects loaded, and I update the display every frame in the following way:
In a class created by me, called DisplayManager:
public static void updateDisplay(){
Display.sync(FPS_CAP);
Display.update();
long currentFrameTime = getCurrentTime();
delta = (currentFrameTime - lastFrameTime)/1000f;
lastFrameTime = currentFrameTime;
}
The main loop of the program:
while(!Display.isCloseRequested() && !Thread.interrupted()){
time += DisplayManager.getFrameTimeSeconds();
if (time > 1.0){
System.out.println("World FPS:" + counter);
time = 0;
counter = 0;
}
renderer.renderScene(entities, normalMapEntities, terrains, lights, camera, new Vector4f(0, 1, 0, 0), true);
DisplayManager.updateDisplay();
counter +=1;
}
The renderer.renderScene method loads the changes made to the screen.
Now, what I want to achieve is that these data that are currently being displayed on the display itself, are shown in a JFrame or JLayer of javax.swing: link
Currently I've been looking at it on the internet and it may be that the Display.getDrawable () method is useful, but I do not know how I can load a drawable object into a JFrame or JLayer.
I leave you the method that creates the DisplayManeger class screen created by me:
public static void createDisplay(){
ContextAttribs attribs = new ContextAttribs(3, 2).withForwardCompatible(true).withProfileCore(true);
try {
Display.setDisplayMode(new DisplayMode(WIDTH, HEIGHT));
Display.getDrawable();
Display.create(new PixelFormat().withSamples(SAMPLES).withDepthBits(DEPHT_BITS), attribs);
Display.setTitle("3D World");
GL11.glEnable(GL13.GL_MULTISAMPLE);
} catch (LWJGLException e) {
e.printStackTrace();
}
GL11.glViewport(0, 0, WIDTH, HEIGHT);
lastFrameTime = getCurrentTime();
}
Thanks in advance for your help.