System_Shutdown
Clean up HGE engine resources and close the window.
Synopsis
void HGE::System_Shutdown();
Description
System_Shutdown releases all engine resources and closes the application window. Call this when your game is exiting, after System_Start returns.
This function:
- Closes the graphics device
- Releases audio resources
- Destroys the window
- Frees internal engine memory
Important Notes
- Free your own resources (textures, sprites, sounds) before calling System_Shutdown
- Always call System_Shutdown even if System_Initiate failed (it handles that case)
- Call
Release()on the HGE object after System_Shutdown
Example
int main()
{
HGE *hge = hgeCreate(HGE_VERSION);
// Setup
hge->System_SetState(HGE_FRAMEFUNC, FrameFunc);
// ... other setup ...
if (hge->System_Initiate())
{
// Load resources
HTEXTURE tex = hge->Texture_Load("player.png");
hgeSprite *spr = new hgeSprite(tex, 0, 0, 64, 64);
// Run game
hge->System_Start();
// Free resources BEFORE shutdown
delete spr;
hge->Texture_Free(tex);
}
// Always call shutdown
hge->System_Shutdown();
// Release HGE object
hge->Release();
return 0;
}
Cleanup Pattern
void FreeResources()
{
// Free in reverse order of creation
delete sprPlayer;
delete sprEnemy;
hge->Texture_Free(texPlayer);
hge->Texture_Free(texEnemy);
hge->Effect_Free(sndShoot);
hge->Music_Free(musBackground);
}
// In main:
if (hge->System_Initiate())
{
LoadResources();
hge->System_Start();
FreeResources(); // Clean up our stuff
}
hge->System_Shutdown(); // Clean up engine
hge->Release();