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

Lwjgl3 canvas #1868

Merged
merged 9 commits into from
Jan 19, 2024
Merged

Lwjgl3 canvas #1868

merged 9 commits into from
Jan 19, 2024

Conversation

tonihele
Copy link
Contributor

@tonihele tonihele commented Nov 21, 2022

Would this be acceptable solution for now? If we open another ticket to implement this for real?

This would fix #1192 and also TestAwtPanels. The performance is not great.. not terrible...

I tried getting https://github.com/LWJGLX/lwjgl3-awt to work but didn't get it display anything yet.

The problem with this solution is that it is pretty much software rendering. The rendering is first done to a Framebuffer as it is recommended. But then everything goes bad, we just render it to an image (I guess slightly accelerated but...) for displaying it to the user. And another problem is that it requires support for non power of two textures.

This is basically copy paste from what we already had in the engine, the Offscreen rendering to an AWT panel.

@@ -291,6 +289,8 @@ public void invoke(int error, long description) {
requestWidth = videoMode.width();
requestHeight = videoMode.height();
}
oldFramebufferHeight = requestHeight;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By assuming that the scaling factor of 1 is correct we avoid extra resize at the start of application, also fixes TestAwtPanels. If you really don't have scaling... AwtContext wasn't build scaling in mind. It throws an exception when framebuffer resize is triggered, and that is how our scaling currently works.

Copy link
Member

@Ali-RS Ali-RS Feb 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tonihele please revert oldFramebufferHeight and oldFramebufferWidth initial values back to 0.

See: https://github.com/jMonkeyEngine/jmonkeyengine/pull/1950/files#r1103859250

Copy link
Member

@Ali-RS Ali-RS Feb 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TestAwtPanels throws an exception

AwtPanelsContext is modified to log an error instead of throwing an exception which should make TestAwtPanels work again.

Please see #1949

@riccardobl
Copy link
Member

Thank you for the PR.

Would this be acceptable solution for now? If we open another ticket to implement this for real?

Yes, I think this is the least sketchy way to get this to work reliably, other solutions can be implemented as optimization for specific platforms (eg. i see lwjgl3-awt works only on linux systems that use X11).

Also this should probably work well in most systems.

I have 2 questions:

  1. What is the deal with all the changes to Lists?
  2. Is it possible to remove the non-power-of-two requirement by rounding the sizes to the nearest power of two? (it will introduce some cropping, yes, but it should probably be fine i think)

@tonihele
Copy link
Contributor Author

  • What is the deal with all the changes to Lists?

  • Is it possible to remove the non-power-of-two requirement by rounding the sizes to the nearest power of two? (it will introduce some cropping, yes, but it should probably be fine i think)

  1. It is just cleanup, aren't we all taught to program with interfaces? :) Well, I intended to actual have the event queues be queues, but I changed my mind as it would achieve nothing. In sense of clarity or performance the same, so then I just left them as cleanups. Irrelevant changes.

  2. Can be done, also in such matter that our Offscreen rendering would also be void of this requirement. Perhaps in such manner that the capability is checked against and a proper strategy is then used.

@riccardobl
Copy link
Member

It is just cleanup, aren't we all taught to program with interfaces? :) Well, I intended to actual have the event queues be queues, but I changed my mind as it would achieve nothing. In sense of clarity or performance the same, so then I just left them as cleanups. Irrelevant changes.

Ok, i was questioning the use of Deque vs List, but i've seen now that you did that to use poll(). Ok then.

Can be done, also in such matter that our Offscreen rendering would also be void of this requirement. Perhaps in such manner that the capability is checked against and a proper strategy is then used.

Yep, should be easy enough, since we have already a capability registered for that. Do you plan to address it in this PR or would you like to do it at a later time? Non-power-of-two textures should be supported by the vast majority of GPUs anyway, so we could also decide to leave it like that for now.. and just merge this PR

@tonihele
Copy link
Contributor Author

tonihele commented Nov 22, 2022

Yep, should be easy enough, since we have already a capability registered for that. Do you plan to address it in this PR or would you like to do it at a later time? Non-power-of-two textures should be supported by the vast majority of GPUs anyway, so we could also decide to leave it like that for now.. and just merge this PR

I would do additional issues. Not this PR. The following issues would be created:

  1. The non-power of two issue is existing issue with the offscreen rendering, create issue for it
  2. Implement HW accelerated Lwjgl3 Canvas

1 & 2 can be handled then separately without applying any pressure on one another. And if 2 is done before, well, that is all good then, canvas works.

Also there are issues about the scaling and canvas. That should be taken into consideration when touching issue number two.

@Ali-RS
Copy link
Member

Ali-RS commented Dec 31, 2022

What is the state of this PR?
Should this become a candidate for the next release?
Is anybody willing to review and possibly merge it?

@tonihele
Copy link
Contributor Author

What is the state of this PR? Should this become a candidate for the next release? Is anybody willing to review and possibly merge it?

It is ready.

What it is, is a poor solution to something that currently doesn't work at all. With this it works. Usability depends largely on what it is being used for, i.e. gaming, not feasible; using LWJGL 3 and a small 3D canvas in your app, feasibleish. There is the test canvas test app for this.

Even I'm on the fence with this one. My small hope was that we could use LWJGL 3 with the jME SDK with this. But I don't know if this even really makes it possible. SDK rendering at least would need so little power that in that way this would work.

Future development needed as stated above.

@Sailsman63
Copy link
Contributor

Would if be possible to add a short Javadoc comment explaining what/when this is used? IIUC, it's to allow lwjgl to render a scene to an AWT component, but lack of Javadoc is an ongoing pain-point for me with JME.

@tonihele
Copy link
Contributor Author

tonihele commented Jan 8, 2023

Would if be possible to add a short Javadoc comment explaining what/when this is used? IIUC, it's to allow lwjgl to render a scene to an AWT component, but lack of Javadoc is an ongoing pain-point for me with JME.

The code is self-doc... :D As far as I know it is indeed used to render jME context inside an AWT component. Would that itself be a suffice explanation?

@Ali-RS Ali-RS added this to the v3.6.0 milestone Jan 10, 2023
@Sailsman63
Copy link
Contributor

Sorry, I thought I had responded. Yeah, Just a one-liner stating the use. Most of the methods seem to be @Overrides anyway, so they are presumably documented further up the tree.

I am wondering if drawFrameInThread() and destroyFrameBuffer() are intended to be called from user code, or if they are marked public to allow some of the existing machinery to trigger them. If the later, a doc-comment warning that they should not be called directly might be in order.

@Ali-RS Ali-RS modified the milestones: v3.6.0, Future Release Jan 24, 2023
@scenemax3d scenemax3d modified the milestones: Future Release, v3.7.0 Jan 12, 2024
@scenemax3d scenemax3d merged commit ec9c8c5 into jMonkeyEngine:master Jan 19, 2024
@tonihele tonihele deleted the Lwjgl3Canvas branch January 19, 2024 09:09
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

Successfully merging this pull request may close these issues.

TestCanvas crashes with LWJGL3
5 participants