gen2brain / raylib-go

Go bindings for raylib, a simple and easy-to-use library to enjoy videogames programming.
zlib License
1.55k stars 159 forks source link

Overriding RL_CULL_DISTANCE_FAR #269

Closed irfanka closed 11 months ago

irfanka commented 1 year ago

Hi!

I'm new to Golang and raylib-go, so this might be a dumb question but..

Is there any way I can override RL_CULL_DISTANCE_FAR? I'm using CameraThirdPerson and am trying to increase the render distance.

Thanks!

gen2brain commented 1 year ago

Sure, fork the repo and change whatever you want. Of course, there is no option, not sure what it does actually.

gen2brain commented 1 year ago

With C, you can do whatever you want, raylib-go needs to expose the option, and not many users if at all will want to change that.

irfanka commented 1 year ago

fork the repo and change whatever you want

Yup, that's what I ended up doing.

not sure what it does actually

Controls the position of the far clipping plane of the camera frustum. Basically how far the camera will render; any geometry that's farther than RL_CULL_DISTANCE_FAR will simply not be rendered.

It is a bit weird that this is not exposed as an option; it's not that uncommon to tweak this in games. For example, if you're making an open-world game (or just a very large game level), you'd want this value to be a lot higher than raylib default (1000.0), in order to render distant terrain and such...

gen2brain commented 1 year ago

There are already many options in config header that user can adjust, but only in C raylib. Many of those doesn't make sense to implement as Go tags. This one is something that is not even in C config. So, it will not happen here, sorry.

irfanka commented 1 year ago

What do you mean it's not in C config?

raylib-go/raylib/config.h : line 111

https://github.com/gen2brain/raylib-go/blob/9def9b04c9ec9858224f934f341e17954f071a5e/raylib/config.h#L111C17-L111C17

gen2brain commented 1 year ago

Sorry, I don't follow all the options for some years, if it is, and you want to be exposed, PR is welcome. I will not spend my time on this.

irfanka commented 1 year ago

Well, it's probably a better idea to figure out a generic way to override any option in config.h, instead of just exposing this single one.

What do you think would be the right way to do that? cgo CFLAGS?

gen2brain commented 1 year ago

Well, generic way is Go tags. There are already examples in this repo. I don't think there is a better way, but fill free to prove me wrong.

gen2brain commented 1 year ago

Of course, you can ignore everything that is defined and pass to CGO_CFLAGS whatever you want. It is not related to any change in this repo.

gen2brain commented 11 months ago

Ok, just tested with CGO_CFLAGS="-DRL_CULL_DISTANCE_FAR=500.0" go build and it does work, it shows redefined warnings. For such options that seems to be the best method.

lukebayes commented 2 months ago

Just in case anyone else bumps into this issue.

I struggled to get this working from my C project until I added this to my own CMakeLists.txt file:

target_compile_definitions("raylib" PUBLIC "RL_CULL_DISTANCE_FAR=10000.0")