Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RuntimeException during swapchain creation on JavaFX 20 Windows #50

Open
lenis0012 opened this issue Apr 10, 2023 · 0 comments
Open

RuntimeException during swapchain creation on JavaFX 20 Windows #50

lenis0012 opened this issue Apr 10, 2023 · 0 comments

Comments

@lenis0012
Copy link

lenis0012 commented Apr 10, 2023

with DriftFX 1.0.0 I am getting a runtime exception on JavaFX 20 with JDK 20.

Exception in thread "Thread-4" java.lang.RuntimeException
	at org.eclipse.fx.drift.internal.frontend.FxImageFactory.createFxImage(FxImageFactory.java:37)
	at org.eclipse.fx.drift.internal.frontend.SimpleFrontSwapChain.<init>(SimpleFrontSwapChain.java:58)
	at org.eclipse.fx.drift.internal.frontend.FrontendImpl.doCreateSwapchain(FrontendImpl.java:99)
	at org.eclipse.fx.drift.internal.frontend.FrontendImpl.receiveCommand(FrontendImpl.java:137)
	at org.eclipse.fx.drift.internal.backend.BackendImpl.sendCommand(BackendImpl.java:85)
	at org.eclipse.fx.drift.internal.backend.BackendImpl.createSwapchain(BackendImpl.java:45)
	at org.eclipse.fx.drift.internal.RendererImpl.createSwapchain(RendererImpl.java:88)
	at com.lenis0012.oraksi.SceneExplorer.loop(SceneExplorer.java:74)
	at com.lenis0012.oraksi.SceneExplorer.run(SceneExplorer.java:37)

This error occurs in FxImageFactory when creating an image. I debugged the error and noticed that all Prism backends return false.
So Prism.isES2(), Prism.isD3D() and Prism.isSW() are all false.

I am using the following code to set up an OpenGL context:

this.context = org.eclipse.fx.drift.internal.GL.createContext(0, 3, 3);
org.eclipse.fx.drift.internal.GL.makeContextCurrent(context);

and this is the code in my rendering loop:

Vec2i size = renderer.getSize();
if(swapchain == null || size.x != swapchain.getConfig().size.x || size.y != swapchain.getConfig().size.y) {
    if(swapchain != null) {
        swapchain.dispose();
    }
    swapchain = renderer.createSwapchain(new SwapchainConfig(size, 2, PresentationMode.MAILBOX, StandardTransferTypes.MainMemory));
}

RenderTarget renderTarget = swapchain.acquire();
int texId = GLRenderer.getGLTextureId(renderTarget);

glBindFramebuffer(GL_FRAMEBUFFER, fbo);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texId, 0);
glViewport(0, 0, size.x, size.y);

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

glBindFramebuffer(GL_FRAMEBUFFER, 0);
swapchain.present(renderTarget);

The initialization and loop happen on a separate thread started from the FXML controller using Platform.runLater to allow layout to complete first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant