本文整理汇总了C++中LPDIRECTDRAWSURFACE::GetPixelFormat方法的典型用法代码示例。如果您正苦于以下问题:C++ LPDIRECTDRAWSURFACE::GetPixelFormat方法的具体用法?C++ LPDIRECTDRAWSURFACE::GetPixelFormat怎么用?C++ LPDIRECTDRAWSURFACE::GetPixelFormat使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LPDIRECTDRAWSURFACE
的用法示例。
在下文中一共展示了LPDIRECTDRAWSURFACE::GetPixelFormat方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetDisplayMode
//.........这里部分代码省略.........
(void **)&lpDDSOffScreen2)))
{
lpDDSOffScreen->Release();
BLOCK = false;
return (false);
}
lpDDSOffScreen2->PageLock(0);
lpDDSOffScreen->Release();
ZeroMemory (&ddsd, sizeof (ddsd));
if (pDoubleBuffered)
{
ddsd.dwSize = sizeof( ddsd);
ddsd.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT;
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP;
GUI.NumFlipFrames = 3;
ddsd.dwBackBufferCount = 2;
}
else
{
GUI.NumFlipFrames = 1;
ddsd.dwSize = sizeof (ddsd);
ddsd.dwFlags = DDSD_CAPS;
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
}
LPDIRECTDRAWSURFACE lpDDSPrimary;
dErr = lpDD->CreateSurface (&ddsd, &lpDDSPrimary, NULL);
if( FAILED(dErr) )
{
if (pDoubleBuffered)
{
ddsd.dwBackBufferCount = 1;
GUI.NumFlipFrames = 2;
if (FAILED(dErr = lpDD->CreateSurface (&ddsd, &lpDDSPrimary, NULL)))
{
ddsd.dwFlags = DDSD_CAPS;
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
pDoubleBuffered = false;
GUI.NumFlipFrames = 1;
dErr = lpDD->CreateSurface (&ddsd, &lpDDSPrimary, NULL);
}
}
if (FAILED(dErr))
{
BLOCK = false;
lpDDSOffScreen2->PageUnlock(0);
lpDDSOffScreen2->Release();
lpDDSOffScreen2 = NULL;
return (false);
}
}
ZeroMemory (&DDPixelFormat, sizeof (DDPixelFormat));
DDPixelFormat.dwSize = sizeof (DDPixelFormat);
lpDDSPrimary->GetPixelFormat (&DDPixelFormat);
clipped = true;
if((!pWindowed && pDoubleBuffered) || FAILED(lpDDSPrimary->SetClipper( lpDDClipper)))
clipped = false;
if (FAILED (lpDDSPrimary->QueryInterface (IID_IDirectDrawSurface2, (void **)&lpDDSPrimary2)))
{
BLOCK = false;
lpDDSPrimary->Release();
lpDDSPrimary = NULL;
return (FALSE);
}
lpDDSPrimary->Release();
lpDDSPrimary = NULL;
if((!pWindowed && pDoubleBuffered) || FAILED(lpDDSPrimary2->SetClipper( lpDDClipper)))
clipped = false;
if (pDepth == 8)
{
dErr = lpDD->CreatePalette (DDPCAPS_8BIT | DDPCAPS_ALLOW256,
PaletteEntries, &lpDDPalette, NULL);
if( FAILED(dErr))
{
lpDDPalette = NULL;
BLOCK = false;
return false;
}
}
depth = pDepth;
height = pHeight;
width = pWidth;
doubleBuffered = pDoubleBuffered;
BLOCK = false;
return (true);
}
示例2: SetDisplayMode
//.........这里部分代码省略.........
(void **)&lpDDSOffScreen2)))
{
lpDDSOffScreen->Release();
BLOCK = false;
return (false);
}
lpDDSOffScreen2->PageLock(0);
lpDDSOffScreen->Release();
ZeroMemory (&ddsd, sizeof (ddsd));
if (pDoubleBuffered)
{
ddsd.dwSize = sizeof( ddsd);
ddsd.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT;
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP;
GUI.NumFlipFrames = 3;
ddsd.dwBackBufferCount = 2;
}
else
{
GUI.NumFlipFrames = 1;
ddsd.dwSize = sizeof (ddsd);
ddsd.dwFlags = DDSD_CAPS;
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
}
LPDIRECTDRAWSURFACE lpDDSPrimary;
dErr = lpDD->CreateSurface (&ddsd, &lpDDSPrimary, NULL);
if( FAILED(dErr) )
{
if (pDoubleBuffered)
{
ddsd.dwBackBufferCount = 1;
GUI.NumFlipFrames = 2;
if (FAILED(dErr = lpDD->CreateSurface (&ddsd, &lpDDSPrimary, NULL)))
{
ddsd.dwFlags = DDSD_CAPS;
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
pDoubleBuffered = false;
GUI.NumFlipFrames = 1;
dErr = lpDD->CreateSurface (&ddsd, &lpDDSPrimary, NULL);
}
}
if (FAILED(dErr))
{
BLOCK = false;
lpDDSOffScreen2->PageUnlock(0);
lpDDSOffScreen2->Release();
lpDDSOffScreen2 = NULL;
return (false);
}
}
ZeroMemory (&DDPixelFormat, sizeof (DDPixelFormat));
DDPixelFormat.dwSize = sizeof (DDPixelFormat);
lpDDSPrimary->GetPixelFormat (&DDPixelFormat);
Clipped = true;
if((!pWindowed && pDoubleBuffered) || FAILED(lpDDSPrimary->SetClipper( lpDDClipper)))
Clipped = false;
if (FAILED (lpDDSPrimary->QueryInterface (IID_IDirectDrawSurface2, (void **)&lpDDSPrimary2)))
{
BLOCK = false;
lpDDSPrimary->Release();
lpDDSPrimary = NULL;
return (FALSE);
}
lpDDSPrimary->Release();
lpDDSPrimary = NULL;
if((!pWindowed && pDoubleBuffered) || FAILED(lpDDSPrimary2->SetClipper( lpDDClipper)))
Clipped = false;
if (pDepth == 8)
{
dErr = lpDD->CreatePalette (DDPCAPS_8BIT | DDPCAPS_ALLOW256,
PaletteEntries, &lpDDPalette, NULL);
if( FAILED(dErr))
{
lpDDPalette = NULL;
BLOCK = false;
return false;
}
}
Depth = pDepth;
Height = pHeight;
Width = pWidth;
DoubleBuffered = pDoubleBuffered;
BLOCK = false;
return (true);
}
示例3: rglswCreateWindow
//.........这里部分代码省略.........
{
return FALSE;
}
ZeroMemory(&ddcaps, sizeof(ddcaps));
ddcaps.dwSize = sizeof(ddcaps);
lpDD->GetCaps(&ddcaps, NULL);
if (WINDOWED)
{
ddrval = lpDD->SetCooperativeLevel(hwnd, DDSCL_NORMAL);
if (ddrval != DD_OK)
{
return FALSE;
}
}
else
{
ddrval = lpDD->SetCooperativeLevel(hwnd, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
if (ddrval != DD_OK)
{
return FALSE;
}
ddrval = lpDD->SetDisplayMode(SCRWIDTH, SCRHEIGHT, 16);
if (ddrval != DD_OK)
{
return FALSE;
}
}
ZeroMemory(&ddsd, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
if (WINDOWED)
{
ddsd.dwFlags = DDSD_CAPS;
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
ddrval = lpDD->CreateSurface(&ddsd, &PrimarySurface, NULL);
}
else
{
ddsd.dwFlags = DDSD_CAPS;
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
ddrval = lpDD->CreateSurface(&ddsd, &PrimarySurface, NULL);
}
if (ddrval != DD_OK)
{
return FALSE;
}
ZeroMemory(&ddsd, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH;
ddsd.ddsCaps.dwCaps = DDSCAPS_VIDEOMEMORY;
ddsd.dwWidth = SCRWIDTH;
ddsd.dwHeight = SCRHEIGHT;
ddrval = lpDD->CreateSurface(&ddsd, &BackSurface, NULL);
if (ddrval != DD_OK)
{
ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
ddrval = lpDD->CreateSurface(&ddsd, &BackSurface, NULL);
}
if (ddrval != DD_OK)
{
return FALSE;
}
pix.dwSize = sizeof(pix);
pix.dwFlags = DDPF_RGB;
BackSurface->GetPixelFormat(&pix);
if (pix.dwRBitMask == 0x7C00)
{
depth = 15;
}
else
{
depth = 16;
}
bActive = TRUE;
if (useDirectDraw)
{
scratch_pitch = GetPitch();
scratch_buffer_2 = NULL;
}
else
{
depth = 15;
scratch_pitch = 2*SCRWIDTH;
scratch_buffer_2 = (BYTE*)malloc(scratch_pitch*SCRHEIGHT);
}
scratch_buffer = (BYTE*)malloc(scratch_pitch*SCRHEIGHT);
memset(scratch_buffer, 0, scratch_pitch*SCRHEIGHT);
clear_buffers();
return TRUE;
}
示例4: set_fullscreen
//must be the game window
int dd_Window::set_fullscreen(int w, int h, int bpp)
{
_ASSERTE(bGameWindow);
quad ws;
HRESULT hr;
DX_RELEASE(dx_os);
DX_RELEASE(dx_ps);
DX_RELEASE(dx_win_ps);
hr = dx_dd->SetCooperativeLevel(hMainWnd, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
if (hr != DD_OK)
{
return 0;
}
//hack for 320x200 letterboxing
if(w == 320 && h == 200)
dx_dd->SetDisplayMode(320, 240, bpp);
else
dx_dd->SetDisplayMode(w, h, bpp);
hr = dx_dd->CreateSurface(&dx_psd, &dx_ps, NULL);
if (hr != DD_OK)
{
return 0;
}
dx_osd.dwWidth=w;
dx_osd.dwHeight=h;
hr=dx_dd->CreateSurface(&dx_osd,&dx_os,NULL);
if(hr!=DD_OK)
{
return 0;
}
hr = dx_ps->GetAttachedSurface(&dx_bsd.ddsCaps, &dx_bs);
if (hr != DD_OK)
{
DX_RELEASE(dx_os);
return 0;
}
ws = GetWindowLong(hwnd, GWL_STYLE);
ws &= ~WS_OVERLAPPEDWINDOW;
ws |= WS_POPUP;
SetWindowLong(hwnd, GWL_STYLE, ws);
SetWindowPos(hwnd,0,0,0,0,0,SWP_NOSIZE|SWP_NOMOVE|SWP_FRAMECHANGED | SWP_NOZORDER);
//make window take up entire screen
//choose one or the other
//SetWindowPos(hwnd,0,0,0,w,h,SWP_NOACTIVATE | SWP_NOZORDER);
ShowWindow(hwnd,SW_SHOWMAXIMIZED);
//set pixelformat parameters
{
DDPIXELFORMAT ddpf;
ddpf.dwSize = sizeof(ddpf);
ddpf.dwFlags = DDPF_RGB;
hr = dx_ps->GetPixelFormat(&ddpf);
if (hr != DD_OK) err("Could not get pixel format!");
//if (ddpf.dwRBitMask == 0x7C00 && bpp == 16)
// vid_bpp = 15, vid_bytesperpixel = 2;
//else
// vid_bpp = bpp, vid_bytesperpixel = bpp / 8;
vid_bpp = 32;
}
if(img) delete img;
img = new image();
img->shell = true;
SetHandleImage(1,img);
screen = img;
// img->alphamap = 0;
img->width = w;
img->height = h;
img->cx1 = 0;
img->cx2 = w-1;
img->cy1 = 0;
img->cy2 = h-1;
img->data=0;
flip_fullscreen();
return 1;
}