mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-18 03:44:54 -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.modding.events.WindowCloseEvent
|
||||||
import de.bixilon.minosoft.gui.rendering.sound.AudioPlayer
|
import de.bixilon.minosoft.gui.rendering.sound.AudioPlayer
|
||||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
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.RenderPolling
|
||||||
import de.bixilon.minosoft.util.logging.Log
|
import de.bixilon.minosoft.util.logging.Log
|
||||||
import de.bixilon.minosoft.util.logging.LogLevels
|
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()}!" }
|
Log.log(LogMessageType.RENDERING_GENERAL, LogLevels.INFO) { "Hello LWJGL ${Version.getVersion()}!" }
|
||||||
latch.inc()
|
latch.inc()
|
||||||
this.latch = latch
|
this.latch = latch
|
||||||
if (RunConfiguration.OPEN_Gl_ON_FIRST_THREAD) {
|
if (RenderPolling.ENABLED) {
|
||||||
RenderPolling.rendering = this
|
RenderPolling.rendering = this
|
||||||
RenderPolling.RENDERING_LATCH.dec()
|
RenderPolling.RENDERING_LATCH.dec()
|
||||||
return
|
return
|
||||||
@ -45,7 +44,7 @@ class Rendering(private val connection: PlayConnection) {
|
|||||||
fun start() {
|
fun start() {
|
||||||
val latch = this.latch ?: throw IllegalStateException("Rendering not initialized yet!")
|
val latch = this.latch ?: throw IllegalStateException("Rendering not initialized yet!")
|
||||||
startAudioPlayerThread(latch)
|
startAudioPlayerThread(latch)
|
||||||
if (RunConfiguration.OPEN_Gl_ON_FIRST_THREAD) {
|
if (RenderPolling.ENABLED) {
|
||||||
startRenderWindow(latch)
|
startRenderWindow(latch)
|
||||||
} else {
|
} else {
|
||||||
startRenderWindowThread(latch)
|
startRenderWindowThread(latch)
|
||||||
|
@ -16,16 +16,21 @@ package de.bixilon.minosoft.util
|
|||||||
import de.bixilon.kutil.latch.CountUpAndDownLatch
|
import de.bixilon.kutil.latch.CountUpAndDownLatch
|
||||||
import de.bixilon.minosoft.Minosoft
|
import de.bixilon.minosoft.Minosoft
|
||||||
import de.bixilon.minosoft.gui.rendering.Rendering
|
import de.bixilon.minosoft.gui.rendering.Rendering
|
||||||
|
import de.bixilon.minosoft.terminal.RunConfiguration
|
||||||
|
|
||||||
object RenderPolling {
|
object RenderPolling {
|
||||||
val RENDERING_LATCH = CountUpAndDownLatch(Int.MAX_VALUE shr 1)
|
val RENDERING_LATCH = CountUpAndDownLatch(Int.MAX_VALUE shr 1)
|
||||||
var rendering: Rendering? = null
|
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() {
|
internal fun pollRendering() {
|
||||||
|
if (!ENABLED) {
|
||||||
|
return
|
||||||
|
}
|
||||||
check(Thread.currentThread() == Minosoft.MAIN_THREAD) { "Current thread is not the main thread!" }
|
check(Thread.currentThread() == Minosoft.MAIN_THREAD) { "Current thread is not the main thread!" }
|
||||||
while (true) {
|
while (true) {
|
||||||
RENDERING_LATCH.waitForChange()
|
RENDERING_LATCH.waitForChange()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user