So I'm wondering: are clippers slow? or is it just my code that is?
DirectDraw Clippers
So I'm wondering: are clippers slow? or is it just my code that is?
Are DDraw clippers slow???
Do a comparison of: FPS with them and without them(If it doesn't crash
Perhaps your misusing them? How many do you have attached to the backbuffer?
My game uses clippers extensively, and there's a noticeable drop in performance when using certain drivers on my V550. I've found that the RIVA drivers tend to handle clippers fairly well, and that the default Viper drivers do not.
If anyone has any other information on this, I'd love to hear it.
Mason McCuskey
Spin Studios
www.spin-studios.com
RECT dest;
RECT src;
int i=1, ii=1;
int dx, dy;if (pos_x < 0) pos_x = 0;
if (pos_y < 0) pos_y = 0;pos_x+=2;
pos_y+=2;dx = pos_x - ((pos_x / TILE_WIDTH)*TILE_WIDTH);
dy = pos_y - ((pos_y / TILE_HEIGHT)*TILE_HEIGHT);src.top = 1;
src.left = 1;
src.bottom = TILE_HEIGHT;
src.right = TILE_WIDTH;for (i=0;i<=8;i++)
{
dest.top = i * TILE_HEIGHT - dy;
if (i==0) dest.top = 0;
dest.bottom = i * TILE_HEIGHT - dy + TILE_HEIGHT;
src.top = 0;
if (i==0) src.top = TILE_HEIGHT - dy;
src.bottom = TILE_HEIGHT;
for (ii=0;ii<=11;ii++)
{
dest.left = ii * TILE_WIDTH - dx;
if (ii==0) dest.left = 0;
dest.right = ii * TILE_WIDTH - dx + TILE_WIDTH;
src.left = 0;
if (ii==0) src.left = TILE_WIDTH - dx;
src.right = TILE_WIDTH;
primsurf->Blt(&dest, bitmap, &src, NULL, NULL);
}
}
while(primsurf->Flip(NULL, DDFLIP_WAIT)!=DD_OK);
------------------
They can clip against a *series* of rectangles, including ones that partially overlap each other. Because of this, they're a great tool in GUI design.
If all you need is simple "draw only inside this rectangle" clipping, writing your own is an option... but if you need more complex clipping, the speed hit may be worth the development time saved.
Mason McCuskey
Spin Studios
www.spin-studios.com
For what you are doing, create you're own clipper, the use bltfast vs blt.
You might also try to combine a run of tiles, into one single blt. That could get you a preformance increase.
primsurf->Blt(&dest_rect, bitmap, &src_rect, NULL, NULL);
Last time I wrote a tile based thing I used bltfast changed the rect to only display teh bits of tiles needed on the edge of the screen and it ran realy well.
Please!
zomeone@usa.net
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).]
So, hope it does the trick. Good luck.
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?
it should be
Blt(&dest, surface, &src, NULL, NULL)
or
BltFast(....)
Also rememeber to not attach a clipper to the backbuffer surface, if you plan on using BltFast
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!
+-------+
| | <- 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!
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.