Skip to content

Commit

Permalink
Ignore unimplemented renderers in OpenGL backend.
Browse files Browse the repository at this point in the history
  • Loading branch information
dector committed Nov 3, 2019
1 parent 4efee8a commit 5053f48
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 62 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,13 @@ import xyz.chunkstories.api.util.configuration.Configuration
import xyz.chunkstories.client.glfw.GLFWWindow
import xyz.chunkstories.client.ingame.IngameClientImplementation
import xyz.chunkstories.content.GameContentStore
import xyz.chunkstories.graphics.GraphicsBackendsEnum
import xyz.chunkstories.graphics.GraphicsEngineImplementation
import xyz.chunkstories.gui.ClientGui
import xyz.chunkstories.gui.layer.LoginUI
import xyz.chunkstories.input.lwjgl3.Lwjgl3ClientInputsManager
import xyz.chunkstories.sound.ALSoundManager
import xyz.chunkstories.task.WorkerThreadPool
import xyz.chunkstories.util.LogbackSetupHelper
import xyz.chunkstories.util.VersionInfo
import java.io.File
import java.text.SimpleDateFormat
import java.util.*
Expand Down Expand Up @@ -151,60 +149,10 @@ class ClientImplementation internal constructor(val arguments: Map<String, Strin
}

override fun print(message: String) {
chatLogger.info(message+Math.random())
chatLogger.info(message + Math.random())
}

override fun logger(): Logger {
return this.logger
}

companion object {

@JvmStatic
fun main(launchArguments: Array<String>) {
val argumentsMap = mutableMapOf<String, String>()
for (launchArgument in launchArguments) {
if(launchArgument.startsWith("--")) {
val stripped = launchArgument.removePrefix("--")

if(launchArgument.contains('=')) {
val firstIndex = stripped.indexOf('=')
val argName = stripped.substring(0, firstIndex)
val argValue = stripped.substring(firstIndex + 1, stripped.length).removeSurrounding("\"")

argumentsMap[argName] = argValue
} else {
argumentsMap[stripped] = "true"
}
} else {
println("Unrecognized launch argument: $launchArgument")
}
}

if(argumentsMap["help"] != null) {
printHelp()
System.exit(0)
}

ClientImplementation(argumentsMap)
}

private fun printHelp() {
println("""
Chunk Stories Client version: ${VersionInfo.versionJson.verboseVersion}
Available commandline options:
--core=... Specifies the folder/file to use as the base content
--mods=... Specifies some mods to load
--backend=[${GraphicsBackendsEnum.values()}] Forces a specific backend to be used.
Backend-specific options:
Vulkan-specific options:
--enableValidation Enables the validation layers
OpenGL-specific options:
""".trimIndent())
}
}
}
51 changes: 51 additions & 0 deletions client/src/main/java/xyz/chunkstories/client/Launcher.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package xyz.chunkstories.client

import xyz.chunkstories.graphics.GraphicsBackendsEnum
import xyz.chunkstories.util.VersionInfo
import kotlin.system.exitProcess

fun main(launchArguments: Array<String>) {
val argumentsMap = mutableMapOf<String, String>()
for (launchArgument in launchArguments) {
if (launchArgument.startsWith("--")) {
val stripped = launchArgument.removePrefix("--")

if (launchArgument.contains('=')) {
val firstIndex = stripped.indexOf('=')
val argName = stripped.substring(0, firstIndex)
val argValue = stripped.substring(firstIndex + 1, stripped.length).removeSurrounding("\"")

argumentsMap[argName] = argValue
} else {
argumentsMap[stripped] = "true"
}
} else {
println("Unrecognized launch argument: $launchArgument")
}
}

if (argumentsMap["help"] != null) {
printHelp()
exitProcess(0)
}

ClientImplementation(argumentsMap)
}

private fun printHelp() {
println("""
Chunk Stories Client version: ${VersionInfo.versionJson.verboseVersion}
Available commandline options:
--core=... Specifies the folder/file to use as the base content
--mods=... Specifies some mods to load
--backend=[${GraphicsBackendsEnum.values()}] Forces a specific backend to be used.
Backend-specific options:
Vulkan-specific options:
--enableValidation Enables the validation layers
OpenGL-specific options:
""".trimIndent())
}
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ class OpenglGraphicsBackend(graphicsEngine: GraphicsEngineImplementation, window
val implemClass: Class<out OpenglDispatchingSystem<out Representation>> = when(dispatchingSystemRegistration.clazz) {
ModelsRenderer::class.java -> OpenglModelsDispatcher::class
ChunksRenderer::class.java -> OpenglChunkRepresentationsDispatcher::class
else -> throw Exception("Unimplemented system on this backend: ${dispatchingSystemRegistration.clazz}")
else -> throw NotImplementedError("Unimplemented system on this backend: ${dispatchingSystemRegistration.clazz}")
}.java

val existing = list.find { implemClass.isAssignableFrom(it::class.java) }
Expand All @@ -183,7 +183,7 @@ class OpenglGraphicsBackend(graphicsEngine: GraphicsEngineImplementation, window
val new: OpenglDispatchingSystem<out Representation> = when(dispatchingSystemRegistration.clazz) {
ModelsRenderer::class.java -> OpenglModelsDispatcher(this)
ChunksRenderer::class.java -> OpenglChunkRepresentationsDispatcher(this)
else -> throw Exception("Unimplemented system on this backend: ${dispatchingSystemRegistration.clazz}")
else -> throw NotImplementedError("Unimplemented system on this backend: ${dispatchingSystemRegistration.clazz}")
}

list.add(new)
Expand All @@ -207,4 +207,4 @@ class OpenglGraphicsBackend(graphicsEngine: GraphicsEngineImplementation, window
var debugMode = true
val logger = LoggerFactory.getLogger("client.gfx_gl")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import xyz.chunkstories.graphics.opengl.OpenglGraphicsBackend
import xyz.chunkstories.graphics.opengl.systems.OpenglDispatchingSystem
import xyz.chunkstories.graphics.opengl.systems.OpenglDrawingSystem
import xyz.chunkstories.graphics.vulkan.systems.world.ViewportSize
import xyz.chunkstories.gui.logger

class OpenglPass(val backend: OpenglGraphicsBackend, val renderTask: OpenglRenderTask, val declaration: PassDeclaration) : Cleanable {
val drawingSystems: List<OpenglDrawingSystem>
Expand Down Expand Up @@ -60,11 +61,16 @@ class OpenglPass(val backend: OpenglGraphicsBackend, val renderTask: OpenglRende
val drawingSystem = backend.createDrawingSystem(this, registeredSystem as RegisteredGraphicSystem<DrawingSystem>)
drawingSystems.add(drawingSystem)
} else if (DispatchingSystem::class.java.isAssignableFrom(registeredSystem.clazz)) {
val dispatchingSystem = backend.getOrCreateDispatchingSystem(renderTask.renderGraph.dispatchingSystems, registeredSystem as RegisteredGraphicSystem<DispatchingSystem>)
val drawer = dispatchingSystem.createDrawerForPass(this, registeredSystem.dslCode as OpenglDispatchingSystem.Drawer<*>.() -> Unit)

dispatchingSystem.drawersInstances.add(drawer)
dispatchingDrawers.add(drawer)
try {
val dispatchingSystem = backend.getOrCreateDispatchingSystem(renderTask.renderGraph.dispatchingSystems, registeredSystem as RegisteredGraphicSystem<DispatchingSystem>)
val drawer = dispatchingSystem.createDrawerForPass(this, registeredSystem.dslCode as OpenglDispatchingSystem.Drawer<*>.() -> Unit)

dispatchingSystem.drawersInstances.add(drawer)
dispatchingDrawers.add(drawer)
} catch (e: NotImplementedError) {
logger.error("System not implemented in OpenGL backend.", e)
// TODO ignore for now
}
} else {
throw Exception("What is this :$registeredSystem ?")
}
Expand Down Expand Up @@ -191,4 +197,4 @@ class OpenglPass(val backend: OpenglGraphicsBackend, val renderTask: OpenglRende
drawingSystems.forEach(Cleanable::cleanup)
dispatchingDrawers.forEach(Cleanable::cleanup)
}
}
}

0 comments on commit 5053f48

Please sign in to comment.