Fix for UnloadMesh per issue #303

This commit is contained in:
Peter Johnson 2023-11-08 13:33:57 -08:00
parent 4c850b2472
commit f8a694c149

View file

@ -7,8 +7,10 @@ package rl
import "C" import "C"
import ( import (
"fmt"
"image/color" "image/color"
"runtime" "runtime"
"slices"
"unsafe" "unsafe"
) )
@ -335,15 +337,15 @@ func DrawBillboardPro(camera Camera, texture Texture2D, sourceRec Rectangle, pos
C.DrawBillboardPro(*ccamera, *ctexture, *csourceRec, *cposition, *cup, *csize, *corigin, crotation, *ctint) C.DrawBillboardPro(*ccamera, *ctexture, *csourceRec, *cposition, *cup, *csize, *corigin, crotation, *ctint)
} }
//List of VaoIDs of meshes created by calling UploadMesh() // List of VaoIDs of meshes created by calling UploadMesh()
//Used by UnloadMesh() to determine if mesh is go-managed or C-allocated // Used by UnloadMesh() to determine if mesh is go-managed or C-allocated
var goManagedMeshIDs []uint32 = make([]uint32, 0) var goManagedMeshIDs []uint32 = make([]uint32, 0)
// UploadMesh - Upload vertex data into a VAO (if supported) and VBO // UploadMesh - Upload vertex data into a VAO (if supported) and VBO
func UploadMesh(mesh *Mesh, dynamic bool) { func UploadMesh(mesh *Mesh, dynamic bool) {
//check if mesh has already been uploaded to prevent duplication //check if mesh has already been uploaded to prevent duplication
if mesh.VaoID != 0 { if mesh.VaoID != 0 {
fmt.printf("VAO: [ID %i] Trying to re-load an already loaded mesh", mesh->vaoId) fmt.printf("VAO: [ID %i] Trying to re-load an already loaded mesh", mesh.VaoId)
return return
} }