Jump to content
  • Advertisement
Sign in to follow this  
sheep19

[HGE] can't load resources!

This topic is 3260 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
Advertisement
Are you totally sure the files are in the working directory? Have you set up the debugger so it is so?

Share this post


Link to post
Share on other sites
Thanks for your help people. I asked the same question on relish games forum and I got a reply that said that the picture and the .res file have to be in executable's directory, not the main.cpp. It works great now!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!