Ownership of Models + Double Frees
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 30/100
- Tipo di issue
- Bug
- Chiarezza
- Da chiarire
- Stato di attività
- Ferma
- Ambito
- computer-graphics
Direzione di ricerca
Start with the models example and the Model destructor, then trace UnloadModel and UnloadMesh in rmodel.c through the shown unload sequence. Reproduce the double free and determine how ownership is shared between the wrapper and raylib. Done means the model and mesh resources are released once without the corruption error or duplicate VAO unload.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
When loading the Models with Mesh the ownership is not clear and the mash(es)(?) got double freed.
Logs
INFO: TEXTURE: [ID 2] Texture loaded successfully (128x128 | GRAY_ALPHA | 1 mipmaps)
INFO: FONT: Default font loaded successfully (224 glyphs)
INFO: FILEIO: [resources/cubicmap.png] File loaded successfully
INFO: IMAGE: Data loaded successfully (32x16 | R8G8B8 | 1 mipmaps)
INFO: TEXTURE: [ID 3] Texture loaded successfully (32x16 | R8G8B8 | 1 mipmaps)
INFO: VAO: [ID 2] Mesh uploaded successfully to VRAM (GPU)
INFO: FILEIO: [resources/cubicmap_atlas.png] File loaded successfully
INFO: IMAGE: Data loaded successfully (256x256 | R8G8B8A8 | 1 mipmaps)
INFO: TEXTURE: [ID 4] Texture loaded successfully (256x256 | R8G8B8A8 | 1 mipmaps)
INFO: TIMER: Target time per frame: 16.667 milliseconds
INFO: TEXTURE: [ID 2] Unloaded texture data from VRAM (GPU)
INFO: SHADER: [ID 3] Default shader unloaded successfully
INFO: TEXTURE: [ID 1] Default texture unloaded successfully
double free or corruption (!prev)
INFO: Window closed successfully
INFO: TEXTURE: [ID 4] Unloaded texture data from VRAM (GPU)
INFO: VAO: [ID 2] Unloaded vertex array data from VRAM (GPU)
INFO: VAO: [ID 2] Unloaded vertex array data from VRAM (GPU)
models example
// Define the camera to look into our 3d world
raylib::Camera camera({ 0.2f, 0.4f, 0.2f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f);
raylib::Texture cubicmap;
raylib::Model model;
raylib::Texture texture;
// load from imMap
{
raylib::Image imMap;
imMap.Load("resources/cubicmap.png"); // Load cubicmap image (RAM)
cubicmap.Load(imMap); // Convert image to texture to display (VRAM)
raylib::Mesh mesh = raylib::Mesh::Cubicmap(imMap, Vector3{1.0f, 1.0f, 1.0f});
model.Load(mesh);
// NOTE: By default each cube is mapped to one part of texture atlas
texture.Load("resources/cubicmap_atlas.png"); // Load map texture
model.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = texture; // Set map diffuse texture
}
// Error happen at the end of the main
~Model() {
Unload(); ///< error here ::UnloadModel(*this);
}
rmodel.c
// Unload model (meshes/materials) from memory (RAM and/or VRAM)
// NOTE: This function takes care of all model elements, for a detailed control
// over them, use UnloadMesh() and UnloadMaterial()
void UnloadModel(Model model)
{
// Unload meshes
for (int i = 0; i < model.meshCount; i++) UnloadMesh(model.meshes[i]); ///< here
...
// Unload mesh from memory (RAM and VRAM)
void UnloadMesh(Mesh mesh)
{
// Unload rlgl mesh vboId data
rlUnloadVertexArray(mesh.vaoId);
if (mesh.vboId != NULL) for (int i = 0; i < MAX_MESH_VERTEX_BUFFERS; i++) rlUnloadVertexBuffer(mesh.vboId[i]);
RL_FREE(mesh.vboId);
RL_FREE(mesh.vertices); ///< error here
- Lingua principale
- C++
- Stelle
- 960
- Fork
- 120
- Merge medio
- 10m
- PR unite (30g)
- 1
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di RobLoach/raylib-cpp
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
RobLoach/raylib-cpp#425 ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
RobLoach/raylib-cpp#427 ·
-
Code gen Aperta
Difficoltà 5/5 Più di una settimana Idoneità per principianti 30/100
RobLoach/raylib-cpp#415 · 1 commento ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 45/100
RobLoach/raylib-cpp#370 · 1 commento ·
-
SDF Font Support Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 55/100
RobLoach/raylib-cpp#366 · 3 commenti ·
Tutte le issue di RobLoach/raylib-cpp
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
duckdb/duckdb-wasm#2258 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
objectionary/eo-graphs#75 ·
-
Coarray integration tests carry no LABELS, so run_tests.py silently skips them under every backend Apertacoarray
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
FISCO-BCOS/FISCO-BCOS#5642 ·