🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

DirectDraw Clippers

Started by
19 comments, last by ZomeonE 24 years, 6 months ago
I can't get it to work, do u have an example that you can send to me?
Please!

zomeone@usa.net

Advertisement
HRESULT rVal; // DirectDraw return value
RECT rcSource; // Tile size & position on surface

rcSource.left = xPos;
rcSource.top = yPos;
rcSource.right = xPos + TILEWIDTH;
rcSource.bottom = yPos + TILEHEIGHT;

// Clip right side
if (destX + TILEWIDTH > WINDOWWIDTH)
rcSource.right = rcSource.right - (destX + TILEWIDTH - WINDOWWIDTH);

// Clip bottom side
if (destY + TILEHEIGHT > WINDOWHEIGHT)
rcSource.bottom = rcSource.bottom - (destY + TILEHEIGHT - WINDOWHEIGHT);

// Clip left side
if (destX <= 0)
rcSource.left = rcSource.left + (-destX)

// Clip top side
if (destY <= 0)
rcSource.top = rcSource.top + (-destY)

if (FAILED(rVal = (lpDestSurface->BltFast(destX, destY, lpSourceSurface, &rcSource, NULL)))
return rVal;
.
.
.

[This message has been edited by Stark (edited December 14, 1999).]

I'm really not to sure how well that'll work, 'cause I'm at work and doing this all from memory and on a napkin beside me. hehehe

So, hope it does the trick. Good luck.

Thanks alot!

I havn't had any time to test it yet, but I will. I'm not sure why the BltFast function doesn't work. It doesn't blit anything...nothing. I'm using 640x480x16, loaded a 16 bit bitmap and try to blit it to the backbuffer. But it doesn't work with the source rect. The

Blt(&dest, surface, NULL, NULL, NULL)

works but not

Blt(&dest, surface, &src, NULL, NULL)
of
BltFast(....)

what's the problem?

oops

it should be

Blt(&dest, surface, &src, NULL, NULL)
or
BltFast(....)

Are you receiving an error message from the operation?
Also rememeber to not attach a clipper to the backbuffer surface, if you plan on using BltFast
Where should i put the clipper?

Anyway, I'm not using clippers and I've read that BltFast doesn't work with clippers. I think I read it in the Dx reference!

Alright, just wondering, but I'm under the impression that you think that using Blt, giving it a source rectangle will actually CLIP it to the destination rectangle, well, it dosn't. When you have a 20x20 destination rectangle, and a 40x40 source rectangle, DirectDraw SHRINKS it down to 20x20, it dosn't clip it. Also, if your source rectangle is much larger than your destination rectangle (Although your video card may vary, I think this applies to most), nothing ends up getting blitted. I think that this is what you were asking, but I may be wrong.

Vore

Ok, I mean like this:


+-------+
| | <- source surface
| +---+
| | | <- source rect
+---+---+

That won't resize the image when it is blitted right?
It will only blit the part of the source surface specified in the source rect to the destination surface. Tell me if I'm wrong!

I'm have a 2d scrolling function, which uses a clipper on the backbuffer and normal ->Blt(...) to draw the tiles on the screen. But it's SLOW, really SLOW.
So I'm wondering: are clippers slow? or is it just my code that is?

This topic is closed to new replies.

Advertisement