Archived

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

Aaaargh This does not work!

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

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!

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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"<

Share this post


Link to post
Share on other sites
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:

  
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites