Hello. I started using Haaf's game engine.
I'm trying to load a sprite using a resource file.
here's my code:
#pragma comment(lib, "hge.lib")
#pragma comment(lib, "hgehelp.lib")
#include <hge.h>
#include <hgesprite.h>
#include <hgeresource.h>
#include "constants.h"
// global variables
HGE *hge = 0;
hgeSprite *s = 0;
// function declarations
bool RenderFunc();
bool FrameFunc();
int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
hge = hgeCreate(HGE_VERSION);
hge->System_SetState(HGE_FRAMEFUNC, FrameFunc);
hge->System_SetState(HGE_RENDERFUNC, RenderFunc);
hge->System_SetState(HGE_WINDOWED, true);
hge->System_SetState(HGE_USESOUND, false);
hge->System_SetState(HGE_FPS, constants::FPS);
hge->System_SetState(HGE_WINDOWED, true);
hge->System_SetState(HGE_SCREENWIDTH, constants::SCREEN_WIDTH);
hge->System_SetState(HGE_SCREENHEIGHT, constants::SCREEN_HEIGHT);
hge->System_SetState(HGE_SCREENBPP, constants::SCREEN_BPP);
if( hge->System_Initiate() )
{
hgeResourceManager *manager = new hgeResourceManager("resources.res");
if( !manager ) exit(-1);
s = manager->GetSprite("spr");
if(!s) exit(-2);
}
else
{
MessageBox(NULL, hge->System_GetErrorMessage(), "Error",
MB_OK | MB_ICONERROR | MB_APPLMODAL);
}
delete s;
hge->System_Shutdown();
hge->Release();
return 0;
}
bool RenderFunc()
{
hge->Gfx_BeginScene();
hge->Gfx_Clear(0);
hge->Gfx_EndScene();
return false;
}
bool FrameFunc()
{
if( hge->Input_GetKeyState(HGEK_ESCAPE) ) return true;
return false;
}
The program exits with
-2.
resources.res
Texture background
{
filename = story_0.png
}
Sprite spr
{
texture = background
rect = 0, 0, 200, 200
}
The image is in the current working directory. Any help?