System_Initiate

Initialize the HGE engine and create the application window.

Synopsis

bool HGE::System_Initiate();

Returns

true if initialization succeeded, false if it failed.

Description

System_Initiate initializes the HGE engine based on the state values you've set with System_SetState. This includes:

  • Creating the application window
  • Initializing DirectX graphics
  • Setting up the audio system (if enabled)
  • Configuring input handling

You must call System_SetState for required settings before calling this function.

Required States

Before calling System_Initiate, you should set:

hge->System_SetState(HGE_FRAMEFUNC, FrameFunc);    // Required
hge->System_SetState(HGE_WINDOWED, true);          // Window mode
hge->System_SetState(HGE_SCREENWIDTH, 800);        // Dimensions
hge->System_SetState(HGE_SCREENHEIGHT, 600);

Error Handling

If initialization fails, you can check the log file for details:

if (!hge->System_Initiate())
{
    MessageBox(NULL, "Failed to initialize HGE", "Error", MB_OK);
    hge->System_Shutdown();
    hge->Release();
    return -1;
}

Example

int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
    HGE *hge = hgeCreate(HGE_VERSION);
    
    // Configure
    hge->System_SetState(HGE_FRAMEFUNC, FrameFunc);
    hge->System_SetState(HGE_RENDERFUNC, RenderFunc);
    hge->System_SetState(HGE_WINDOWED, true);
    hge->System_SetState(HGE_SCREENWIDTH, 800);
    hge->System_SetState(HGE_SCREENHEIGHT, 600);
    hge->System_SetState(HGE_TITLE, "My Game");
    hge->System_SetState(HGE_LOGFILE, "game.log");
    
    // Initialize
    if (hge->System_Initiate())
    {
        LoadResources();
        hge->System_Start();
        FreeResources();
    }
    
    hge->System_Shutdown();
    hge->Release();
    return 0;
}

See Also