void DDShutdown(void) { // release clipper if (lpDDClipper) { lpDDClipper->Release(); lpDDClipper = NULL; } // release the secondary surface if (lpDDSBack) { lpDDSBack->Release(); lpDDSBack = NULL; } // release the primary surface if (lpDDSPrimary) { lpDDSPrimary->Release(); lpDDSPrimary = NULL; } // finally, the main dd object if (lpDD) { lpDD->Release(); lpDD = NULL; } }
HRESULT CALLBACK WinProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_PAINT: if(flag) { RectClient = GetClientRect(hWnd, diff_x, diff_y); HRESULT ddrval = lpDDSPrimary->Blt (&RectClient, lpDDSTemp, &RectTemp, DDBLT_WAIT, NULL); if(ddrval == DDERR_SURFACELOST) { ddrval = lpDDSPrimary->Restore(); if (ddrval != DD_OK) break; } } return 0; //这里一定要是return,而不是break,否则不显示画面 case WM_DESTROY: FreeDDraw(); PostQuitMessage(0); return 0; } return DefWindowProc(hwnd, message, wParam, lParam); }
void AlliesWhiteboard::DrawTextInput(LPDIRECTDRAWSURFACE DestSurf) { Dialog *DialogPTR = (Dialog*)LocalShare->Dialog; int BFHalfX = (LocalShare->ScreenWidth-128)/2 + 128; int BFHalfY = (LocalShare->ScreenHeight-64)/2 + 32; if(CurrentElement) DialogPTR->DrawText(DestSurf, BFHalfX-InputBoxWidth/2+5, BFHalfY-InputBoxHeight/2-13, "Edit Textmarker"); else DialogPTR->DrawText(DestSurf, BFHalfX-InputBoxWidth/2+5, BFHalfY-InputBoxHeight/2-13, "Add Textmarker"); DDBLTFX ddbltfx; DDRAW_INIT_STRUCT(ddbltfx); ddbltfx.ddckSrcColorkey.dwColorSpaceLowValue = 102; ddbltfx.ddckSrcColorkey.dwColorSpaceHighValue = 102; RECT Dest; Dest.left = BFHalfX-InputBoxWidth/2; Dest.top = BFHalfY-InputBoxHeight/2; Dest.right = Dest.left+InputBoxWidth; Dest.bottom = Dest.top+InputBoxHeight; if(DestSurf->Blt(&Dest, lpInputBox, NULL, DDBLT_ASYNC | DDBLT_KEYSRCOVERRIDE, &ddbltfx)!=DD_OK) { DestSurf->Blt(&Dest, lpInputBox, NULL, DDBLT_WAIT | DDBLT_KEYSRCOVERRIDE, &ddbltfx); } DialogPTR->DrawSmallText(DestSurf, BFHalfX-(InputBoxWidth/2)+14, BFHalfY-5, Text); //draw cursor if textbox overlap if((MouseX-128)>Dest.left-10 && (MouseX-128)<Dest.right && (MouseY-32)>Dest.top-34 && (MouseY-32)<Dest.bottom) DialogPTR->BlitCursor(DestSurf, MouseX-128, MouseY-32); }
bool lock(LPDIRECTDRAWSURFACE dd,_TPixelsRef& out_pixelsRef){ DDSURFACEDESC ddsdDest; memset(&ddsdDest,0,sizeof(ddsdDest)); ddsdDest.dwSize=sizeof(ddsdDest); //ddsdDest.dwFlags=DDSD_LPSURFACE | DDSD_PITCH | DDSD_WIDTH | DDSD_HEIGHT; HRESULT ddrval=dd->Lock(NULL,&ddsdDest,DDLOCK_WAIT,NULL); if( ddrval == DDERR_SURFACELOST ) { ddrval = m_ddsprimary->Restore(); if( ddrval!= DD_OK ) return false; dd->Lock(NULL,&ddsdDest,DDLOCK_WAIT,NULL); } if (ddsdDest.lpSurface==0) return false; if (ddsdDest.lPitch<=4){ out_pixelsRef.pdata=ddsdDest.lpSurface;//获得页面首地址 out_pixelsRef.width=ddsdDest.dwHeight; out_pixelsRef.height=ddsdDest.dwWidth; out_pixelsRef.byte_width=-out_pixelsRef.width*ddsdDest.lPitch; ((Pixels32Ref&)out_pixelsRef).reversal(); }else{ out_pixelsRef.pdata=ddsdDest.lpSurface;//获得页面首地址 out_pixelsRef.width=ddsdDest.dwWidth; out_pixelsRef.height=ddsdDest.dwHeight; out_pixelsRef.byte_width=ddsdDest.lPitch; } return true; }
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); } }
void CALLBACK _GameProc(HWND hWnd, UINT message, UINT wParam, DWORD lParam) { static int Frame = 0, Count = 0; RECT BackRect = { 0, 0, 640, 480 }, SpriteRect; BackScreen -> BltFast( 0, 0, BackGround, &BackRect, DDBLTFAST_WAIT | DDBLTFAST_NOCOLORKEY ); SpriteRect.left = Frame * 100; SpriteRect.top = 0; SpriteRect.right = SpriteRect.left + 100; SpriteRect.bottom = 70; BackScreen -> BltFast( MouseX - 50, MouseY - 35, SpriteImage, &SpriteRect, DDBLTFAST_WAIT | DDBLTFAST_SRCCOLORKEY ); // enter animation code here! if(gFullScreen) RealScreen->Flip(NULL, DDFLIP_WAIT); else{ RECT WinRect, SrcRect={0, 0, gWidth, gHeight}; GetWindowRect(MainHwnd, &WinRect); RealScreen->Blt(&WinRect, BackScreen, &SrcRect, DDBLT_WAIT, NULL ); } }
static gxj_pixel_type* startDirectPaint(int &dstWidth, int &dstHeight, int &dstYPitch) { gxj_pixel_type *dst = NULL; #if JWC_WINCE_USE_DIRECT_DRAW if (isScreenRotated() || !isScreenFullyVisible() || editBoxShown) { /* DDraw is not very reliable on an rotated screen. Use GDI instead. */ return NULL; } if (g_pDD == NULL) { /* DirectDraw failed to initialize. Let's use GDI to Blit to the LCD. */ return NULL; } HRESULT hRet; DDSURFACEDESC surfaceDesc; DDSURFACEDESC ddsd; if (g_pDDSPrimary == NULL) { /* Create the primary surface with 0 back buffer */ memset(&ddsd, 0, sizeof(ddsd)); ddsd.dwSize = sizeof(ddsd); ddsd.dwFlags = DDSD_CAPS; ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE ; hRet = g_pDD->CreateSurface(&ddsd, &g_pDDSPrimary, NULL); if (hRet != DD_OK) { g_pDDSPrimary = NULL; return NULL; } } surfaceDesc.dwSize = sizeof(surfaceDesc); hRet = g_pDDSPrimary->Lock(NULL, &surfaceDesc, DDLOCK_DISCARD | DDLOCK_WRITEONLY, NULL); if (hRet == DD_OK) { dst = (gxj_pixel_type*)surfaceDesc.lpSurface; dstWidth = surfaceDesc.dwWidth; dstHeight = surfaceDesc.dwHeight; dstYPitch = surfaceDesc.lPitch; } else { /* Release the DD resources. Maybe we'd get lucky and can allocate * it next time. */ g_pDDSPrimary->Release(); g_pDDSPrimary = NULL; return NULL; } #else if (editBoxShown) { return NULL; } dstWidth = gxDispProps.cxWidth; dstHeight = gxDispProps.cyHeight; dstYPitch = gxDispProps.cbyPitch; dst = (gxj_pixel_type*)GXBeginDraw(); #endif return dst; }
void AlliesWhiteboard::DrawTextMarker(LPDIRECTDRAWSURFACE DestSurf, int X, int Y, char *cText, char C) { int x = X - *MapX + 128; int y = Y - *MapY + 32; DDBLTFX ddbltfx; DDRAW_INIT_STRUCT(ddbltfx); ddbltfx.ddckSrcColorkey.dwColorSpaceLowValue = 102; ddbltfx.ddckSrcColorkey.dwColorSpaceHighValue = 102; RECT Dest; Dest.left = x-TextMarkerWidth/2; Dest.top = y-TextMarkerHeight/2; Dest.right = Dest.left+TextMarkerWidth; Dest.bottom = Dest.top+TextMarkerHeight; RECT Source; Source.left = C*TextMarkerWidth; Source.top = 0; Source.right = Source.left+TextMarkerWidth; Source.bottom = TextMarkerHeight; if(DestSurf->Blt(&Dest, lpSmallCircle, &Source, DDBLT_ASYNC | DDBLT_KEYSRCOVERRIDE, &ddbltfx)!=DD_OK) { DestSurf->Blt(&Dest, lpSmallCircle, &Source, DDBLT_WAIT | DDBLT_KEYSRCOVERRIDE, &ddbltfx); } Dialog *pDialog = (Dialog*)LocalShare->Dialog; pDialog->DrawText(DestSurf, x+TextMarkerWidth , y-5, cText); }
void Welcome(LPDIRECTDRAWSURFACE lpdds) { const UINT MAXLEN = 85; const UINT NUMLINES = 17; char message[NUMLINES][MAXLEN] = { "Mandlebrot and Julia Set Viewer", "", "Controls:", "Z lets you define a new window to zoom into by clicking and dragging the mouse", "UP, DOWN, LEFT, RIGHT arrows scroll the current view", "SPACEBAR resets the view to the default window [(-2,-2i),(2,2i)]", "ENTER refreshes the current view (also wipes out any orbit diagrams)", "M switches to Mandlebrot Set", "J switches to Julia Set (after getting the c value for z^2 + c)", "C chooses a point in the complex plane to plot in the orbit diagram", "O (the letter O, not the number 0) plots the orbit diagram of the specified point ", " (warning... plotting the orbit in a zoomed view will cause unexpected results.", " In order to plot the orbit of a point you choose from a zoomed view, you must", " reset the view with SPACEBAR before pressing O to plot the orbit)", "ESCAPE exits the program", "", "Press SPACEBAR to start"}; HDC hdc; lpdds->GetDC(&hdc); for (UINT i = 0; i < NUMLINES; ++i) TextOut(hdc, 0, i * 16, message[i], strlen(message[i])); lpdds->ReleaseDC(hdc); }
// this restores memory when surface memory is lost static int dd_restore(void) { HRESULT ret; if (!lpDDSPrimary) return 1; ret = lpDDSPrimary->Restore(); if (ret == DD_OK) { if (lpDDSBitmap) { ret = lpDDSBitmap->Restore(); if (ret == DD_OK) return 1; else { module_logger(&win32DirectDrawVideo, _L|LOG_ERROR|L_0, _("video_restore: could not restore bitmap %8X\n"), ret); return 0; } } return 1; } else { module_logger(&win32DirectDrawVideo, _L|LOG_ERROR|L_0, _("video_restore: could not restore primary %8X\n"), ret); return 0; } }
void mfc_render_delete_overlay(void *mfc_render_handle) { _MFC_RENDER_OVERLAY *pMFC_RENDER_OVERLAY; LPDIRECTDRAWSURFACE pDDSOverlay; if (mfc_render_handle == NULL) { PRINT_ERRMSG(TEXT("\nmfc_render_handle is NULL.")); return; } pMFC_RENDER_OVERLAY = (_MFC_RENDER_OVERLAY *) mfc_render_handle; pDDSOverlay = pMFC_RENDER_OVERLAY->pDD; if (pDDSOverlay != NULL) { // Use UpdateOverlay() with the DDOVER_HIDE flag to remove an overlay // from the display. pDDSOverlay->UpdateOverlay(NULL, g_pDDSPrimary, NULL, DDOVER_HIDE, NULL); pDDSOverlay->Release(); pDDSOverlay = NULL; } pDDSOverlay = (LPDIRECTDRAWSURFACE) pMFC_RENDER_OVERLAY->pDD_back; if (pDDSOverlay != NULL) { // Use UpdateOverlay() with the DDOVER_HIDE flag to remove an overlay // from the display. pDDSOverlay->UpdateOverlay(NULL, g_pDDSPrimary, NULL, DDOVER_HIDE, NULL); pDDSOverlay->Release(); pDDSOverlay = NULL; } }
bool flip(long bltWidth,long bltHeight){ if (m_ddsback==0) return true; if (m_IS_USER_BACK_BUFFER){ if ((bltWidth>0)&&(bltHeight>0)){ RECT rt; rt.left=0; rt.top=0; rt.right=bltWidth; rt.bottom=bltHeight; #ifdef WINCE HRESULT ddrval=m_ddsprimary->Blt(&rt,m_ddsback, &rt,DDBLT_WAITNOTBUSY, NULL); #else HRESULT ddrval=m_ddsprimary->BltFast(0,0, m_ddsback, &rt, NULL); #endif return (ddrval == DD_OK); }else return true; }else{ //flip while( true ) { HRESULT ddrval= m_ddsprimary->Flip( NULL, DDFLIP_WAIT );// 交换表面 if( ddrval == DD_OK ) return true; if( ddrval == DDERR_SURFACELOST ) { ddrval = m_ddsprimary->Restore(); if( ddrval!= DD_OK ) return false; } if( ddrval != DDERR_WASSTILLDRAWING ){ return false; } ::Sleep(0); } } }
static void finiObjects(BOOL freeDD) { if (!bActive) { return; } if (lpDD != NULL) { if (PrimarySurface != NULL) { PrimarySurface->Release(); PrimarySurface = NULL; } if (BackSurface != NULL) { BackSurface->Release(); BackSurface = NULL; } if (freeDD) { lpDD->Release(); lpDD = NULL; } } }
static void ReleaseAllObjects(void) { if (g_pDDSBack != NULL) { g_pDDSBack->Release(); g_pDDSBack = NULL; } if (g_pDDSPrimary != NULL) { g_pDDSPrimary->Release(); g_pDDSPrimary = NULL; } if (g_pDDSOne != NULL) { g_pDDSOne->Release(); g_pDDSOne = NULL; } if (g_pDDSTwo != NULL) { g_pDDSTwo->Release(); g_pDDSTwo = NULL; } if (g_pDD != NULL) { g_pDD->Release(); g_pDD = NULL; } }
int CreditsProc(PASSPROCVARS Params){ int r=0; r+=ccbOK.ProcFunction(Params); if(r){ //we have to flip the screen Flip(Pass.DDFront); Blit(Pass.DDBack, ddsCredits, 0, 0, 640, 480, 0, 0); } //now handle some messages switch(Params.uMsg){ case WM_CLOSE: Pass.ProgramFlow=PF_EXIT; CreditsInfo=CREDITS_EXIT; break; case WM_PAINT: ddsCredits->Restore(); ddsCreditsh->Restore(); DDReLoadBitmap(ddsCredits,BMP_CREDITS); DDReLoadBitmap(ddsCreditsh,BMP_CREDITSH); Blit(Pass.DDFront, ddsCredits, 0, 0, 640, 480, 0, 0); Blit(Pass.DDBack, ddsCredits, 0, 0, 640, 480, 0, 0); break; case WM_KEYDOWN: switch(Params.wParam){ case VK_ESCAPE: CreditsInfo=CREDITS_EXIT; break; } break; } return 0; }
STDMETHODIMP CeE2DPage::BitBlt(ICeE2DPage *pdest, LONG destx, LONG desty, LONG width, LONG height, LONG srcx, LONG srcy, LONG rop) { HRESULT hr; LPDIRECTDRAWSURFACE lpddsDest = NULL; DWORD bltFlags = 0; DDBLTFX ddbltfx; RECT rectdest; RECT rectsrc; if (pdest == NULL) return E_FAIL; hr = ((CeE2DPage *)pdest)->get_lpdds(&lpddsDest); if (FAILED(hr)) return hr; bltFlags = DDBLT_ROP; ddbltfx.dwSize = sizeof(DDBLTFX); ddbltfx.dwROP = rop; rectdest.left = destx; rectdest.top = desty; rectdest.right = destx + width - 1; rectdest.bottom = desty + height - 1; rectsrc.left = srcx; rectsrc.top = srcy; rectsrc.right = rectdest.right; rectsrc.bottom = rectdest.bottom; hr = lpddsDest->Blt(&rectdest, this->m_lpDDS, &rectsrc, bltFlags, &ddbltfx); if (FAILED(hr)) { return hr; } return NOERROR; }
STDMETHODIMP CeE2DPage::NextPage(ICeE2DPage **ret) { HRESULT hr; LPDIRECTDRAWSURFACE lpdds = NULL; DDSCAPS ddscaps; ICeE2DPage *ppage; if (!this->m_bInited) return E_FAIL; ppage = new CCeE2DPage; ppage->AddRef(); ddscaps.dwCaps = DDSCAPS_BACKBUFFER; hr = this->m_lpDDS->GetAttachedSurface(&ddscaps, &lpdds); if (FAILED(hr)) return hr; hr = ((CeE2DPage *)ppage)->init(lpdds, this->m_nPages); if (FAILED(hr)) { lpdds->Release(); return hr; } *ret = ppage; return NOERROR; }
// initialization STDMETHODIMP CDirect2DRMDevice::InitFromSurface(LPDIRECTDRAWSURFACE pdds) { HRESULT hr; if (pdds == NULL) return E_NULLPOINTER; // if (m_pddsBackBuffer) // return E_ALREADYINITIALIZED; // release the old surface MMRELEASE(m_pddsBackBuffer); pdds->AddRef(); m_pddsBackBuffer = pdds; if (FAILED(hr = pdds->GetSurfaceDesc(&m_ddsd)) || FAILED(hr = m_pixi.Init(m_ddsd.ddpfPixelFormat))) return hr; // notify the viewports that the device has been resized for(DWORD i = 0, cLimit = m_dsViewports.Items(); i < cLimit; i++) { if (FAILED(hr = m_dsViewports[i]->DeviceResized())) return hr; } return S_OK; }
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; }
void settingsRedrawScreen(){ ScreenHighlighted->Restore(); ScreenUnhighlighted->Restore(); DDReLoadBitmap(ScreenHighlighted,BMP_SETTINGSH); DDReLoadBitmap(ScreenUnhighlighted,BMP_SETTINGS); DrawString("Setting up alpha table/@", 0, 0, 8); Blit(Pass.DDFront, ScreenUnhighlighted, 0, 0, 640, 480, 0, 0); Blit(Pass.DDBack, ScreenUnhighlighted, 0, 0, 640, 480, 0, 0); }
void mfc_render_flip(void *mfc_render_handle) { HRESULT hRet; _MFC_RENDER_OVERLAY *pMFC_RENDER_OVERLAY; LPDIRECTDRAWSURFACE pDDSOverlay; if (mfc_render_handle == NULL) { PRINT_ERRMSG(TEXT("\nmfc_render_handle is NULL.")); return; } pMFC_RENDER_OVERLAY = (_MFC_RENDER_OVERLAY *) mfc_render_handle; if (pMFC_RENDER_OVERLAY->show == 0) { RECT rs, rd; rs.left = 0; rs.top = 0; rs.right = pMFC_RENDER_OVERLAY->src_wd; rs.bottom = pMFC_RENDER_OVERLAY->src_hi; rd.left = pMFC_RENDER_OVERLAY->x; rd.top = pMFC_RENDER_OVERLAY->y; rd.right = pMFC_RENDER_OVERLAY->dst_wd; rd.bottom = pMFC_RENDER_OVERLAY->dst_hi; pDDSOverlay = pMFC_RENDER_OVERLAY->pDD; // Update the overlay parameters. hRet = pDDSOverlay->UpdateOverlay(&rs, g_pDDSPrimary, &rd, DDOVER_SHOW, NULL); if (hRet != DD_OK) { PRINT_ERRMSG(TEXT("Unable to show overlay surface!")); return; } hRet = pDDSOverlay->SetOverlayPosition(0, 0); if (hRet != DD_OK) { PRINT_ERRMSG(TEXT("Unable to SetOverlayPosition!")); return; } pMFC_RENDER_OVERLAY->show = 1; } if (pMFC_RENDER_OVERLAY->which == 0) { pMFC_RENDER_OVERLAY->pDD->Flip(NULL, 0); pMFC_RENDER_OVERLAY->which = 1; } else if (pMFC_RENDER_OVERLAY->which == 1) { pMFC_RENDER_OVERLAY->pDD_back->Flip(NULL, 0); pMFC_RENDER_OVERLAY->which = 0; } }
void PutText(const char* text,LPDIRECTDRAWSURFACE surface){ HDC hdc; if(SUCCEEDED(surface->GetDC(&hdc))){ RECT rect; rect.left=10; rect.right=g_nScreenWidth-10; rect.top= 10; rect.bottom=g_nScreenHeight; DrawText(hdc,text,-1,&rect,0); surface->ReleaseDC(hdc); } }
/* * KillIntroGFX: * Releases the surfaces for the intro graphics */ void KillIntroGFX(void) { lpDDSXG->Release(); lpDDSXG = NULL; lpDDSPP->Release(); lpDDSPP = NULL; lpDDSMR->Release(); lpDDSMR = NULL; lpDDSHW->Release(); lpDDSHW = NULL; }
HRESULT DDFlip(void) { #ifndef DOD_WINDOWED HRESULT ddrval; ddrval = lpDDSPrimary->Flip(NULL, DDFLIP_WAIT); // flip the surfaces return ddrval; #else RECT rect = { 0, 0, 640, 480 }; lpDDSPrimary->Blt(&rcWindow, lpDDSBack, &rect, DDBLT_WAIT, NULL); return 1; #endif }
void ReleaseSurfaces(){ if(lpSecondary!=NULL) //if secondary surface exists lpSecondary->Release(); //release secondary surface if(lpPrimary!=NULL) //if primary surface exists lpPrimary->Release(); //release primary surface if(lpBackground!=NULL) //if background exists lpBackground->Release(); //release background for(int i=0; i<NUM_SPRITES; i++){ //for each sprite if(g_pSprite[i]) //if sprite exists g_pSprite[i]->Release(); //release sprite delete g_pSprite[i]; //delete sprite } }
BOOL DrawBegin() { DDSURFACEDESC ddsd; HRESULT result; if (bSaveFramebuffer || !useDirectDraw) { scrpitch = scratch_pitch; scrbuf = scratch_buffer; return TRUE; } 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) { scrpitch = scratch_pitch; scrbuf = scratch_buffer; return TRUE; } scrpitch = ddsd.lPitch; scratch_pitch = scrpitch; scrbuf = (BYTE*)ddsd.lpSurface; return TRUE; }
//----------------------------------------------------------------------------- // Name: EraseScreen() // Desc: //----------------------------------------------------------------------------- VOID EraseScreen() { // Erase the background DDBLTFX ddbltfx; ZeroMemory( &ddbltfx, sizeof(ddbltfx) ); ddbltfx.dwSize = sizeof(ddbltfx); #ifdef NONAMELESSUNION ddbltfx.u5.dwFillColor = g_dwFillColor; #else ddbltfx.dwFillColor = g_dwFillColor; #endif while( 1 ) { HRESULT hr = g_pddsBackBuffer->Blt( NULL, NULL, NULL, DDBLT_COLORFILL, &ddbltfx ); if( SUCCEEDED(hr) ) return; if( hr == DDERR_SURFACELOST ) { if( FAILED( RestoreSurfaces() ) ) return; } if( hr != DDERR_WASSTILLDRAWING ) return; } }
HDC __getScreenDC() { HDC hdc; if (g_pDDSBack->GetDC(&hdc) == DD_OK) { return hdc; } return NULL; }
static void endDirectPaint() { #if JWC_WINCE_USE_DIRECT_DRAW g_pDDSPrimary->Unlock(NULL); #else GXEndDraw(); #endif }
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; }