-
-
Notifications
You must be signed in to change notification settings - Fork 711
Add header builders script for env.GLSL_HEADER and SVG icons
#1789
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
f766129 to
5317634
Compare
5317634 to
51008e1
Compare
dsnopek
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've spent some more time thinking about this, I think I'm on-board with it now.
When we talked about it last time, I was confusing GLSL_HEADER (which I've actually never used before) with GLES3_GLSL. What's in here does appear to match what we have in Godot.
The SVG bit is a little bit different than in Godot, but analogous. I do wonder if we should provide a SCons builder for it? We have builders in godot-cpp than aren't in Godot, for example GodotCPPBindings and GodotCPPDocData. This could be GodotCPPSVGIcon or something like that? But I think it'd be fine moving forward without that - we can always add it later if we want
|
Would this be something I add to the CMAKE files like the documentation tools? |
|
@enetheru Yes, these are just Python functions. As long as CMake can run them before the rest compiles, that is sufficient. |
|
Cherry-picked for 4.5 in PR #1870 |
|
Cherry-picked for 4.4 in PR #1871 |
Sometimes it is desired to have non-C++ files compiled into C++ code and available for use there. For example, you may want GLSL files available as Strings to be used at runtime. For example, you may want SVG files available as Strings to allow generating multiple sizes at runtime (important for the editor to be able to display things at any scale).
Each of these functionalities is already available when using a Godot engine module:
glsl_builders.pyto generate these. This is exposed withenv.GLSL_HEADER, meaning you call into it in a SConscript or SCsub likeenv.GLSL_HEADER("path/to/some_file.glsl")and it will generate a filesome_file.glsl.gen.hwithinline constexpr const char *some_file_shader_glsl = ...in it.[icons]in the.gdextensionfile provides icons for classes. This fulfills the most common use case, however...This PR adds a new file to the
toolsfolder calledheader_builders.pywhich mimics the basic functionality of Godot's functions for GLSL header builders and SVG icon header builders. The GLSL header is used exactly like it is in the engine, withenv.GLSL_HEADER("path/to/some_file.glsl"). This is registered ingodotcpp.pywith"GLSL_HEADER": Builder(.As for the SVG icon builders, the engine does not provide an API for modules because it's supposed to be handled automatically, and so the function isn't needed in modules. Therefore, if the user needs non-class resizable SVG icons at runtime, calling into this function can be left as a godot-cpp-specific part of a user's buildsystem code, like this:
Note that the code in this PR cannot simply be an exact copy of the engine functions. Those functions have many dependencies on other functions which are not necessary in GDExtension, such as the code to generate the copyright headers. The code in this PR is a lot simpler. Also, the code in this PR is much more generalized. The GLSL code in Godot is hard-coded for GLSL, but the function in this PR can be used for non-GLSL as well. As for the SVG icons, the code in the engine is duplicated for editor icons and default theme icons, and each is hard-coded for each of those, while the code in this PR will work with any destination file.
The motivation behind this PR is the needs of the Godot 4D module/extension, but this benefits all extensions.