Archived

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

More DX problems than I can cope with...

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

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.

Share this post


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

Share this post


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

Share this post


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

Share this post


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

if (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.

Share this post


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

Share this post


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

Share this post


Link to post
Share on other sites