[WIP] Include renderer inside the library instead of explicitly providing them at project level#17
Open
Logickin-Lambda wants to merge 4 commits into
Open
[WIP] Include renderer inside the library instead of explicitly providing them at project level#17Logickin-Lambda wants to merge 4 commits into
Logickin-Lambda wants to merge 4 commits into
Conversation
When I see this binding, the first thing comes in mind is that we need to ship our own renderer for each backend, but trying to translate the original C renderer manually and individually is not an efficient approach which everyone who have their own renderer might written differently, and they need to update their own version of renderer with their own code. With this commit, users now have an option to either using the original approach, or they can specify a specific renderer for their project with an enum, similar to how zgui works.
The new README let users know that not only they can pick their own renderer with the recent update, but their original approach remain unaffected, letting them freedom to experiment their own backend that is not included in the library.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
As suggested previously, I was thinking of putting the renderer backend inside the library so that users can use the library out of the box by selecting a preferred backend along with the related dependency instead of providing the renderer from their ends.
So far, I have gotten a working solution, and all you need is to choose a renderer at build.zig in your projects as shown:
At the application level, instead of loading your renderer file, all you need is to fetch the renderer from the zclay module as shown:
This works because under the hood, the library picks and selectively compile the renderer based on the switch statement, controlled by the .renderer option:
Where the
@import("zclay_options").rendereris an enum defined in the build.zig of the library:As you can see, with this implementation, for every new backend added into the library, the contributors can simply add a new name into the enum and loading their renderer at root.zig by expending the switch statement with their imports.
To test the upgrade, you may build the example
raylib-sidebar-containerfrom my fork to see how the new option behaves and to verify the result. I didn't updateraylib-clay-official-websitebecause I want to show you that the original method still works so that it offers a way for users to test and build their own renderer.I am a bit tired now, so my speaking is a bit incoherent. Please let me know if you have any questions.