More DX problems than I can cope with...

Started by
8 comments, last by Yanroy 23 years, 5 months ago
I have DirectDraw problems coming out my ears! I am trying to program an RTS game, but I have tons of problems (redundant enough yet?). Here is the list: I tried to make a clipper that would let me draw partial tiles at the edge of the screen (for smooth scrolling), but whenever I scroll, the app hangs. Take out the clipper and everything works like clockwork (except it doesn''t smooth scroll...) I wanted to add transparency (kinda important...). I set up the colorkey exactly as shown in Windows Game Programming For Dummies (don''t lecture about that plz, I know his coding style is worthless). It doesn''t work. There is no change with or without it. I tried setting the colorkey values with the RGB() macro and my own RGB16BIT() functions (the surface is 16bits). Because the clipper failed, I was trying to add clipping manually. It works on the top and left (smooth scrolling, that is), but the tiles along the bottom and right edges are either shown entirely or not at all (it jumps as I scroll) This is really killing me! Please help! Much thanks (grammar? ) ahead of time. --------------------

You are not a real programmer until you end all your sentences with semicolons; (c) 2000 ROAD Programming

You are unique. Just like everybody else.

Yanroy@usa.com

Visit the ROAD Programming Website for more programming help.

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

You are not a real programmer until you end all your sentences with semicolons; (c) 2000 ROAD Programming
You are unique. Just like everybody else.
"Mechanical engineers design weapons; civil engineers design targets."
"Sensitivity is adjustable, so you can set it to detect elephants and other small creatures." -- Product Description for a vibration sensor

Yanroy@usa.com

Advertisement
Make sure you are looking at return codes during the clipper construction.

*** Triality ***
*** Triality ***
I do. The program bails if any startup function doesn''t return DD_OK. I should note that I found a bug in my custom clipper code that makes that work now... but that is just the map. The units really need the clipper.

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


You are not a real programmer until you end all your sentences with semicolons; (c) 2000 ROAD Programming


You are unique. Just like everybody else.

Yanroy@usa.com

Visit the ROAD Programming Website for more programming help.

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

You are not a real programmer until you end all your sentences with semicolons; (c) 2000 ROAD Programming
You are unique. Just like everybody else.
"Mechanical engineers design weapons; civil engineers design targets."
"Sensitivity is adjustable, so you can set it to detect elephants and other small creatures." -- Product Description for a vibration sensor

Yanroy@usa.com

Can you post the code you''re using to create the clipper, and tell us which error code is being returned?

-Ironblayde
 Aeon Software

The following sentence is true.
The preceding sentence is false.
"Your superior intellect is no match for our puny weapons!"
this is what i use for the clipper. it will create a full screen clipper for the window:

DDResult = pDirectDraw->CreateClipper(NULL, &pDDClipper, NULL);if(FAILED(DDResult)){	return 0;}DDResult = pDDClipper->SetHWnd(NULL, hWnd);if(FAILED(DDResult)){	return 0;}DDResult = pDDSBack->SetClipper(pDDClipper);if(FAILED(DDResult))	return 0;} 

just remember, you have to use Blt and not BltFast when using clippers

for colour keys, this is what i use. i just use black for the colour because theres no chance that it wont be the right colour
DDCOLORKEY DDColorKey;DDColorKey.dwColorSpaceHighValue	= 0;DDColorKey.dwColorSpaceLowValue		= 0;DDResult = pSurface->SetColorKey(DDCKEY_SRCBLT, &DDColorKey);if(FAILED(DDResult)){	return 0;} 


hope this helps
Dude, that clipper setting code is for windowed mode only. To find out how to do clippers for fullscreen mode, go to page 236 of your book and start reading.

-Blackstream
-Blackstream Will you, won't you, will you, won't you, won't you take my virus?-The Mad HackerBlackstream's Webpage
Also, make sure that the color key is on the surface that is the source of your BLT, not the destination. And make sure you use the flag, DDBLT_KEYSRC, in your pSurface->Blt() function, or you won''t use the key.

-Blackstream
-Blackstream Will you, won't you, will you, won't you, won't you take my virus?-The Mad HackerBlackstream's Webpage
Blackstream, you solved my transparency problem. Thanks a lot. It''s really hard to make a good game without transparency . As for the read-the-book solution, that is where I got my clipper code to begin with (with some modification, of course). Here it is:

    // set up clipperif (lpdd->CreateClipper(0, &lpddclipper, NULL) != DD_OK)	return false;LPRGNDATA ClipperData;ClipperData = (LPRGNDATA)malloc(sizeof(RGNDATAHEADER) + sizeof(RECT));memcpy(ClipperData->Buffer, &ScreenArea, sizeof(RECT));ClipperData->rdh.dwSize = sizeof(RGNDATAHEADER);ClipperData->rdh.iType = RDH_RECTANGLES;ClipperData->rdh.nCount = 1;ClipperData->rdh.nRgnSize = sizeof(RECT);ClipperData->rdh.rcBound.left = 64000;ClipperData->rdh.rcBound.top = 64000;ClipperData->rdh.rcBound.right = -64000;ClipperData->rdh.rcBound.bottom = -64000;if (lpddclipper->SetClipList(ClipperData, 0) != DD_OK){	free(ClipperData);	return false;}if (lpddsback->SetClipper(lpddclipper) != DD_OK){	free(ClipperData);	return false;}free(ClipperData);    


I have the feeling that the answer to this problem is going to make me feel really stupid. FYI: The symptoms of this bug is nothing being blitted to the screen, and the entire comp hanging (needs hard reboot).

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


You are not a real programmer until you end all your sentences with semicolons; (c) 2000 ROAD Programming


You are unique. Just like everybody else.

Yanroy@usa.com

Visit the ROAD Programming Website for more programming help.

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

You are not a real programmer until you end all your sentences with semicolons; (c) 2000 ROAD Programming
You are unique. Just like everybody else.
"Mechanical engineers design weapons; civil engineers design targets."
"Sensitivity is adjustable, so you can set it to detect elephants and other small creatures." -- Product Description for a vibration sensor

Yanroy@usa.com

Two things. One, I assume ScreenArea contains a RECT or RECTs, am I right? Two, and this is the error.

ClipperData->rdh.rcBound.left = 64000;
ClipperData->rdh.rcBound.top = 64000;
ClipperData->rdh.rcBound.right = -64000;
ClipperData->rdh.rcBound.bottom = -64000;

Think about this code for a second. What bounds does this define? The upperleft is the lowerright of the bounds, and the lowerright is the upperleft. Why is this? Well, you forgot one thing. To change the bounds of CliiperData.rdh.rcBound to match your rects. If you have one RECT only, your bounds become your RECTS bounds. So...

ClipperData->rdh.rcBound.left = ScreenArea.left;
ClipperData->rdh.rcBound.top = ScreenArea.top;
ect.

If you have more than one RECT, you need to adjust your bounds to meet all of your rects. In other words, rdh.rcBound.left is equal to the left of the Rect furthest to the left. I don''t have access to a compiler or WGPFD, but this is what I think the (sorta pusedo)code is.


for(x = 0; x < num_rects; x++)
{
if(ScreenArea[x].left < ClipperData->rdh.rcBound.left)
ClipperData->rdh.rcBound.left = ScreenArea[x].left;
if(ScreenArea[x].top < ClipperData->rdh.rcBound.top)
ClipperData->rdh.rcBound.top = ScreenArea[x].top;
if(ScreenArea[x].right > ClipperData->rdh.rcBound.right)
ClipperData->rdh.rcBound.right = ScreenArea[x].right;
if(ScreenArea[x].bottom > ClipperData->rdh.rcBound.bottom)
ClipperData->rdh.rcBound.bottom = ScreenArea[x].bottom;
}

Insert this (you may need to modify it to match your variables and stuff) right after you declared ClipperData->rdh.rcBound.xxx=xxx;

Let me know if it works

-Blackstream

-Blackstream Will you, won't you, will you, won't you, won't you take my virus?-The Mad HackerBlackstream's Webpage
I won''t be able to test that until tonight (or, if I get swamped with homework, this weekend ), but that MUST be the problem! Thanks a whole lot. And I do feel really stupid :D. Thanks again (everybody).

Now, with the power of transparency and clipping, I commence with my takeover of the world. HAHAHAHA. (I can dream, can''t I?)

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


You are not a real programmer until you end all your sentences with semicolons; (c) 2000 ROAD Programming


You are unique. Just like everybody else.

Yanroy@usa.com

Visit the ROAD Programming Website for more programming help.

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

You are not a real programmer until you end all your sentences with semicolons; (c) 2000 ROAD Programming
You are unique. Just like everybody else.
"Mechanical engineers design weapons; civil engineers design targets."
"Sensitivity is adjustable, so you can set it to detect elephants and other small creatures." -- Product Description for a vibration sensor

Yanroy@usa.com

This topic is closed to new replies.

Advertisement