Skip to content

Raylib bindings failing to build when animating a model #17

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

Open
diegoxter opened this issue May 8, 2025 · 8 comments
Open

Raylib bindings failing to build when animating a model #17

diegoxter opened this issue May 8, 2025 · 8 comments

Comments

@diegoxter
Copy link

diegoxter commented May 8, 2025

V version: V 0.4.10 1070378, press to see full `v doctor` output
V full version V 0.4.10 1070378a4693876e685b4805f11c16fd86237e2b.1070378
OS linux, Debian GNU/Linux 12 (bookworm)
Processor 4 cpus, 64bit, little endian, Intel(R) Core(TM) i5-2520M CPU @ 2.50GHz
Memory 1.27GB/3.7GB
V executable /home/adriego/Code/tools/v/v
V last modified time 2025-05-07 16:16:50
V home dir OK, value: /home/adriego/Code/tools/v
VMODULES OK, value: /home/adriego/.vmodules
VTMP OK, value: /tmp/v_1000
Current working dir OK, value: /home/adriego/Code/projects/vling
Git version git version 2.39.5
V git status 1070378a
.git/config present true
cc version cc (Debian 12.2.0-14) 12.2.0
gcc version gcc (Debian 12.2.0-14) 12.2.0
clang version N/A
tcc version tcc version 0.9.28rc 2025-02-13 HEAD@f8bd136d (x86_64 Linux)
tcc git status thirdparty-linux-amd64 696c1d84
emcc version N/A
glibc version ldd (Debian GLIBC 2.36-9+deb12u10) 2.36

What did you do?
./v -g -o vdbg cmd/v && ./vdbg main.v && main

module main

import raylib as r

const screen_width = 800
const screen_height = 450
const max_columns = 20

fn main() {
	r.init_window(screen_width, screen_height, 'Test')

	mut camera := r.Camera{}
	camera.position = r.Vector3{f32(0.0), f32(2.0), f32(4.0)}
	camera.target = r.Vector3{f32(0.0), f32(2.0), f32(0.0)}
	camera.up = r.Vector3{f32(0.0), f32(1.0), f32(0.0)}
	camera.fovy = f32(60.0)
	camera.projection = int(r.CameraProjection.camera_perspective)

	// Animations
	filepath :="assets/Rogue.gltf"
	model := r.load_model(filepath)
	mut anims := &r.ModelAnimation{};
	anim_count := 0;
	anims = r.load_model_animations(filepath, &anim_count);
	mut current_frame := 0;
	//

	mut camera_mode := r.CameraMode.camera_first_person

	mut heights := [max_columns]f32{}
	mut positions := [max_columns]r.Vector3{}
	mut colors := [max_columns]r.Color{}

	mut i := 0
	for i < max_columns {
		heights[i] = f32(r.get_random_value(1, 12))
		positions[i] = r.Vector3{f32(r.get_random_value(-15, 15)), heights[i] / 2.0, f32(r.get_random_value(-15,
			15))}
		colors[i] = r.Color{u8(r.get_random_value(20, 255)), u8(r.get_random_value(10,
			255)), 30, 255}

		i++
	}

	// TODO disable this on prod
	r.enable_cursor()
	r.set_target_fps(60)

	for (!r.window_should_close()) {
		if r.is_key_pressed(int(r.KeyboardKey.key_two)) {
			camera_mode = r.CameraMode.camera_first_person
			camera.up = r.Vector3{f32(0.0), f32(1.0), f32(0.0)}
		}

		if r.is_key_pressed(int(r.KeyboardKey.key_three)) {
			camera_mode = r.CameraMode.camera_third_person
			camera.up = r.Vector3{f32(0.0), f32(1.0), f32(0.0)}
		}

			 if r.is_key_pressed(int(r.KeyboardKey.key_space))
        {
            current_frame++;
            unsafe {
							r.update_model_animation(model, anims[0], current_frame)
							if current_frame >= anims[0].frame_count {
								current_frame = 0
							}
						}
        }

		r.update_camera(&camera, int(camera_mode))

		r.begin_drawing()
		r.clear_background(r.raywhite)

		r.begin_mode_3d(camera)
		r.draw_plane(r.Vector3{f32(0.0), f32(0.0), f32(0.0)}, r.Vector2{f32(32.0), f32(32.0)},
			r.lightgray)
		r.draw_cube(r.Vector3{f32(-16.0), f32(2.5), f32(0.0)}, f32(1.0), f32(5.0), f32(32.0),
			r.blue)
		r.draw_cube(r.Vector3{f32(16.0), f32(2.5), f32(0.0)}, f32(1.0), f32(5.0), f32(32.0),
			r.lime)
		r.draw_cube(r.Vector3{f32(0.0), f32(2.5), f32(16.0)}, f32(32.0), f32(5.0), f32(1),
			r.gold)

		i = 0
		for i < max_columns {
			r.draw_cube(positions[i], f32(2.0), heights[i], f32(2.0), colors[i])
			r.draw_cube_wires(positions[i], f32(2.0), heights[i], f32(2.0), r.maroon)

			i++
		}

		// Draw player cube
		if camera_mode == r.CameraMode.camera_third_person {
			r.draw_cube(camera.target, f32(0.5), f32(0.5), f32(0.5), r.purple)
			r.draw_cube_wires(camera.target, f32(0.5), f32(0.5), f32(0.5), r.darkpurple)
		}

			r.draw_model(
				model,
				r.Vector3{f32(0.0), f32(0), f32(0.0)},
				f32(1),
				r.white
			)

		r.end_mode_3d()

		// r.draw_text("Haha!", 190, 200, 20, r.lightgray)

		r.end_drawing()
	}

	r.unload_model(model)
	r.unload_model_animations(anims, anim_count)
	r.close_window()
}

What did you see?

================== C compilation error (from tcc): ==============
cc: /tmp/v_1000/main.01JTPXA4B4Y2Y7NHCKZNASMWE8.tmp.c:6271: error: field not found: bone_count
=================================================================
(You can pass `-cg`, or `-show-c-output` as well, to print all the C error messages).
builder error: 
==================
C error found. It should never happen, when compiling pure V code.
This is a V compiler bug, please report it using `v bug file.v`,
or goto https://github.com/vlang/v/issues/new/choose .
You can also use #help on Discord: https://discord.gg/vlang .

What did you expect to see?

Raylib creating the window and allowing me to check on the animation by pressing the spacebar

Note

You can use the 👍 reaction to increase the issue's priority for developers.

Please note that only the 👍 reaction to the issue itself counts as a vote.
Other reactions and those to comments will not be taken into account.

Copy link

Connected to Huly®: V_0.6-22805

@jorgeluismireles
Copy link

My installation of raylib can't find file <raylib.h>. I can't find docs explaining how to proceed.

$ v install raylib
Scanning `raylib`...
Updating module `raylib` in `~/.vmodules/raylib`...
Updated module `raylib`.
$ v run 24434.v 
builder error: Header file <raylib.h>, needed for module `raylib` was not found. Please install the 
corresponding development headers.

@diegoxter
Copy link
Author

My installation of raylib can't find file <raylib.h>. I can't find docs explaining how to proceed.

$ v install raylib
Scanning `raylib`...
Updating module `raylib` in `~/.vmodules/raylib`...
Updated module `raylib`.
$ v run 24434.v 
builder error: Header file <raylib.h>, needed for module `raylib` was not found. Please install the 
corresponding development headers.

You need to install the headers, check raylib docs. The V package just install the wrapper, not the library per se

@jorgeluismireles
Copy link

jorgeluismireles commented May 8, 2025

Follow instructions from https://github.com/raysan5/raylib/wiki/Working-on-GNU-Linux

has no member named ‘bone_count’; did you mean ‘boneCount’?:

/tmp/v_1000/24434.01JTR9G0MRNW4CHSKA6HA5X60N.tmp.c:6271: error: field not found: bone_count
=================================================================================
======== Output of the C Compiler (cc) ========
/tmp/v_1000/24434.01JTR9G0MRNW4CHSKA6HA5X60N.tmp.c: In function ‘main__main’:
/tmp/v_1000/24434.01JTR9G0MRNW4CHSKA6HA5X60N.tmp.c:6271:101: error: ‘raylib__ModelAnimation’ {aka ‘struct ModelAnimation’} has no member named ‘bone_count’; did you mean ‘boneCount’?
 6271 |         raylib__ModelAnimation* anims = ((raylib__ModelAnimation*)memdup(&(raylib__ModelAnimation){.bone_count = 0,.frame_count = 0,.bones = 0,.frame_poses = 0,.name = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},}, sizeof(raylib__ModelAnimation)));

@diegoxter
Copy link
Author

Im trying to figure things out but it seems like its a wrapper error, not necessarily an issue with the compiler

@jorgeluismireles
Copy link

Seems wrapper is not converted some fields to C pascalCase

ModelAnimation’} has no member named ‘frame_count’; did you mean ‘frameCount’?
ModelAnimation’} has no member named ‘frame_poses’; did you mean ‘framePoses’?
ModelAnimation’} has no member named ‘frame_count’; did you mean ‘frameCount’?

@diegoxter
Copy link
Author

maybe @spytheman or @EmmaTheMartian can help (even though this should be reported on the raylib github)

@diegoxter
Copy link
Author

For context:

	model_animations := r.load_model_animations(filepath, &anims_count)
	unsafe {
			println(typeof(model_animations[anim_index].frame_count))
			println(model_animations[0].frame_count)
	}

the type of the frame_count is correctly printed as an int, but when trying to access it it fails

@spytheman spytheman transferred this issue from vlang/v May 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants