Skip to main content
GameDev.net gamedev.net
🔒 Locked

I'M AT MY WITS END!!!

Started by Shazer Dec 31, 2000 at 8:47 PM 17 replies 500+ views
Original Post
Shazer
Shazer
I am having some SERIOUS debugging problems here! I am making a little arkanoid clone... AND IT DOESN''T WANT TO WORK! The calls to Blt (DirectDraw) are throwing the computer into fits, and I can''t figure out why. All the code looks sound to me... I have checked it through about 15 billion times, compared all the calls to the examples in the books, done debugging step-throughs; basicly, everything I can think of. I thought that if a fresh pair of eyes looked at my code for a few minutes, they might find an obvious error that I missed. If you are interested in helping me, I will e-mail you the source file (it''s really short). I would really appreciate some help here!! Mail me at novedkelley@yahoo.com. Sorry to beg so blatantly, but I have tried everything else! The Shaz "I don''t want to be a pie... I don''t like gravy." - Babbs, Chicken Run
Optimism is not a state of mind, but a form of life!SuperNova Games
GalaxyQuest
GalaxyQuest
Can you be a little more specific as to what is your problem!!! i mean i dont wanna do the debugging of code that isnt mine which may or may-not be properly commented in which case ill just WAIST my time trying to figure out what your doing. So, figure out what and where your problem is happening and state it here (*without posting your entire code, just a snippet if really, really needed*)

(you said your blt() is going crazy but thats about as general a remark as you can get...if that is your problem area at all!)

aka John M.
Never give up. Never surrender!


neonstar
neonstar
are you sure that you are Unlocking the surface if it is locked before the Blt call? i had this problem one time, and it gave me headaches for weeks. make sure you unlock a surface (if needed) before you blit to it.

just a suggestion



--
david@neonstar.net
neonstar entertainment
--david@neonstar.netneonstar enter
Shazer
Shazer
I can''t really explain whats going on. ANY call I make to Blt crashes the program. The code is in a general "Game Run" function that the message loop calls to do all the stuff. It calls an Erase Surface function and uses Blt to fill the buffer flipping surface with black. Then, I try to immediatly Blt a bitmap stored in an offscreen surface of the same size to the back buffer, and the program freezes with a white screen in Debug mode, and just crashes when I just run it. The colorfill blitting works fine... but when I try to blit from an offscreen surface, it crashes. Is there a trick here that I don''t know about?

The Shaz

"I don''t want to be a pie... I don''t like gravy." - Babbs, Chicken Run
Optimism is not a state of mind, but a form of life!SuperNova Games
neonstar
neonstar
i don''t know what to tell you man, it does sound kinda crazy. how bout e-mailing me your directdraw source and i''ll take a look at it. david@neonstar.net.

dave



--
david@neonstar.net
neonstar entertainment
--david@neonstar.netneonstar enter
Zipster
Zipster
Are you sure this offscreen surface exists? Was it created properly? Or did the surface creation call fail?
Shazer
Shazer
I do not get any error messages at all, until the program reaches the Blt call. Then it just crashes (run), or hangs (debug). I also found out that the calls to Flip do the same thing. I took out the bitmap Blitting and tried to just flip the surfaces, and it didn''t work. I think it has to be my code, because I can compile and run the sample programs. Does anyone else have some wisdom to impart upon me??

The Shaz



"I don''t want to be a pie... I don''t like gravy." - Babbs, Chicken Run

SuperNova Games
Optimism is not a state of mind, but a form of life!SuperNova Games
Gaiiden
Gaiiden
here''s some oft repeated wisdom - post some code so we can all look at it (gee, what an incentive ) there''s nothing proprietary about DirectDraw code that you should bother hiding from us (not that you are). I''m not spending the time doing your pondering for you, but I will glance over your code to see if you are doing anything wrong.

==============================
"Need more eeenput..."
- #5, "Short Circuit"
Blade Edge Software
==============================
Drew Sikora
Executive Producer
GameDev.net
Shazer
Shazer
Well, I thought of doing that in the beggining, but I couldn''t isolate the problem. I''ll put where the problem is, and you can tell me if the prob is there or somewhere else. That would help too.

  // Run the game

BOOL RunGame(HWND hwnd)
{
OutputDebugString("Running the game...\n");

// Erase the drawing surface

if (!EraseSurface(lpDDSBack))
{
MessageBox(hwnd, "Erase Back buffer", "ERROR", MB_OK);
return FALSE;
}

// Right now... I just want to draw the background and flip...

// Blt the background to the buffer

if (FAILED(lpDDSBack->Blt(NULL, lpDDSBackground, NULL, DDBLT_WAIT, NULL)))
{
MessageBox(hwnd, "Background Blt", "ERROR", MB_OK);
return FALSE;
}

RECT ball = {100, 100, 110, 110};

// Blt the ball onto the background

if (FAILED(lpDDSBack->Blt(&ball, lpDDSBall, NULL, DDBLT_WAIT | DDBLT_KEYSRC, NULL)))
{
MessageBox(hwnd, "Ball Blt", "ERROR", MB_OK);
return FALSE;
}

// Now, flip the surfaces

if (FAILED(lpDDSPrimary->Flip(NULL, DDFLIP_WAIT)))
{
MessageBox(hwnd, "Flip", "ERROR", MB_OK);
return FALSE;
}

// return successfull, i guess

return TRUE;
}


All of the Blts and Flips fail, except the Blt that colorfills int he EraseSurface function.

The Shaz




"I don''t want to be a pie... I don''t like gravy." - Babbs, Chicken Run

SuperNova Games
Optimism is not a state of mind, but a form of life!SuperNova Games
CHollman82
CHollman82
May I suggest that when you post a question you state at least the topic in the subject line. You''ll find you get more help that way.

BTW If you''re not at you wits end then your not a programmer
codeXtremeif(you->intelligence < radish->intelligence) you->STFU();
jumble
jumble
You have set the palette for the surface you are blitting right? If you havent a clue what im on about, look up the DDSetColorKey function in the DDUtils { ddutil.h & ddutil.cpp }. If you dont have the DDUtils: Get them!
jumble-----------
Shazer
Shazer
I am using 16bit, so I am not using a pallete. I am correct in that... right??

The Shaz



"I don''t want to be a pie... I don''t like gravy." - Babbs, Chicken Run

SuperNova Games
Optimism is not a state of mind, but a form of life!SuperNova Games
Haeberle
Haeberle
Hey,

may be this sound stupid, but have u checked your initializing code for

1) clearing the surface description with memset or ZeroMemory

2) setting the size filed with ddsd.dwSize=sizeof(...)

I forgot one of them one time and had a lot time to search for error cause its so trivial.

Hope its such an easy error

Keep on working !!!

Haeberle

haNg loOse ¿
furby100
furby100
I think you''ve got to specify a destination rectangle for surface (not colorfill) blits. Not sure about that though. Try specifying a destination rectangle for your background. Make sure that you have created all your surfaces correctly.



''Smile, things could get worse.''
So I smiled, and they did.


sharewaregames.20m.com

The_[PI]_ehT
The_[PI]_ehT
Well, I have another idea what it could be...

When you want to use Backbuffers, you have to create the Primary Surface complex. Therefore you need to modify the flags of the DDSurfaceDescription structure as well as the capability tab.
After creating the Primary Surface, you get a pointer to the Backbuffer Surface by calling the Primary Surface's GetAttachedSurface function.
Your whole Surface initialization code should look pretty much like this:

    
DDSURFACEDESC ddsd;
LPDIRECTDRAWSURFACE lpDDPrimary;
LPDIRECTDRAWSURFACE lpDDBackbuffer;
DDSCAPS ddscaps;

// set the whole thing to zero

ZeroMemory( &ddsd, sizeof( DDSURFACEDESC ) );

// obligatory: DD has to know the struct's size

ddsd.dwSize = sizeof( DDSURFACEDESC );

// set the flags: Caps and BackbufferCount contain info

ddsd.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT;

// now fill the caps

ddsd.ddsdCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | // primary surface

DDSCAPS_FLIP | // flippable

DDSCAPS_COMPLEX | // surface is complex

DDSCAPS_VIDEOMEMORY; // surface is in video memory


// set Backbuffer Count: double buffering, so one backbuffer

ddsd.dwBackBufferCount = 1;

// create primary buffer

HRESULT hr = lpDD->CreateSurface( &ddsd, &lpDSPrimary, NULL );
// error checking goes here


// zero the cute lil' thing

ZeroMemory( &ddscaps, sizeof( ddscaps ) );

// set the appropriate caps field

ddscaps.dwCaps = DDSCAPS_BACKBUFFER;

// now get the attached backbuffer

hr = lpDDPrimary->GetAttachedSurface( &ddscaps, &lpDDBackbuffer );
// error checking goes here



Now the thing should work. If the error remains or if your init code is right, please post again, with an excerpt of your init code too. Then we'll see whether there's a solution.

HTH
pi~

Edited by - thepi on January 7, 2001 12:06:17 PM
Jan PieczkowskiBrainwave Studios
ImmaGNUman
ImmaGNUman
You dont have to specify any rects for blitting, furby.

-----------------------------

A wise man once said "A person with half a clue is more dangerous than a person with or without one."

The Micro$haft BSOD T-Shirt
-----------------------------A wise man once said "A person with half a clue is more dangerous than a person with or without one."The Micro$haft BSOD T-Shirt
The_[PI]_ehT
The_[PI]_ehT
well he has to if he wants only to blit a certain area (i.e. a small object)

pi~
Jan PieczkowskiBrainwave Studios
Shazer
Shazer
Right off, I''d like to thank you all for your ongoing attempts to help me! I''m sure this will not be the last time I run into a wall. I figured out what was wrong. Neonstar was correct. The surfaces were locked, via a couple HDCs. I forgot to release them after I finished using them. Sorry to have wasted all your time with something so trivial, but the problem is solved, AND I WANT TO THANK YOU ALL FOR IT!!!

The Shaz



"I don''t want to be a pie... I don''t like gravy." - Babbs, Chicken Run

SuperNova Games
Optimism is not a state of mind, but a form of life!SuperNova Games

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.