Archived

This topic is now archived and is closed to further replies.

Phiro

Bitmap display

Recommended Posts

Pretty simple problem, maybe this one is easier to understand than the last one I posted All I am trying to do is display a 32x32 red bmp to my ddraw window. I have red.bmp in the project folder. I run my executable and kaboom, I get an access violation trying to read 0x00000000. Doing some debug stuff, it appears the first line pasted here is failing.... looking at code examples, I don''t see what I am doing wrong. Any ideas? g_pDisplay->CreateSurfaceFromBitmap(&g_pBitmap, "red.bmp", 32, 32) <--- this is failing? g_pDisplay->Clear(0); g_pDisplay->Blt(0,0,g_pBitmap,0); g_pDisplay->Present(); g_pBitmap->Destroy();

Share this post


Link to post
Share on other sites
First make sure that g_pDisplay has been created successfully and that it points to something. Also make sure that g_pBitmap is valid and points to something.

Alaa,

Share this post


Link to post
Share on other sites
Here are my three globals...

CDisplay *g_pDisplay = NULL;
CSurface *g_pBitmap = NULL;
CSurface *g_pText = NULL;

g_pText seems to work just fine, so I''m _assuming_ g_pBitmap is fine.

Share this post


Link to post
Share on other sites
Well, now I am *really confused.

If I run my exe manually, it bombs out trying to read 0x00000000. If I run it from mcvc++, (control-f5 or whatever, I just go to Build, Execute ), it works fine.

WTH?

Share this post


Link to post
Share on other sites
Did u create g_pDisplay "g_pDisplay = new CDisplay(...)" before using g_pDisplay->SomeMethod();

I only see that you declared g_pDisplay and initialized it to NULL.

Alaa,

Share this post


Link to post
Share on other sites
PHIRO said:"Well, now I am *really confused.

If I run my exe manually, it bombs out trying to read 0x00000000. If I run it from mcvc++, (control-f5 or whatever, I just go to Build, Execute ), it works fine.

WTH? "

Running ur program by using +F5 and running it directly has a difference because of the path. Ur *.exe file is in the ..\debug foder by default, so function such as LoadBitmap("BitmapFileName.bmp"); may failed because those files are not in the debug folder, right?

I think alaa_m is right, first of all make sure that ur g_pDisplay has been created succesfully and that it's a valid "Object".

[edited by - remi on October 2, 2002 9:12:17 PM]

Share this post


Link to post
Share on other sites
Yes, I created it with new before using it, sheesh

The whole problem was the patching, I am such a dolt. I have to have any bitmaps I''m using in the same folder as my proggie. Very obvious in hindsight.

Thanks for the help.

Share this post


Link to post
Share on other sites