Aaaargh This does not work!
For the last couple of evenings I have been trying to get a simple direct X windowed program running. It''s based on a ''pixel plotting demo'' in LaMothe''s TOTWGPG book.
All I am trying to do at the moment is blit a bitmap onto the primary surface, and I have completely exhausted any way I can think of to get it working.
After a few crashes and a few posts to gamedev I have it running without causing an error, but it just does not work!
I didn''t want to post a huge amount of code (I''d have to submit the whole .cpp since I have no idea what is wrong) so if any of you good people have got a few minutes to spare, perhaps you could download the VS project at:
www.todayguide.com/manicminer.zip
I know it''s a bit much asking people to download a zip file and try to dissect it, but I do not know where to turn.
The code is a little untidy, what with endless alterations, so you''ll have to excuse that!
CHALLENGE ACCEPTED!
#EDIT# Wow (no offence, but,) that's hard code to follow!
I'll keep working at it though! #/EDIT#
Edited by - SpazBoy the Mitey on February 21, 2002 5:36:50 AM
#EDIT# Wow (no offence, but,) that's hard code to follow!
I'll keep working at it though! #/EDIT#
Edited by - SpazBoy the Mitey on February 21, 2002 5:36:50 AM
hmm i have spent about 15 minutes looking at your program and
unfortunately, I still can''t make heads nor tails of it. I
suggest perhaps that you use LaMothe''s book to prop up your
wonky coffee table, and have a look at the tutorial series,
"Game Programming Genesis" right here at GameDev.net
http://www.gamedev.net/reference/articles/article1229.asp
In the meantime, I''ll have another dig through your code and
I might just rewrite it myself
unfortunately, I still can''t make heads nor tails of it. I
suggest perhaps that you use LaMothe''s book to prop up your
wonky coffee table, and have a look at the tutorial series,
"Game Programming Genesis" right here at GameDev.net
http://www.gamedev.net/reference/articles/article1229.asp
In the meantime, I''ll have another dig through your code and
I might just rewrite it myself
you are a star!
good luck!
if it ever ends up working i will dedicate it to you. By the way, it ought to end up looking like the flash game in the main frame at www.todayguide.com , so if you want to program this functionality into that would be good too
aha, i had a look at the resource you mentioned. i could definitely do this simple blitting program in GDI, it's the introduction of DX that has thrown the spanner into the works...
Edited by - graeme on February 21, 2002 6:42:02 AM
good luck!
if it ever ends up working i will dedicate it to you. By the way, it ought to end up looking like the flash game in the main frame at www.todayguide.com , so if you want to program this functionality into that would be good too
aha, i had a look at the resource you mentioned. i could definitely do this simple blitting program in GDI, it's the introduction of DX that has thrown the spanner into the works...
Edited by - graeme on February 21, 2002 6:42:02 AM
I looked through it you just have to do the following
in your drawBackground() you don''t have to lock the surface before blting, blt locks the surface for you. just comment out your lock and unlock.
// if (FAILED(lpddsprimary->Lock(NULL,&ddsd,DDLOCK_WAIT|DDLOCK_SURFACEMEMORYPTR,NULL)))
// LOG<<"LOCK PRIMARY FAILED"< if (!lpddsprimary->Blt(&dR,wall,&sR,DDBLT_WAIT,NULL))
LOG<<"blit fail"<
// if (FAILED(lpddsprimary->Unlock(NULL)))
// LOG<<"UNLOCK PRIMARY FAILED"<
in your drawBackground() you don''t have to lock the surface before blting, blt locks the surface for you. just comment out your lock and unlock.
// if (FAILED(lpddsprimary->Lock(NULL,&ddsd,DDLOCK_WAIT|DDLOCK_SURFACEMEMORYPTR,NULL)))
// LOG<<"LOCK PRIMARY FAILED"< if (!lpddsprimary->Blt(&dR,wall,&sR,DDBLT_WAIT,NULL))
LOG<<"blit fail"<
// if (FAILED(lpddsprimary->Unlock(NULL)))
// LOG<<"UNLOCK PRIMARY FAILED"<
oh my, I am so grateful.
I have spent the last three nights trying to work this out.
Thankyou very, very much.
I have spent the last three nights trying to work this out.
Thankyou very, very much.
There''s a small bug in the message loop too (in main). The one from TOTWGPG only removes one message from the queue on each run of Game_Main. It should really check for messages, if there are any, process them all then call Game-Main. I use something along the lines of this:
Glad you''ve got the DDraw problem sorted now tho
bool done = false;while(not done){ // Check if there are any messages in the queue if(GetQueueStatus(QS_ALLINPUT) != 0) { // Process all the messages in the queue while(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { if(msg.message == WM_QUIT) done=true; DispatchMessage(&msg); } } // main game processing goes here if(!done) Game_Main(); }
Glad you''ve got the DDraw problem sorted now tho
Thanks Krunk.
So many helpful people here on GameDev!
Now I have got over my elation at wh0mk's fix to my problem, and I no longer have to wait for the compiler to build my program, only to see another black, empty window, I'm wondering, why does locking the surface stop the blit from altering the locked surface? Is it because this lock prevents the lock that blt calls from being effective? I can vaguely see what's going on, but exactly what is going on??
Oh yea, I meant to ask about Release(). In the many tutorials and code examples that I've trawled through in the last couple of days I have seen a surface being Released() after manipulation in some cases, and other programmers seem to have not bothered and only done this in a routine called to exit the program. When is it wise to use Release and when is it necessary??
Edited by - graeme on February 21, 2002 5:07:26 PM
So many helpful people here on GameDev!
Now I have got over my elation at wh0mk's fix to my problem, and I no longer have to wait for the compiler to build my program, only to see another black, empty window, I'm wondering, why does locking the surface stop the blit from altering the locked surface? Is it because this lock prevents the lock that blt calls from being effective? I can vaguely see what's going on, but exactly what is going on??
Oh yea, I meant to ask about Release(). In the many tutorials and code examples that I've trawled through in the last couple of days I have seen a surface being Released() after manipulation in some cases, and other programmers seem to have not bothered and only done this in a routine called to exit the program. When is it wise to use Release and when is it necessary??
Edited by - graeme on February 21, 2002 5:07:26 PM
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement