Closed MatejMagat305 closed 1 year ago
Please create a minimal reproducible example (the least amount of code that still causes the error), otherwise I cannot be sure that the problem is with this library and not with vcl / v itself.
Can you also specify the output of v doctor
please.
Minimal reproducible example:
module main
import irishgreencitrus.raylibv as r
const (
screen_width = 800
screen_height = 450
)
fn main() {
r.init_window(screen_width, screen_height, 'draw.v [core] example - basic window'.str)
r.set_target_fps(60)
mut camera := r.Camera{
position: r.Vector3{0.0, 0.0, 10.0}
target: r.Vector3{0.0, 0.0, 0.0}
up: r.Vector3{0.0, 0.0, 0.0}
fovy: 45.0
projection: r.camera_perspective
}
r.set_camera_mode(camera, r.camera_free)
draw(mut camera)
}
fn draw(mut camera r.Camera) {
for !r.window_should_close() {
care_camera(mut &camera)
r.begin_drawing()
r.clear_background(r.raywhite)
r.begin_mode_3d(r.Camera3D(camera))
r.draw_grid(100, 1.0)
r.draw_circle_3d(r.Vector3{3,3,3}, 5, r.Vector3{(0),0,0}, 0, r.Color{u8(100),255,100,100})
r.end_mode_3d()
r.end_drawing()
}
}
fn care_camera(mut camera &r.Camera) {
r.update_camera(camera)
if r.is_key_down(r.key_z) {
(*camera).target = r.Vector3{0.0, 0.0, 0.0}
} else if r.is_key_down(r.key_left) {
(*camera).target.x--
} else if r.is_key_down(r.key_right) {
(*camera).target.x++
} else if r.is_key_down(r.key_up) {
(*camera).target.y--
} else if r.is_key_down(r.key_down) {
(*camera).target.y++
} else if r.is_key_down(r.key_minus) {
(*camera).target.z--
} else if r.is_key_down(r.key_kp_add) {
(*camera).target.z++
}
}
Is it because I am casting to Camera3D?
The mut
modifier (confusingly) casts camera
to a pointer.
The fixed code snippet from what is causing the error is
r.begin_mode_3d(r.Camera3D(*camera))
This should be a compile time error in V, its not an error in this library.
thank and sorry
as I mension in https://github.com/vlang/v/issues/17401, I have problem compile my program and one error seems like that it is error of compiler, but it can be error of library,
it corespondent with line 32