-
Notifications
You must be signed in to change notification settings - Fork 149
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
Exception using UploadMesh #263
Comments
Hey @Roboadam, as a workaround u can set the GODEBUG environment variable like this: More information in the go docs: https://pkg.go.dev/cmd/cgo#hdr-Passing_pointers |
Here is a "running" example: package main
import (
rl "github.com/gen2brain/raylib-go/raylib"
)
func main() {
rl.InitWindow(800, 450, "Test")
defer rl.CloseWindow()
verticies := []float32{0, 0, 0, 1, 0, 2, 2, 0, 0}
normals := []float32{0, 1, 0, 0, 1, 0, 0, 1, 0}
textcoord := []float32{0, 0, 0.5, 1, 1, 0}
mesh := rl.Mesh{
TriangleCount: 1,
VertexCount: 3,
Vertices: &verticies[0],
Normals: &normals[0],
Texcoords: &textcoord[0],
}
rl.UploadMesh(&mesh, false)
model := rl.LoadModelFromMesh(mesh)
defer rl.UnloadModel(model)
camera := rl.Camera3D{Position: rl.Vector3{X: 5, Y: 5, Z: 5}, Up: rl.Vector3{Y: 1}, Fovy: 45}
for !rl.WindowShouldClose() {
rl.UpdateCamera(&camera, rl.CameraOrbital)
rl.BeginDrawing()
rl.ClearBackground(rl.RayWhite)
rl.BeginMode3D(camera)
rl.DrawModel(model, rl.Vector3{}, 1, rl.Red)
rl.DrawGrid(10, 1)
rl.EndMode3D()
rl.EndDrawing()
}
} But in the end, it is going to crash:
This is because |
Thank you so much for the thorough reply. Setting cgocheck=0 "fixes" it. That makes perfect sense about UnloadModel and the GC not playing nicely together. |
Disclamer: I am a complete novice at golang so this may be a silly issue.
I was trying recreate the models/models_mesh_generation.c from the c raylib examples and I got
"runtime error: cgo argument has Go pointer to Go pointer"
when calling UploadMesh.This is a simplified example that recreates the issue:
Produces:
The text was updated successfully, but these errors were encountered: