Sign in to follow this  

HGE Question [SOLVED]

This topic is 4097 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

Hi all, I've recently began fiddling with HGE and I've run into a stumbling block. I'm learning how to display sprites and such using the resource system provided in the engine and when I finally come down to rendering a sprite, all I see is a white block which is the right size but has nothing inside it. main.cpp
#include <windows.h>
#include <hge.h>
#include <hgeresource.h>
#include <hgesprite.h>

HGE *hge = 0;
hgeResourceManager *myRes;
hgeSprite *stingray;

void GameCycle()
{
    stingray->Render(0,0);
}

bool FrameFunc()
{
    hge->Gfx_BeginScene();
    hge->Gfx_Clear(0);  //clear the screen, filling it with black
    GameCycle();
    hge->Gfx_EndScene(); 
    return false;
}

void LoadResources()
{
    stingray = myRes->GetSprite("sStingray");
}

int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
    hge = hgeCreate(HGE_VERSION);
    hge->System_SetState(HGE_WINDOWED, true);
    hge->System_SetState(HGE_FRAMEFUNC, FrameFunc);
    hge->System_SetState(HGE_TITLE, "HGE Tutorial");

    myRes = new hgeResourceManager("resource.res");
    LoadResources();

    if(hge->System_Initiate())
    {
        hge->System_Start();
    }
    else
    {
        MessageBox(NULL, hge->System_GetErrorMessage(), "Error", MB_OK | MB_ICONERROR | MB_SYSTEMMODAL);
    }

    delete myRes;    

    hge->System_Shutdown();
    hge->Release();
    return 0;
}


resource.res
Texture tStingray
{
	filename=stingray.jpeg
}

Sprite sStingray
{
	texture=tStingray
	rect=0, 0, 64, 64
}


I hate to just post source, but I really can't find anything wrong with my code, and functionally it runs and compiles. I think it's just something I'm overlooking in rendering. Thanks for your time, toXic1337 [Edited by - toXic1337 on September 30, 2006 3:52:37 AM]

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I get white blocks when it can't find the resource. Maybe the file path is wrong, or it's not a supported filetype.

Share this post


Link to post
Share on other sites
Well, I thought that could have been it as well. But I have my stingray.jpeg image in the same directory as the resource file and executable. So I'm pretty sure that's not it, unless my syntax in the resource file is wrong.

toXic1337

Share this post


Link to post
Share on other sites
Figured it out,

Apparently if you're going to use resources you have to initialize the resource manager after you initialize hge itself... makes sense [duh]

Hope this helps someone a little smarter than me...

toXic1337 [lol]

Share this post


Link to post
Share on other sites

This topic is 4097 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this