raylib-go icon indicating copy to clipboard operation
raylib-go copied to clipboard

function rl.UpdateCamera() isn't able to move the camera

Open tuzu128 opened this issue 6 months ago • 15 comments
trafficstars

Expected behavior: When I pass rl.CameraFree as a mode to UpdateCamera() and press W/A/S/D it will move me in the corresponding behavior Actual behavior: It dose nothing when I press W/A/S/D.

My system: Alpine linux mesa-25.0.5 6.12.26-1-lts river (wayland) go version go1.24.2 linux/amd64 AMD Ryzen 5 3400G I am on the latest version of raylib-go

You can reproduce it with the flowing code:

package main

import (
	"strconv"

	rl "github.com/gen2brain/raylib-go/raylib"
)

func main() {
	rl.InitWindow(1080, 720, "Raylib")
	defer rl.CloseWindow()
	rl.SetTargetFPS(60)

	var camera rl.Camera3D
	camera.Position = rl.Vector3{X: 10, Y: 10, Z: 10}
	camera.Target = rl.Vector3{X: 0, Y: 0, Z: 0}
	camera.Up = rl.Vector3{X: 0, Y: 1, Z: 0}
	camera.Fovy = 45.0
	camera.Projection = rl.CameraPerspective
	rl.DisableCursor()

	for !rl.WindowShouldClose() {
		rl.UpdateCamera(&camera, rl.CameraFree)

		rl.BeginDrawing()
		{

			rl.ClearBackground(rl.White)

			rl.BeginMode3D(camera)
			{
				rl.DrawCube(rl.Vector3{X: 0, Y: 1, Z: 0}, 2.0, 2.0, 2.0, rl.Brown)
				rl.DrawCubeWires(rl.Vector3{X: 0, Y: 1, Z: 0}, 2.0, 2.0, 2.0, rl.Black)
				rl.DrawGrid(80, 1)
			}
			rl.EndMode3D()

			rl.DrawRectangle(0, 0, 90, 90, rl.Black)
			rl.DrawFPS(0, 0)
			rl.DrawText("X: "+strconv.Itoa(int(camera.Position.X)), 0, 20, 20, rl.White)
			rl.DrawText("Y: "+strconv.Itoa(int(camera.Position.Y)), 0, 40, 20, rl.White)
			rl.DrawText("Z: "+strconv.Itoa(int(camera.Position.Z)), 0, 60, 20, rl.White)
		}
		rl.EndDrawing()
	}
}

or this example .

tuzu128 avatar May 05 '25 11:05 tuzu128

I would also like to add that you can't use the mouse to move.

tuzu128 avatar May 06 '25 06:05 tuzu128

Hello. I have failed to reproduce the issue.

SETUP

  • Linux archlinux 6.14.4-arch1-1
  • AMD Ryzen 7 8845HS w/ Radeon 780M Graphics
  • wayland(GNOME)
  • same go setup as the issuer / updated raylib-go to test out

r3g492 avatar May 06 '25 14:05 r3g492

It works here without any issues. @tuzu128 Can you try something other than river (wayland)?

gen2brain avatar May 07 '25 10:05 gen2brain

It also doesn't work with sway, I can try X11 next.

tuzu128 avatar May 07 '25 10:05 tuzu128

I have now also tried lxqt on X11 And it also doesn't work, it may be a musl lib C problem.

tuzu128 avatar May 07 '25 10:05 tuzu128

You can also try with RGFW and SDL backends.

gen2brain avatar May 07 '25 10:05 gen2brain

I will try it with SDL an another machine also running Alpine, than I can also try something like arch in a VM.

tuzu128 avatar May 08 '25 09:05 tuzu128

I am sorry but I won't be able to get to my computer for about 2 days, I will test it later.

tuzu128 avatar May 08 '25 13:05 tuzu128

It doesn't work using GLFW under fedora distrobox. May I ask how do I compile it using sdl2?

tuzu128 avatar May 10 '25 12:05 tuzu128

@tuzu128 All available build tags are on README page, you use it with -tags.

gen2brain avatar May 10 '25 18:05 gen2brain

It works with SDL, sorry for my late response.

tuzu128 avatar May 14 '25 15:05 tuzu128

Does it work with RGFW? Also, with SDL, does it work with both Wayland and X11? And musl is not related to any of that, right? Anyway, nothing to fix in this repo, but it would be nice if your issue could be pinpointed to something concrete.

gen2brain avatar May 17 '25 03:05 gen2brain

It worked under musl Wayland with SDL. I haven't tried RGFW

tuzu128 avatar May 18 '25 19:05 tuzu128

I managed to reproduce the issue on another laptop. Almost identical software, but it is connected to an external monitor and keyboard. It may be related to this repository, as the camera functions have been rewritten from C. However, it is interesting that it works in both SDL and RGFW, but not in GLFW. I will look into this more when I find the time. @tuzu128, you also have some setup that involves another monitor?

gen2brain avatar Jun 09 '25 13:06 gen2brain

I only have one monitor which is connected to the PC, I am on a desktop.

tuzu128 avatar Jun 09 '25 15:06 tuzu128

recreated this locally myself. for me it was a virtual device being picked up as a gamepad. Keychron Link was being detected as a gamepad

I did not test specific backends though

(I was on windows for my recreation)

DanielACashion avatar Jul 03 '25 06:07 DanielACashion