mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-18 11:54:59 -04:00
only poll rendering if enabled
This commit is contained in:
parent
305e0fcb75
commit
68ff96739d
@ -18,7 +18,6 @@ import de.bixilon.minosoft.gui.eros.dialog.ErosErrorReport.Companion.report
|
||||
import de.bixilon.minosoft.gui.rendering.modding.events.WindowCloseEvent
|
||||
import de.bixilon.minosoft.gui.rendering.sound.AudioPlayer
|
||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
||||
import de.bixilon.minosoft.terminal.RunConfiguration
|
||||
import de.bixilon.minosoft.util.RenderPolling
|
||||
import de.bixilon.minosoft.util.logging.Log
|
||||
import de.bixilon.minosoft.util.logging.LogLevels
|
||||
@ -34,7 +33,7 @@ class Rendering(private val connection: PlayConnection) {
|
||||
Log.log(LogMessageType.RENDERING_GENERAL, LogLevels.INFO) { "Hello LWJGL ${Version.getVersion()}!" }
|
||||
latch.inc()
|
||||
this.latch = latch
|
||||
if (RunConfiguration.OPEN_Gl_ON_FIRST_THREAD) {
|
||||
if (RenderPolling.ENABLED) {
|
||||
RenderPolling.rendering = this
|
||||
RenderPolling.RENDERING_LATCH.dec()
|
||||
return
|
||||
@ -45,7 +44,7 @@ class Rendering(private val connection: PlayConnection) {
|
||||
fun start() {
|
||||
val latch = this.latch ?: throw IllegalStateException("Rendering not initialized yet!")
|
||||
startAudioPlayerThread(latch)
|
||||
if (RunConfiguration.OPEN_Gl_ON_FIRST_THREAD) {
|
||||
if (RenderPolling.ENABLED) {
|
||||
startRenderWindow(latch)
|
||||
} else {
|
||||
startRenderWindowThread(latch)
|
||||
|
@ -16,16 +16,21 @@ package de.bixilon.minosoft.util
|
||||
import de.bixilon.kutil.latch.CountUpAndDownLatch
|
||||
import de.bixilon.minosoft.Minosoft
|
||||
import de.bixilon.minosoft.gui.rendering.Rendering
|
||||
import de.bixilon.minosoft.terminal.RunConfiguration
|
||||
|
||||
object RenderPolling {
|
||||
val RENDERING_LATCH = CountUpAndDownLatch(Int.MAX_VALUE shr 1)
|
||||
var rendering: Rendering? = null
|
||||
val ENABLED = RunConfiguration.OPEN_Gl_ON_FIRST_THREAD
|
||||
|
||||
|
||||
/**
|
||||
* Polls rendering (if opengl context is forced on the main thread)
|
||||
* Eventually polls rendering (if opengl context is forced on the main thread)
|
||||
*/
|
||||
internal fun pollRendering() {
|
||||
if (!ENABLED) {
|
||||
return
|
||||
}
|
||||
check(Thread.currentThread() == Minosoft.MAIN_THREAD) { "Current thread is not the main thread!" }
|
||||
while (true) {
|
||||
RENDERING_LATCH.waitForChange()
|
||||
|
Loading…
x
Reference in New Issue
Block a user