LWJGL / lwjgl3

LWJGL is a Java library that enables cross-platform access to popular native APIs useful in the development of graphics (OpenGL, Vulkan, bgfx), audio (OpenAL, Opus), parallel computing (OpenCL, CUDA) and XR (OpenVR, LibOVR, OpenXR) applications.
https://www.lwjgl.org
BSD 3-Clause "New" or "Revised" License
4.81k stars 640 forks source link

BGFX Gradle ShaderC wrapper #438

Open SergeySave opened 5 years ago

SergeySave commented 5 years ago

Environment

Description

I wrote a wrapper plugin for BGFX's shaderc for Gradle so that running a task in gradle will result in a set of output files. This is based around/derived from the makefiles on the bgfx GitHub page. However, this Gradle plugin is probably pretty bad (my first gradle plugin), and I am unsure of how to properly publish it. I would like the LWJGL team to take what I have written here and use it to create something of similar functionality built into LWJGL. This would significantly lower the barrier to entry for bgfx in LWJGL.

Small disclaimer: this code was only tested on macOS so there is no guarantee that it will work on linux or windows.

While I don't expect anything to come from this, I hope the team can put it to some sort of use.

Here is a link to my build.gradle file that contains the code.

Some notes about how it works: In the tools directory (default: /tools) it looks for an include directory which contains all of the files in this directory. it also looks for the shaderc executable within tools/macosx, tools/linux, and tools/windows respectively depending on the operating system. It looks for .sc files that are not varying.def.sc files inside of src/main/shaders (can be configured) and runs shaderc on all of them to turn them into each of the enabled output types (by default all). The exported shader files are in binary format and can be read by simply using the loadShader method located in BGFXDemoUtil from LWJGL's demo project.

Thanks for taking the time to read this, and I hope you can manage to find some use for this.

Spasi commented 5 years ago

Hey @SergeySave, this is interesting. Two suggestions:

I'm also not sure how to make this available to bgfx users, ideas are welcome.

SergeySave commented 5 years ago

Alright, I added those two suggestions to the file.

In terms of making this available to bgfx users, if this is made into a proper gradle plugin it could be included in the LWJGL gradle file generator. It could be made to work in such a way where you have to add it by only including the apply plugin line similarly to how you apply the java or kotlin plugins.

Other than that this plugin can also probably be made to clone the bgfx repository (or just the src folder in it) so that it can automatically fetch those include files, however I'm not really sure where it should put these.

Again it should work on windows and linux, but no guarantees.

xtexChooser commented 2 years ago

Looking forward to it!