本文整理汇总了C++中LPDIRECTDRAWSURFACE::Unlock方法的典型用法代码示例。如果您正苦于以下问题:C++ LPDIRECTDRAWSURFACE::Unlock方法的具体用法?C++ LPDIRECTDRAWSURFACE::Unlock怎么用?C++ LPDIRECTDRAWSURFACE::Unlock使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LPDIRECTDRAWSURFACE
的用法示例。
在下文中一共展示了LPDIRECTDRAWSURFACE::Unlock方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: clear_buffers
static void clear_buffers(void)
{
LPDIRECTDRAWSURFACE surfs[] = {BackSurface, PrimarySurface};
LPDIRECTDRAWSURFACE surf;
DDSURFACEDESC ddsd;
BYTE* psurf;
int i, y;
for (i = 0; i < 2; i++)
{
ZeroMemory(&ddsd, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
surf = surfs[i];
if (surf->Lock(NULL, &ddsd, DDLOCK_WAIT, NULL) != DD_OK)
{
continue;
}
for (y = 0; y < SCRHEIGHT; y++)
{
psurf = (BYTE*)ddsd.lpSurface + y*ddsd.lPitch;
ZeroMemory(psurf, 2*SCRWIDTH);
}
surf->Unlock(NULL);
}
}
示例2: endDirectPaint
static void endDirectPaint() {
#if JWC_WINCE_USE_DIRECT_DRAW
g_pDDSPrimary->Unlock(NULL);
#else
GXEndDraw();
#endif
}
示例3: DDColorMatch
/*
* DDColorMatch:
* Matches a color (RGB) with a surface
*/
DWORD DDColorMatch(LPDIRECTDRAWSURFACE pdds, COLORREF rgb)
{
COLORREF rgbT;
HDC hdc;
DWORD dw = CLR_INVALID;
DDSURFACEDESC ddsd;
HRESULT hres;
// use GDI SetPixel to color match for us
if (rgb != CLR_INVALID && pdds->GetDC(&hdc) == DD_OK) {
rgbT = GetPixel(hdc, 0, 0); // save current pixel value
SetPixel(hdc, 0, 0, rgb); // set our value
pdds->ReleaseDC(hdc);
}
// now lock the surface so we can read back the converted color
ddsd.dwSize = sizeof(ddsd);
while ((hres = pdds->Lock(NULL, &ddsd, 0, NULL)) == DDERR_WASSTILLDRAWING);
if (hres == DD_OK) {
dw = *(DWORD *)ddsd.lpSurface; // get DWORD
if (ddsd.ddpfPixelFormat.dwRGBBitCount < 32) {
dw &= (1 << ddsd.ddpfPixelFormat.dwRGBBitCount) - 1; // mask it to bpp
}
pdds->Unlock(NULL);
}
// now put the color that was there back.
if (rgb != CLR_INVALID && pdds->GetDC(&hdc) == DD_OK) {
SetPixel(hdc, 0, 0, rgbT);
pdds->ReleaseDC(hdc);
}
return dw;
}
示例4: DrawEnd
BOOL DrawEnd()
{
if (bSaveFramebuffer || !useDirectDraw)
{
scrbuf = scratch_buffer;
scrpitch = 0;
return TRUE;
}
if (BackSurface == NULL)
{
return FALSE;
}
if (scrbuf == scratch_buffer)
{
scrpitch = 0;
return TRUE;
}
if (bActive)
{
BackSurface->Unlock(NULL);
}
scrpitch = 0;
scrbuf = NULL;
return TRUE;
}
示例5: q_unlock
void q_unlock()
{
if( !locked) {
qWarning("Direct Painter not locked (QDirectPainter::unlock()");
return;
}
g_pDDSSurface->Unlock(0);
locked = false;
}
示例6: CreateSurfPCXResource
LPDIRECTDRAWSURFACE CreateSurfPCXResource(WORD PCXNum, bool VidMem)
{
HRSRC FResource = FindResource(HInstance, MAKEINTRESOURCE(PCXNum), RT_RCDATA);
if(FResource == NULL)
IDDrawSurface::OutptTxt("FResource NULL");
HGLOBAL LResource = LoadResource(HInstance, FResource);
if(LResource == NULL)
IDDrawSurface::OutptTxt("LResource NULL");
LPVOID PCXBuf = LockResource(LResource);
if(PCXBuf == NULL)
IDDrawSurface::OutptTxt("PCXBuf NULL");
pcx_picture_typ PCXPic;
//PCXPic.buffer= (unsigned char *)malloc ( SizeofResource ( HInstance, FResource));
PCX2BitMap((unsigned char*)PCXBuf, &PCXPic, 0);
int Height = PCXPic.header.height-PCXPic.header.y+1;
int Width = PCXPic.header.width-PCXPic.header.x+1;
LPDIRECTDRAWSURFACE RetSurf;
DDSURFACEDESC ddsd;
DDRAW_INIT_STRUCT(ddsd);
ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
if(VidMem)
ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY;
else
ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
ddsd.dwWidth = Width;
ddsd.dwHeight = Height;
if( DD_OK!=((LPDIRECTDRAW)LocalShare->TADirectDraw)->CreateSurface(&ddsd, &RetSurf, NULL))
{
return NULL;
}
DDRAW_INIT_STRUCT(ddsd);
RetSurf->Lock(NULL, &ddsd, DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT, NULL);
unsigned char *SurfPTR = (unsigned char*)ddsd.lpSurface;
if (NULL!=PCXPic.buffer)
{
if (NULL!=SurfPTR)
{
for(int i=0; i<Height; i++)
{
memcpy(&SurfPTR[i*ddsd.lPitch], &PCXPic.buffer[i*Width], Width);
}
}
delete [] PCXPic.buffer;
}
RetSurf->Unlock(NULL);
return RetSurf;
}
示例7: flip_fullscreen
void dd_Window::flip_fullscreen()
{
int i=0;
HRESULT hr;
//hack for 320x200 letterboxing
if(xres == 320 && yres == 200)
{
hr = dx_bs->BltFast(0,20,dx_os,NULL,DDBLTFAST_WAIT | DDBLTFAST_NOCOLORKEY);
DDBLTFX ddbltfx;
memset(&ddbltfx, 0, sizeof(DDBLTFX));
ddbltfx.dwSize = sizeof(DDBLTFX);
ddbltfx.dwFillColor = 0;
RECT rBlit;
rBlit.left = 0; rBlit.top = 0; rBlit.right = 320; rBlit.bottom = 20;
dx_bs->Blt(&rBlit, 0, 0, DDBLT_COLORFILL | DDBLT_WAIT, &ddbltfx);
rBlit.left = 0; rBlit.top = 220; rBlit.right = 320; rBlit.bottom = 240;
dx_bs->Blt(&rBlit, 0, 0, DDBLT_COLORFILL | DDBLT_WAIT, &ddbltfx);
}
//regular case
else
hr = dx_bs->BltFast(0,0,dx_os,NULL,DDBLTFAST_WAIT | DDBLTFAST_NOCOLORKEY);
if(hr==DDERR_SURFACELOST)
{
dx_bs->Restore();
dx_os->Restore();
dx_bs->BltFast(0,0,dx_os,NULL,DDBLTFAST_WAIT | DDBLTFAST_NOCOLORKEY);
}
hr=dx_ps->Flip(0,DDFLIP_WAIT | DDFLIP_NOVSYNC);
//dx_ps->Flip(0,0);
if(hr==DDERR_SURFACELOST)
{
dx_ps->Restore();
hr=dx_ps->Flip(0,DDFLIP_WAIT | DDFLIP_NOVSYNC);
}
hr=dx_os->Lock(0,&dx_osd,DDLOCK_SURFACEMEMORYPTR | DDLOCK_WRITEONLY | DDLOCK_WAIT,0);
if(hr==DDERR_SURFACELOST)
{
dx_os->Restore();
hr=dx_os->Lock(0,&dx_osd,DDLOCK_SURFACEMEMORYPTR | DDLOCK_WRITEONLY | DDLOCK_WAIT,0);
}
dx_os->Unlock(0);
img->data=(quad*)dx_osd.lpSurface;
img->pitch=dx_osd.lPitch/vid_bytesperpixel;
}
示例8: RestoreFromPCX
//loads the PCX picture onto an existing surface
void RestoreFromPCX(WORD PCXNum, LPDIRECTDRAWSURFACE lpSurf)
{
HRSRC FResource = FindResource(HInstance, MAKEINTRESOURCE(PCXNum), RT_RCDATA);
if(FResource == NULL)
IDDrawSurface::OutptTxt("FResource NULL");
HGLOBAL LResource = LoadResource(HInstance, FResource);
if(LResource == NULL)
IDDrawSurface::OutptTxt("LResource NULL");
LPVOID PCXBuf = LockResource(LResource);
if(PCXBuf == NULL)
IDDrawSurface::OutptTxt("PCXBuf NULL");
pcx_picture_typ PCXPic;
PCX2BitMap((unsigned char*)PCXBuf, &PCXPic, 0);
int Height = PCXPic.header.height-PCXPic.header.y+1;
int Width = PCXPic.header.width-PCXPic.header.x+1;
DDSURFACEDESC ddsd;
DDRAW_INIT_STRUCT(ddsd);
lpSurf->Lock(NULL, &ddsd, DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT, NULL);
unsigned char *SurfPTR = (unsigned char*)ddsd.lpSurface;
if ((NULL!=PCXPic.buffer))
{
if ((NULL!=SurfPTR)&&(NULL!=PCXPic.buffer))
{
for(int i=0; i<Height; i++)
{
memcpy(&SurfPTR[i*ddsd.lPitch], &PCXPic.buffer[i*Width], Width);
}
}
delete [] PCXPic.buffer;
}
lpSurf->Unlock(NULL);
}
示例9: Update
bool WinDrawDDS::Update(LPDIRECTDRAWSURFACE dds, const RECT& rect)
{
if (rect.left >= rect.right || rect.top >= rect.bottom)
return false;
HRESULT r;
DDSURFACEDESC ddsd;
memset(&ddsd, 0, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
RECT rectdest;
rectdest.left = ltc.x + rect.left;
rectdest.right = ltc.x + rect.right;
rectdest.top = ltc.y + rect.top;
rectdest.bottom = ltc.y + rect.bottom;
r = dds->Lock(&rectdest, &ddsd, DDLOCK_WAIT | DDLOCK_WRITEONLY, 0);
LOGDDERR("ddsk->Lock", r);
if (r != DD_OK)
return false;
const uint8* src = image + rect.left + (rect.top * width);
uint8* dest = (uint8*) ddsd.lpSurface;
for (int y = rect.top; y < rect.bottom; y++)
{
uint8 *d = dest;
for (int x =0; x < (rect.right - rect.left); x++) {
*d++ = palentry[src[x]].peBlue;
*d++ = palentry[src[x]].peGreen;
*d++ = palentry[src[x]].peRed;
if (m_bpp == 4) {
*d++ = 00;
}
}
dest += ddsd.lPitch;
src += width;
}
dds->Unlock(ddsd.lpSurface);
return true;
}
示例10: GetPitch
DWORD GetPitch()
{
DDSURFACEDESC ddsd;
HRESULT result;
if (BackSurface == NULL)
{
return FALSE;
}
ZeroMemory(&ddsd, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
result = BackSurface->Lock(NULL, &ddsd, DDLOCK_WAIT, NULL);
if (result != DD_OK)
{
return 0;
}
DWORD pitch = ddsd.lPitch;
BackSurface->Unlock(NULL);
return pitch;
}
示例11: mfc_render_do
void mfc_render_do(void *mfc_render_handle, unsigned char *pImg, int width, int height, int img_type)
{
_MFC_RENDER_OVERLAY *pMFC_RENDER_OVERLAY;
DDSURFACEDESC ddsd;
HRESULT hRet;
LPDIRECTDRAWSURFACE pDDSOverlay; // Overlay Surface.
unsigned char *pSurf;
int y_size, u_size;
switch (img_type) {
case MFC_RENDER_IMAGE_TYPE_YUV420:
case MFC_RENDER_IMAGE_TYPE_RGB565:
case MFC_RENDER_IMAGE_TYPE_YV12:
break;
default:
PRINT_ERRMSG(TEXT("img_type is not supported."));
return;
}
if (mfc_render_handle == NULL) {
PRINT_ERRMSG(TEXT("\nmfc_render_handle is NULL."));
return;
}
if (pImg == NULL) {
PRINT_ERRMSG(TEXT("Input image is NULL."));
return;
}
pMFC_RENDER_OVERLAY = (_MFC_RENDER_OVERLAY *) mfc_render_handle;
if (pMFC_RENDER_OVERLAY->which == 1) {
pDDSOverlay = pMFC_RENDER_OVERLAY->pDD;
}
else if (pMFC_RENDER_OVERLAY->which == 0) {
pDDSOverlay = pMFC_RENDER_OVERLAY->pDD_back;
}
memset(&ddsd, 0, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
// Lock down the surface so we can modify it's contents.
hRet = pDDSOverlay->Lock( NULL, &ddsd, DDLOCK_WAITNOTBUSY, NULL);
if (hRet != DD_OK) {
PRINT_ERRMSG(TEXT("Unable to show overlay surface!"));
return;
}
pSurf = (LPBYTE)ddsd.lpSurface;
y_size = width * height;
u_size = y_size >> 2;
switch (pMFC_RENDER_OVERLAY->surface_type) {
case MFC_RENDER_SURFACE_TYPE_YV12: // YV12의 경우는 그대로 복사한다.
if (img_type == MFC_RENDER_IMAGE_TYPE_YUV420) {
memcpy(pSurf, pImg, y_size);
memcpy(pSurf + y_size, pImg + y_size + u_size, u_size);
memcpy(pSurf + y_size + u_size, pImg + y_size, u_size);
}
else if (img_type == MFC_RENDER_IMAGE_TYPE_YV12) {
memcpy(pSurf, pImg, y_size + (u_size << 1));
}
else if (img_type == MFC_RENDER_IMAGE_TYPE_RGB565) {
PRINT_ERRMSG(TEXT("This case is not supported. : (Surface type is YV12 and Image type is RGB565)"));
}
break;
case MFC_RENDER_SURFACE_TYPE_RGB565: // RGB565의 경우는 SW YUV->RGB 변환 수행
if (img_type == MFC_RENDER_IMAGE_TYPE_YUV420) {
_yuv420ToRgb565(pImg, pImg + y_size, pImg + y_size + u_size, width, height,
pSurf, width, height,
0);
}
else if (img_type == MFC_RENDER_IMAGE_TYPE_YV12) {
_yuv420ToRgb565(pImg, pImg + y_size + u_size, pImg + y_size, width, height,
pSurf, width, height,
0);
}
else if (img_type == MFC_RENDER_IMAGE_TYPE_RGB565) {
memcpy(pSurf, pImg, y_size << 1);
}
break;
default:
break;
}
pDDSOverlay->Unlock(NULL);
}
示例12: SimLoop
/********************************************************************
* Function : SimLoop()
* Purpose : Performs a single Simulation Loop iteration. Includes
* drawing.
********************************************************************/
int SimLoop(void)
{
static int nFramesPerSecond = 0;
static int nFramesSinceLastTick;
static DWORD LastTicks = 0;
DWORD Ticks;
HDC hDC;
HFONT hOldFont;
char s[80];
int slen;
DDSURFACEDESC ddsd;
DDBLTFX BltFx;
HRESULT ddreturn;
/* Perform a single step in our world. */
if (StepWorld(bForwardKey, bBackKey, bLeftKey, bRightKey, nState, nGauge))
{
if (lpPrimary->IsLost() == DDERR_SURFACELOST)
lpPrimary->Restore();
/* Clear the backbuffer. */
#if CLEARBCKGRND
BltFx.dwSize = sizeof(BltFx);
BltFx.dwFillColor = 255;
ddreturn = lpBackbuffer->Blt(NULL,
NULL,
NULL,
DDBLT_COLORFILL | DDBLT_WAIT,
&BltFx);
#else
ddreturn = DD_OK;
#endif
if (ddreturn == DD_OK)
{ /* While this is running, prepare
* the drawing. */
if (PrepDrawWorld())
{
/* Lock the surface. */
memset(&ddsd, 0, sizeof(DDSURFACEDESC));
ddsd.dwSize = sizeof(ddsd);
ddreturn = lpBackbuffer->Lock(NULL, &ddsd, DDLOCK_WAIT | DDLOCK_SURFACEMEMORYPTR, NULL);
if (ddreturn == DD_OK)
{
DrawWorld((unsigned char *)ddsd.lpSurface, (int)ddsd.lPitch);
int nX, nY;
static unsigned char dummy;
unsigned char ni;
ni = 0;
for (nY = 0; nY < 16; nY++)
for (nX = 0; nX < 16; nX++)
{
/* Draw a small block at (nX * 3, nY * 3) */
((unsigned char *)ddsd.lpSurface)[(nY * 3 * ddsd.lPitch) + (nX * 3)] = ni;
((unsigned char *)ddsd.lpSurface)[(nY * 3 * ddsd.lPitch) + (nX * 3 + 1)] = ni;
((unsigned char *)ddsd.lpSurface)[((nY * 3 + 1) * ddsd.lPitch) + (nX * 3)] = ni;
((unsigned char *)ddsd.lpSurface)[((nY * 3 + 1) * ddsd.lPitch) + (nX * 3 + 1)] = ni;
ni++;
}
lpBackbuffer->Unlock(NULL);
/* And now write Frames per second. */
/* Increment Frame counter. */
nFramesSinceLastTick++;
/* Get system tick count. */
Ticks = GetTickCount();
/* Update fps value every second. */
if (Ticks > (LastTicks + 1000))
{ nFramesPerSecond = nFramesSinceLastTick;
nFramesSinceLastTick = 0;
LastTicks = Ticks;
}
/* Get a DC to the buffer & write count. */
if (DD_OK == lpBackbuffer->GetDC(&hDC))
{
SetBkMode(hDC, TRANSPARENT);
hOldFont = SelectObject(hDC, AppFont);
/* Build a string for display. */
slen = wsprintf(s, "FPS : %d", nFramesPerSecond);
/* And draw the text. */
SetTextColor(hDC, RGB(0,0,0));
SIZE sz;
GetTextExtentPoint32(hDC, s, slen, &sz);
RECT rc;
rc.top = 0;
rc.left = 16 * 3;
rc.right = 16 * 3 + sz.cx + 10;
rc.bottom = sz.cy + 10;
DrawFrameControl(hDC, &rc, DFC_BUTTON, DFCS_BUTTONPUSH);
TextOut(hDC, 16*3 + 5, 5, s, slen);
SelectObject(hDC, hOldFont);
lpBackbuffer->ReleaseDC(hDC);
}
//.........这里部分代码省略.........
示例13: unLock
void unLock(LPDIRECTDRAWSURFACE dd){
dd->Unlock(NULL);//解锁页面
}
示例14: pProjCh
//.........这里部分代码省略.........
// okay, now we have the surfaces, we can copy from one to the other,
// darkening pixels as we go
{
long fontimagePitchInShorts = (ddsdimage.lPitch/2);
long backbufferPitchInShorts = (BackBufferPitch/2);
unsigned short* fontimageRowStartPtr =
(
((unsigned short *)ddsdimage.lpSurface)
+
(GetHeight()*theOffset*fontimagePitchInShorts)
);
unsigned short* backbufferRowStartPtr =
(
((unsigned short *)ScreenBuffer)
+
(R2Pos_Cursor.y*backbufferPitchInShorts)
+
(R2Pos_Cursor.x)
);
int screenY = R2Pos_Cursor.y;
for (int yCount=GetHeight(); yCount>0; yCount--)
{
unsigned short* fontimagePtr = fontimageRowStartPtr;
unsigned short* backbufferPtr = backbufferRowStartPtr;
int xIndex = R2Pos_Cursor.x+CloakingPhase/64;
int yIndex = (screenY+CloakingPhase/128)&127;
// if (screenY >= R2Rect_Clip.y0 && screenY <= R2Rect_Clip.y1)
for (int xCount=width; xCount>0;xCount--)
{
int r = CloudTable[(xCount+xIndex)&127][yIndex];
// b += CloudTable[((xCount+R2Pos_Cursor.x)/2-CloakingPhase/96)&127][((yCount+R2Pos_Cursor.y)/4+CloakingPhase/64)&127]/4;
// b += CloudTable[((xCount+R2Pos_Cursor.x+10)/4-CloakingPhase/64)&127][((yCount+R2Pos_Cursor.y-50)/8+CloakingPhase/32)&127]/8;
// if (b>ONE_FIXED) b = ONE_FIXED;
r = MUL_FIXED(FixP_Alpha,r);
//int r = FixP_Alpha;
if (*fontimagePtr)
{
unsigned int backR = (int)(*backbufferPtr) & DisplayPixelFormat.dwRBitMask;
unsigned int backG = (int)(*backbufferPtr) & DisplayPixelFormat.dwGBitMask;
unsigned int backB = (int)(*backbufferPtr) & DisplayPixelFormat.dwBBitMask;
unsigned int fontR = (int)(*fontimagePtr) & DisplayPixelFormat.dwRBitMask;
unsigned int fontG = (int)(*fontimagePtr) & DisplayPixelFormat.dwGBitMask;
unsigned int fontB = (int)(*fontimagePtr) & DisplayPixelFormat.dwBBitMask;
backR += MUL_FIXED(r,fontR);
if (backR>DisplayPixelFormat.dwRBitMask) backR = DisplayPixelFormat.dwRBitMask;
else backR &= DisplayPixelFormat.dwRBitMask;
backG += MUL_FIXED(r,fontG);
if (backG>DisplayPixelFormat.dwGBitMask) backG = DisplayPixelFormat.dwGBitMask;
else backG &= DisplayPixelFormat.dwGBitMask;
backB += MUL_FIXED(r,fontB);
if (backB>DisplayPixelFormat.dwBBitMask) backB = DisplayPixelFormat.dwBBitMask;
else backB &= DisplayPixelFormat.dwBBitMask;
*backbufferPtr = (short)(backR|backG|backB);
}
fontimagePtr++;
backbufferPtr++;
}
screenY++;
fontimageRowStartPtr += fontimagePitchInShorts;
backbufferRowStartPtr += backbufferPitchInShorts;
}
}
}
}
}
}
#endif
}
else
{
#if 0
textprint("unprintable \'%c\'\n",ProjCh);
#endif
}
R2Pos_Cursor . x += 1+GetXInc
(
ProjCh,
*(pProjChar_I+1)
);
// this takes responsibility for updating cursor pos,
// rather than the RenderChar function
pProjChar_I++;
}
image_ptr->Unlock((LPVOID)ddsdimage.lpSurface);
}
示例15:
static void screen_unlock(u8 *screen)
{
lpDDSPrimary->Unlock(screen);
}