diff --git a/client/src/main/java/xyz/chunkstories/client/ClientImplementation.kt b/client/src/main/java/xyz/chunkstories/client/ClientImplementation.kt index c90c0a14..e7776c7b 100644 --- a/client/src/main/java/xyz/chunkstories/client/ClientImplementation.kt +++ b/client/src/main/java/xyz/chunkstories/client/ClientImplementation.kt @@ -19,7 +19,6 @@ 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 @@ -27,7 +26,6 @@ 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.* @@ -151,60 +149,10 @@ class ClientImplementation internal constructor(val arguments: Map) { - val argumentsMap = mutableMapOf() - 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()) - } - } } diff --git a/client/src/main/java/xyz/chunkstories/client/Launcher.kt b/client/src/main/java/xyz/chunkstories/client/Launcher.kt new file mode 100644 index 00000000..71bcbfa9 --- /dev/null +++ b/client/src/main/java/xyz/chunkstories/client/Launcher.kt @@ -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) { + val argumentsMap = mutableMapOf() + 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()) +} diff --git a/client/src/main/java/xyz/chunkstories/graphics/opengl/OpenglGraphicsBackend.kt b/client/src/main/java/xyz/chunkstories/graphics/opengl/OpenglGraphicsBackend.kt index 1e47b784..cba49293 100644 --- a/client/src/main/java/xyz/chunkstories/graphics/opengl/OpenglGraphicsBackend.kt +++ b/client/src/main/java/xyz/chunkstories/graphics/opengl/OpenglGraphicsBackend.kt @@ -173,7 +173,7 @@ class OpenglGraphicsBackend(graphicsEngine: GraphicsEngineImplementation, window val implemClass: Class> = 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) } @@ -183,7 +183,7 @@ class OpenglGraphicsBackend(graphicsEngine: GraphicsEngineImplementation, window val new: OpenglDispatchingSystem = 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) @@ -207,4 +207,4 @@ class OpenglGraphicsBackend(graphicsEngine: GraphicsEngineImplementation, window var debugMode = true val logger = LoggerFactory.getLogger("client.gfx_gl") } -} \ No newline at end of file +} diff --git a/client/src/main/java/xyz/chunkstories/graphics/opengl/graph/OpenglPass.kt b/client/src/main/java/xyz/chunkstories/graphics/opengl/graph/OpenglPass.kt index ef3ecd19..25b56504 100644 --- a/client/src/main/java/xyz/chunkstories/graphics/opengl/graph/OpenglPass.kt +++ b/client/src/main/java/xyz/chunkstories/graphics/opengl/graph/OpenglPass.kt @@ -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 @@ -60,11 +61,16 @@ class OpenglPass(val backend: OpenglGraphicsBackend, val renderTask: OpenglRende val drawingSystem = backend.createDrawingSystem(this, registeredSystem as RegisteredGraphicSystem) drawingSystems.add(drawingSystem) } else if (DispatchingSystem::class.java.isAssignableFrom(registeredSystem.clazz)) { - val dispatchingSystem = backend.getOrCreateDispatchingSystem(renderTask.renderGraph.dispatchingSystems, registeredSystem as RegisteredGraphicSystem) - 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) + 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 ?") } @@ -191,4 +197,4 @@ class OpenglPass(val backend: OpenglGraphicsBackend, val renderTask: OpenglRende drawingSystems.forEach(Cleanable::cleanup) dispatchingDrawers.forEach(Cleanable::cleanup) } -} \ No newline at end of file +}