kool-engine / kool

An OpenGL / WebGPU engine for Desktop JVM, Android and Javascript written in Kotlin
https://fabmax.github.io/kool/kool-js
Apache License 2.0
303 stars 20 forks source link

Feature request - "try Vulkan" #36

Open mqxf opened 1 year ago

mqxf commented 1 year ago

It is basically an option you can put onto the createContext() function, which sets the default rendering engine to vulkan, however, if the setup fails, for example if the GPU doesn't support vulkan, it reverts the rendering engine to OpenGL and creates a new context, closing the second one. That way the GPUs that can support vulkan will have vulkan, and those that cannot will be automatically switched to OpenGL.

Potential name would be a boolean called "autoRevert"

fabmax commented 1 year ago

Yes that would indeed be nice. However, currently the Vulkan backend doesn't support all features (some texture formats are missing, etc.). So for now, using OpenGL is probably the better option in any case. But once I come around improving the Vulkan backend I will integrate something like that.

andrey-zakharov commented 1 year ago

You could easily go with something like this is your Mains:

    val ctx = try {
        createContext {
            assetsBaseDir = assetsDir
            renderBackend = Lwjgl3Context.Backend.VULKAN
            this.title = title
        }
    } catch (e: java.lang.Exception) {
        createContext {
            localAssetPath = assetsDir
            renderBackend = Lwjgl3Context.Backend.OPEN_GL
            this.title = title
        }
    }