david-vanderson / dvui

Other
429 stars 35 forks source link

Add ability to enable `SUPPORT_CUSTOM_FRAME_CONTROL` for the raylib backend #144

Closed VisenDev closed 1 month ago

VisenDev commented 1 month ago

See here

This might help us implement low fps support for the raylib backend. I would also like to be able to implement custom frame control for projects using dvui, so some way to tell dvui to enable this flag when compiling build.zig would be nice.

VisenDev commented 1 month ago

I'd also like to enable this flag

Perhaps we need to create some way for applications to pass backend build flags to dvui

david-vanderson commented 1 month ago

Is there a reason not to turn on those flags all the time? My thinking is that if you want them, then we should make them the default, and deal with configuration options when someone shows up needing otherwise.

VisenDev commented 1 month ago

Is there a reason not to turn on those flags all the time? My thinking is that if you want them, then we should make them the default, and deal with configuration options when someone shows up needing otherwise.

Some of these flags are mutually exclusive, so it wouldn't make sense to enable them both at the same time

iacore commented 1 month ago

Perhaps we need to create some way for applications to pass backend build flags to dvui

We already have

https://github.com/david-vanderson/dvui/blob/14e6a0c64f72648beda1330dc0f7caee793bb40a/examples/raylib-standalone.zig#L26-L31

VisenDev commented 1 month ago

Sorry @iacore I accidentally clicked edit instead of quote reply and didn't realize it

We already have https://github.com/david-vanderson/dvui/blob/14e6a0c64f72648beda1330dc0f7caee793bb40a/examples/raylib-standalone.zig#L26-L31

This lets you pass initialization options, I'm talking about specific cflags to use when building raylib.

Thinking about this some more, perhaps the most flexible solution to this general problem is to give dvui some sort of project integration build option (similiar to zig's system integration build option).

When project integration is set, dvui would avoid building a particular dependency, and rely on the user's build.zig to compile and link dependencies correctly

VisenDev commented 1 month ago

Okay so after experimenting with build.zig a bit, I've discovered that b.option() values for a zig dependency can be specified in the args parameter of b.dependency.

This means that we could do something like this in dvui's build.zig

const skip_building = b.option([]const u8, `"skip_building","A CSV list of values that dvui should skip building") orelse "";

if(find_substring(skip_building, "raylib") == false) {
//build raylib here
}

Then in my project, I can do something like this

const dvui = b.dependency("dvui", .{.skip_building = "raylib,raygui"});

// Now I can build custom build raylib in my build.zig 
...
//Link dvui against raylib once raylib is built
    const backend = dvui.module("backend");
    backend.linkLibrary(raylib.artifact("raylib"));
david-vanderson commented 1 month ago

Now I get what you are trying to do. That sounds reasonable to me!