Archived

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

Guest Anonymous Poster

PR & Direct Draw Surfaces

Recommended Posts

I think you should write pixels to "Back surface".
If you write pixels to back surface then flip, there'll be no blinking.

an example from my old code:
DDSCAPS SurfaceCaps;
SurfaceCaps.dwCaps=DDSCAPS_BACKBUFFER | DDSCAPS_FLIP;
wgtpdds->GetAttachedSurface(&SurfaceCaps,&pBackSurface);

pBackSurface has pointer to back surface.

Then in the rendering loop, (placed after doing 3D renderings)
pBackSurface->GetDC(&DC);
TextOut(DC,....); -> write some text to back surface.
pBackSurface->ReleaseDC(DC);

then do PR_Flip(1);

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I try to mix PR and DirectDraw but I have some blinking problems. The rendering surface is displayed from time to time.

The surface creation code looks something like that:

#if USE_PR
mTextureDDraw = PRGFX_NewBlock (0, 0, mWidth-1, mHeight-1);
#else

// Create texture surface in video memory
DDSURFACEDESC ddsd2;
ddsd2.dwSize = sizeof (ddsd2);
ddsd2.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH;
ddsd2.ddsCaps.dwCaps = DDSCAPS_VIDEOMEMORY | DDSCAPS_3DDEVICE | DDSCAPS_OFFSCREENPLAIN;//| DDSCAPS_OFFSCREENPLAIN;
ddsd2.dwHeight = mHeight;
ddsd2.dwWidth = mWidth;

LPDIRECTDRAWSURFACE lpDDSTemp;
if (FAILED (wgtpdd->CreateSurface (&ddsd2, &lpDDSTemp, NULL)))
throw DrawException (std::string("Cannot create texture surface"));

if (FAILED (lpDDSTemp->QueryInterface(IID_IDirectDrawSurface2,
(LPVOID *)&mTextureDDraw)))
throw DrawException (std::string("Cannot convert surface to DD2"));
#endif


The surface rendering code:


#if USE_PR
PRGFX_PutBlock (left, top, mWidth, mHeight, mTextureDDraw);
#else

LPDIRECTDRAWSURFACE pPrimarySurface1 = NULL;
block pPrimarySurface2 = NULL;

if (wgtpdd->GetGDISurface(&pPrimarySurface1) == DD_OK)
if (pPrimarySurface1->QueryInterface
(IID_IDirectDrawSurface2, (LPVOID*) &pPrimarySurface2) == DD_OK)
{
RECT rect = {left, top, mWidth, mHeight};
// pPrimarySurface1->lpVtbl->Blt(pPrimarySurface2,&rect, mTextureDDraw, NULL, DDBLT_WAIT, NULL);
pPrimarySurface2->Blt(&rect, mTextureDDraw, NULL, DDBLT_WAIT, NULL);
}
#endif

Does anybody have an idea why it's blinking ?

Thanks.

Share this post


Link to post
Share on other sites