本文整理汇总了C++中LPDIRECTDRAWSURFACE类的典型用法代码示例。如果您正苦于以下问题:C++ LPDIRECTDRAWSURFACE类的具体用法?C++ LPDIRECTDRAWSURFACE怎么用?C++ LPDIRECTDRAWSURFACE使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了LPDIRECTDRAWSURFACE类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DrawTextInput
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);
}
示例2: lock
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;
}
示例3: 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);
}
}
示例4: DrawTextMarker
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);
}
示例5: Welcome
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);
}
示例6: mfc_render_delete_overlay
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;
}
}
示例7: sizeof
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;
}
示例8:
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;
}
示例9:
// 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;
}
示例10: 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;
}
示例11: DDShutdown
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;
}
}
示例12: WinProc
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);
}
示例13: _GameProc
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 );
}
}
示例14: memset
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;
}
示例15:
// 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;
}
}