directdraw clipper help

Started by
12 comments, last by kingpinzs 19 years, 4 months ago
Is this how you make a fullscreen cliper. because all I get is a black screen now g_pdd->CreateClipper(0,&g_pddclipper,NULL); g_pddclipper->SetHWnd(0,hwnd); lpBackBuffer->SetClipper(g_pddclipper);
Advertisement
Which blt-method do you use? If you're using BltFast it will fail because it doesn't support clippers hence the black screen.

BltFast returns DDERR_UNSUPPORTED if it fails because of the clipper.

I would suggest you try using the Blt method instead.

\Jimmy H

edit: Yes, your clipper creating is correct, if you intend to use it with for example the IDIRECTDRAWSURFACE7::Blt method.
how do I change from bltfast to blt?
If you do something like this with BltFast now:

RECT srcRect;srcRect.left = 0;srcRect.top = 0;srcRect.right = 20;srcRect.bottom = 20;lpDirectDrawSurface7->BltFast(x, y, lpDirectDrawSurface7Sprite, &srcRect, 0);


You could do this with Blt instead:

RECT srcRect;srcRect.left = 0;srcRect.top = 0;srcRect.right = 20;srcRect.bottom = 20;RECT dstRect;dstRect.left = x;dstRect.top = y;dstRect.right = x + srcRect.right;dstRect.bottom = y + srcRect.bottom;lpDirectDrawSurface7->Blt(&dstRect, lpDirectDrawSurface7Sprite, &srcRect, 0, NULL);


Remember if you want to avoid hardware scaling + antialias keep the same source RECT dimensions in the destination RECT.

\Jimmy H

edit: Blt & BltFast takes the addresses to the RECTs

[Edited by - Jimmy H on November 28, 2004 2:00:34 PM]
thanks that help me alot. I was looking through other forums and could not find the answer.

thanks again
363 H:\My projects\directx\main.cpp no matching function for call to `IDirectDrawSurface7::Blt (RECT&, IDirectDrawSurface7*&, RECT&, int, NULL)'

error C:\Dev-Cpp\include\ddraw.h:1993 candidates are: virtual long int IDirectDrawSurface7::Blt(tagRECT*, IDirectDrawSurface7*, tagRECT*, long
what does this mean?
I forgot Blt and BltFast wants the adresses to the RECTs so it should look like this (sorry for the confusion):

lpDirectDrawSurface7->Blt(&dstRect, lpDirectDrawSurface7Sprite, &srcRect, 0, NULL);
How do I use transparency using blt?

[Edited by - kingpinzs on November 28, 2004 3:21:41 PM]
What kind of transparency are you after? Try searching the docs for 'colorkey' as I think that's all you can really do with DirectDraw.
Did you get the Blt to work?

You could make a surface use for example a source-colorkey (the color specified by the surface's colorkey will not be drawn when the surface is drawn onto another surface).

The colorkey could either be set using the IDIRECTDRAWSURFACE7::SetColorKey function or maybe easier when the surface is created:

//create DirectDraw surfaceDDSURFACEDESC ddsd; //surface descriptionLPDIRECTDRAWSURFACE lpDDFace = NULL;ZeroMemory(&ddsd, sizeof(ddsd)); //set all data in ddsd to 0ddsd.dwSize = sizeof(ddsd);ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_CKSRCBLT; //DDSD_CKSRCBLT - ColorKeySourceBlt enabledddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;ddsd.dwWidth = width;ddsd.dwHeight = height;//set the source-colorkey rangeddsd.ddckCKSrcBlt.dwColorSpaceLowValue = 0;ddsd.ddckCKSrcBlt.dwColorSpaceHighValue = 10;//(all the colors between 0 and 10 will not be drawn from this surface)g_lpDirectDraw->CreateSurface(&ddsd, &lpDDFace, NULL)


Then when the surface is to be drawn specify that the source colorkey should be used with the DDBLT_KEYSRC flag:
g_lpDDFaceBack->Blt(&rDst, g_lpDDFace, &rSrc, DDBLT_KEYSRC, NULL);


\Jimmy H

This topic is closed to new replies.

Advertisement