| View previous topic :: View next topic |
| Author |
Message |
Darkkermi
Joined: 23 Feb 2010 Posts: 14 Location: Melbourne, FL
|
Posted: Tue Feb 23, 2010 4:54 am Post subject: Help beginner programmer |
|
|
Unhandled exception at 0x00a77c00 in TEST.exe: 0xC0000005 Access violation reading location 0x0000009c.
Code:
| Code: | #include <windows>
#include <hge>
#include <hgeresource>
#include <hgesprite>
#include <hgeanim>
HGE *hge = 0;
hgeResourceManager* myRes;
hgeSprite* bgSprite;
hgeSprite* playerSprite;
hgeAnimation* star;
bool FrameFunc()
{
float dt=hge->Timer_GetDelta(); //get the time since the last call to FrameFunc
star->Update(dt); //update the animation
hge->Gfx_BeginScene();
hge->Gfx_Clear(0); //clear the screen, filling it with black
bgSprite->RenderStretch(0, 0, 800, 600); //render the background sprite stretched
playerSprite->Render(200, 200); //render the player sprite
star->Render(400, 300); //render the animation of a star
hge->Gfx_EndScene();
return false;
}
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");
if(hge->System_Initiate())
{
myRes = new hgeResourceManager("resource.res");
bgSprite = myRes->GetSprite("bgSprite");
playerSprite = myRes->GetSprite("playerSprite");
star = myRes->GetAnimation("star"); //start playback of animation
star->Play();
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;
}
|
I got this straight from the tutorial. It seems to be a dynamic error.
Last edited by Darkkermi on Tue Feb 23, 2010 9:37 pm; edited 1 time in total |
|
| Back to top |
|
 |
ProfEclipse Expert
Joined: 10 Mar 2005 Posts: 1516 Location: Orlando, FL USA
|
Posted: Tue Feb 23, 2010 6:58 am Post subject: |
|
|
Add:
| Code: |
hge->System_SetState(HGE_LOGFILE,"test.log");
|
Then run your program and check the log file. It looks like you've got a NULL pointer somewhere which, in your case, probably indicates an error loading a resource. |
|
| Back to top |
|
 |
Darkkermi
Joined: 23 Feb 2010 Posts: 14 Location: Melbourne, FL
|
Posted: Tue Feb 23, 2010 5:47 pm Post subject: |
|
|
I think i found it! it says:
| Code: | HGE Started..
HGE version: 1.80
Date: 23.02.2010, 16:38:32
Application: HGE Tutorial
OS: Windows 6.0.6002
Memory: 2097151K total, 1685724K free
D3D Driver: igdumd32.dll
Description: Mobile Intel(R) 965 Express Chipset Family
Version: 7.14.10.1409
Mode: 800 x 600 x X8R8G8B8
Sound Device: Speakers / Headphones (SigmaTel High Definition Audio CODEC)
Sample rate: 44100
Init done.
Can't load resource: resource
Script 'resource' not found. |
Last edited by Darkkermi on Tue Feb 23, 2010 9:46 pm; edited 1 time in total |
|
| Back to top |
|
 |
DaiShiva Expert
Joined: 03 Mar 2004 Posts: 702 Location: Tucson, AZ
|
Posted: Tue Feb 23, 2010 9:45 pm Post subject: |
|
|
Do the precompiled tutorials run?
Are you able to compile any of the tutorials? |
|
| Back to top |
|
 |
Darkkermi
Joined: 23 Feb 2010 Posts: 14 Location: Melbourne, FL
|
Posted: Tue Feb 23, 2010 9:47 pm Post subject: |
|
|
| yea the precompiled all run and i was able to run the first tutorial fine but i cant get the others to run |
|
| Back to top |
|
 |
ProfEclipse Expert
Joined: 10 Mar 2005 Posts: 1516 Location: Orlando, FL USA
|
Posted: Tue Feb 23, 2010 10:17 pm Post subject: |
|
|
| I'll bet when you saved your resource.res file, it actually saved as resource.res.txt. Bring up your Windows Explorer/Folder Options/View options and uncheck "Hide extensions for known file types". |
|
| Back to top |
|
 |
Darkkermi
Joined: 23 Feb 2010 Posts: 14 Location: Melbourne, FL
|
|
| Back to top |
|
 |
ProfEclipse Expert
Joined: 10 Mar 2005 Posts: 1516 Location: Orlando, FL USA
|
Posted: Wed Feb 24, 2010 12:46 am Post subject: |
|
|
| HGE searches for resources relative to the directory that contains the executable, not the project directory. You need to move your resources into the directory that contains TEST.exe. |
|
| Back to top |
|
 |
Darkkermi
Joined: 23 Feb 2010 Posts: 14 Location: Melbourne, FL
|
Posted: Wed Feb 24, 2010 1:25 am Post subject: |
|
|
that did the trick thanks alot!  |
|
| Back to top |
|
 |
ProfEclipse Expert
Joined: 10 Mar 2005 Posts: 1516 Location: Orlando, FL USA
|
Posted: Wed Feb 24, 2010 4:57 am Post subject: |
|
|
| You're welcome! |
|
| Back to top |
|
 |
|