* move delete to earlier stage
* lines for better readability
* Added detach shader
* Addition forgotten glDeleteProgram
https://github.com/rwengine/openrw/search?utf8=%E2%9C%93&q=glDeleteProgram&type=
In project there's no necessary clearing call of glDeleteProgram.
* Removing/Closing shader programs
Each shader program should be taken care by glDeleteProgram.
To make it works/usefull, each shader's raw ptr will convertet to unique_ptr
in next commit.
* Converting ShaderProgram's ptr to unique
Actually deleting isn't handled,
so this commit removes memory leak.
Should fix this memory leak:
==16721== 8 bytes in 1 blocks are definitely lost in loss record 7 of 264
==16721== at 0x4C2F1CA: operator new(unsigned long) (vg_replace_malloc.c:334)
==16721== by 0x7E7B5D: GameWorld::GameWorld(Logger*, GameData*) (GameWorld.cpp:100)
==16721== by 0x76EC0B: std::_MakeUniq<GameWorld>::__single_object std::make_unique<GameWorld, Logger*,
GameData*>(Logger*&&, GameData*&&) (unique_ptr.h:825)
==16721== by 0x760F50: RWGame::newGame() (RWGame.cpp:107)
==16721== by 0x78E713: LoadingState::enter() (LoadingState.cpp:9)
==16721== by 0x76602B: void StateManager::enter<LoadingState, RWGame*, RWGame::RWGame(Logger&, int, ch
ar**)::{lambda()#1}>(RWGame*&&, RWGame::RWGame(Logger&, int, char**)::{lambda()#1}&&) (StateManager.hpp:4
0)
==16721== by 0x760842: RWGame::RWGame(Logger&, int, char**) (RWGame.cpp:81)
==16721== by 0x750385: main (main.cpp:13)
Should fix this memory leak:
==16721== 103 bytes in 1 blocks are definitely lost in loss record 181 of 264
==16721== at 0x4C2EB6B: malloc (vg_replace_malloc.c:299)
==16721== by 0x58F1AF3: ??? (in /usr/lib64/libLinearMath.so.2.83)
==16721== by 0x83E3C9: btBoxShape::operator new(unsigned long) (btBoxShape.h:34)
==16721== by 0x83CD75: VehicleObject::createObjectHinge(VehicleObject::Part*) (VehicleObject.cpp:722)
==16721== by 0x83C251: VehicleObject::setPartLocked(VehicleObject::Part*, bool) (VehicleObject.cpp:610)
==16721== by 0x83C2D0: VehicleObject::setPartTarget(VehicleObject::Part*, bool, float) (VehicleObject.cpp:623)
==16721== by 0x7B10CD: Activities::EnterVehicle::update(CharacterObject*, CharacterController*) (CharacterController.cpp:226)
==16721== by 0x7B062D: CharacterController::updateActivity() (CharacterController.cpp:26)
==16721== by 0x7B09FE: CharacterController::update(float) (CharacterController.cpp:98)
==16721== by 0x8EBBFA: DefaultAIController::update(float) (DefaultAIController.cpp:87)
==16721== by 0x82ED5A: CharacterObject::tick(float) (CharacterObject.cpp:240)
==16721== by 0x763630: RWGame::tick(float) (RWGame.cpp:506)
==16721==
==16721== 120 bytes in 5 blocks are definitely lost in loss record 187 of 264
==16721== at 0x4C2F1CA: operator new(unsigned long) (vg_replace_malloc.c:334)
==16721== by 0x8EBA26: DefaultAIController::update(float) (DefaultAIController.cpp:63)
==16721== by 0x82ED5A: CharacterObject::tick(float) (CharacterObject.cpp:240)
==16721== by 0x763630: RWGame::tick(float) (RWGame.cpp:506)
==16721== by 0x763128: RWGame::run() (RWGame.cpp:420)
==16721== by 0x750394: main (main.cpp:15)
Should fix this memory leak:
==16721== 120 bytes in 5 blocks are definitely lost in loss record 187 of 264
==16721== at 0x4C2F1CA: operator new(unsigned long) (vg_replace_malloc.c:334)
==16721== by 0x8EBA26: DefaultAIController::update(float) (DefaultAIController.cpp:63)
==16721== by 0x82ED5A: CharacterObject::tick(float) (CharacterObject.cpp:240)
==16721== by 0x763630: RWGame::tick(float) (RWGame.cpp:506)
==16721== by 0x763128: RWGame::run() (RWGame.cpp:420)
==16721== by 0x750394: main (main.cpp:15)
Should fix this memory leak:
==16721== 912 (600 direct, 312 indirect) bytes in 1 blocks are definitely lost in loss record 225 of 264
==16721== at 0x4C2F1CA: operator new(unsigned long) (vg_replace_malloc.c:334)
==16721== by 0x84A697: GameRenderer::GameRenderer(Logger*, GameData*) (GameRenderer.cpp:71)
==16721== by 0x75FC7D: RWGame::RWGame(Logger&, int, char**) (RWGame.cpp:35)
==16721== by 0x750385: main (main.cpp:13)