Skip to content

Conversation

@Markil3
Copy link
Contributor

@Markil3 Markil3 commented Apr 15, 2021

https://hub.jmonkeyengine.org/t/white-screen-on-context-restart/43866/28?u=markil3
Now most of the code that goes into initializing the renderer is now repeated every time. This is accomplished by moving most of the logic from the initContextFirstTime() methods into a new initContext(boolean) method. On the first boot, the code ultimately executes the same way. However, every context restart calls initContext(false) now as well. This will repeat all the code from before save for the creation of the GL and Renderer instances as well as input initialization.

At the moment, SimpleApplication now has a new default binding for the TAB key that restarts the context. This is to make it easier to test various examples, and I plan on removing it before we actually merge it.

This should solve issues #844 and #1445. This commit should also replace PR #1524.

Now most of the code that goes into initializing the renderer
@stephengold stephengold added this to the v3.4.0 milestone Apr 16, 2021
@stephengold
Copy link
Member

I confirmed that this PR resolves issue #844, by running the test case from https://hub.jmonkeyengine.org/t/nifty-does-not-properly-display-gui-after-app-restart-when-gamma-correction-is-enabled/40213/19 and repeatedly pressing the 'T' and 'Tab' keys.

@stephengold
Copy link
Member

I ran TestContextRestart with both jme3-lwjgl and jme3-lwjgl3, and noticed it behaves differently depending on the LWJGL version.

With jme3-lwjgl (LWJGL 2.9.3) pressing 'Tab' causes the box to disappear. With jme3-lwjgl3 (LWJGL 3.2.3 build 13) pressing 'Tab' causes a momentary flicker but the box does not disappear.

@stephengold
Copy link
Member

@Markil3 do you intend to act on my comments?

@Markil3
Copy link
Contributor Author

Markil3 commented Apr 29, 2021

Things have gotten a bit crazy over on my end. I'll try to finish these by the weekend, though. Sorry! Completely forgot!

@Markil3
Copy link
Contributor Author

Markil3 commented Apr 29, 2021

So, I investigated your issue, and it seems to be linked to the AppSettings.setRenderer setting. I can change this to whatever I want on jme3-lwjgl3, but trying to set this on jme3-lwjgl seems to cause problems. I'm investigating it now, but at least it seems to work on the recommended library.

@Markil3
Copy link
Contributor Author

Markil3 commented Apr 29, 2021

Well, this is interesting: moving the call to initialize the GL renderer so that it only triggers upon the first run seems to solve the issue. However, trying to do the same on the jme3-lwjgl3 library breaks it if I'm using something other than OpenGL 2.0.

No idea what's going on underneath, but it works without any major problems, so I guess I'll just apply that fix.

Apparently, this seems to fix the issue of LWJGL not rendering to the new display. However, trying to apply this fix to jme3-lwjgl3 actually creates the problem there.
}

/**
* Reinitializes the relevent details of the context. For internal use only.
Copy link
Member

Choose a reason for hiding this comment

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

Please correct the spelling of "relevant". "Relevent" is not a word in English.

@stephengold
Copy link
Member

In the interest of keeping things moving, I've decided to integrate this and fix the spelling later.

@stephengold stephengold merged commit 1b56889 into jMonkeyEngine:master May 5, 2021
stephengold pushed a commit that referenced this pull request May 5, 2021
* Refactors the context restart code.

Now most of the code that goes into initializing the renderer

* Fixed a misleading comment in lwjgl3's LwjglWindow

* Adds documentation to the LwjglContext methods.

* Cleans up the code and comments.

* Moves the renderer initialization for jme3-lwjgl to just the first run.

Apparently, this seems to fix the issue of LWJGL not rendering to the new display. However, trying to apply this fix to jme3-lwjgl3 actually creates the problem there.
@stephengold
Copy link
Member

@Markil3 Thank you for contributing to JMonkeyEngine!

@stephengold
Copy link
Member

Verified the fix in v3.4.0-beta4.

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.

Nifty Gui is shown too dark in jMonkeyEngine when app is restarted AND gamma correction is enabled

2 participants