本文整理汇总了C++中LPDIRECTDRAWSURFACE7::GetPixelFormat方法的典型用法代码示例。如果您正苦于以下问题:C++ LPDIRECTDRAWSURFACE7::GetPixelFormat方法的具体用法?C++ LPDIRECTDRAWSURFACE7::GetPixelFormat怎么用?C++ LPDIRECTDRAWSURFACE7::GetPixelFormat使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LPDIRECTDRAWSURFACE7
的用法示例。
在下文中一共展示了LPDIRECTDRAWSURFACE7::GetPixelFormat方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init_window
bool video::init_window(int sizex, int sizey)
{
assert(win_hInstance != 0);
g_sizex = sizex; g_sizey = sizey;
if( !WinInit(win_hInstance, win_iCmdShow, gWndClass, title, false) )
return DisplayError("Unable to initialize the program's window.");
running = true;
if( !DDInit() ) {
DestroyDDraw();
goto fail;
}
if( !DDOverlayInit() || !DrawOverlay() ) {
DestroyOverlay();
DestroyDDraw();
goto fail;
}
DDPIXELFORMAT PixelFormat; memset(&PixelFormat, 0, sizeof(PixelFormat)); PixelFormat.dwSize = sizeof(PixelFormat);
g_pDDSOverlay->GetPixelFormat(&PixelFormat);
mask2bits(PixelFormat.dwRBitMask, red_mask, red_shift);
mask2bits(PixelFormat.dwGBitMask, green_mask, green_shift);
mask2bits(PixelFormat.dwBBitMask, blue_mask, blue_shift);
if(PixelFormat.dwFlags == DDPF_RGB)
depth = char(PixelFormat.dwRGBBitCount);
else depth = -char(PixelFormat.dwFourCC);
for(int i = 0, e = sizex * sizey * PixelFormat.dwRGBBitCount / 32, c = get_color(0, 0, 0); i < e; i++)
g_pImg[i] = c; // clear surface
ShowWindow(g_hAppWnd, SW_SHOW);
g_hVSync = CreateThread (
NULL, // LPSECURITY_ATTRIBUTES security_attrs
0, // SIZE_T stacksize
(LPTHREAD_START_ROUTINE) thread_vsync,
this, // argument
0, 0);
SetPriorityClass(g_hVSync, IDLE_PRIORITY_CLASS); // questionable
return true;
fail:
g_pImg = new unsigned int[g_sizex * g_sizey];
return false;
}
示例2: DDAccurateInit
void DDAccurateInit(int resize)
{
DDPIXELFORMAT DDpf;
DDSURFACEDESC2 ddsd;
float OrigW, OrigH, ScaleW, ScaleH;
OrigW=Form1->ClientWidth;
OrigH=Form1->ClientHeight;
if (Form1->StatusBar1->Visible) OrigH -= Form1->StatusBar1->Height;
if (Form1->BaseWidth==0) Form1->BaseWidth= NoWinR-NoWinL;
if (Form1->BaseHeight==0) Form1->BaseHeight= NoWinT-NoWinB;
ScaleW = OrigW / Form1->BaseWidth;
ScaleH = OrigH / Form1->BaseHeight;
RasterX=0;
RasterY=random(256);
//fill the DDpf structure and get the BytesPerPixel
ZeroMemory (&DDpf, sizeof(DDpf));
DDpf.dwSize = sizeof(DDpf);
m_pddsFrontBuffer->GetPixelFormat(&DDpf);
BPP = DDpf.dwRGBBitCount/8;
Paletteised = (BPP==1) ? true:false;
Scale= tv.AdvancedEffects?2:1;
//ScanLen=460*BPP;
ScanLen=(2+machine.tperscanline*2)*BPP;
switch(zx81.bordersize)
{
case BORDERNONE:
WinL=BlWinL; WinR=BlWinR; WinT=BlWinT; WinB=BlWinB;
if (zx81.NTSC) { WinT-=24; WinB-=24; }
break;
case BORDERSMALL:
WinL=SmWinL; WinR=SmWinR; WinT=SmWinT; WinB=SmWinB;
if (zx81.NTSC) { WinT-=24; WinB-=24; }
break;
case BORDERNORMAL:
WinL=NoWinL; WinR=NoWinR; WinT=NoWinT; WinB=NoWinB;
if (zx81.NTSC) { WinT-=24; WinB-=24; }
break;
case BORDERLARGE:
WinL=LaWinL; WinR=LaWinR; WinT=LaWinT; WinB=LaWinB;
if (zx81.NTSC) { WinB-=24; }
break;
case BORDERFULL:
WinL=FuWinL; WinR=FuWinR; WinT=FuWinT; WinB=FuWinB;
if (zx81.NTSC) WinB-=51;
break;
}
ZeroMemory( &ddsd, sizeof( ddsd ) );
ddsd.dwSize = sizeof( ddsd );
// Create the backbuffer surface
ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE;
if (tv.AdvancedEffects)
{
WinL*=2; WinR*=2; WinT*=2; WinB*=2; ScanLen*=2;
TVW=ddsd.dwWidth = 1024;
TVH=ddsd.dwHeight = 768;
HSYNC_TOLLERANCE=HTOL*2; HSYNC_MINLEN=10;
VSYNC_TOLLERANCE=VTOL*2; VSYNC_MINLEN=350;
}
else
{
TVW=ddsd.dwWidth = 520;
TVH=ddsd.dwHeight = 380;
HSYNC_TOLLERANCE=HTOL; HSYNC_MINLEN=10;
VSYNC_TOLLERANCE=VTOL; VSYNC_MINLEN=350;
}
m_pddsFrame->Release(); m_pddsFrame = NULL;
m_pDD->CreateSurface(&ddsd, &m_pddsFrame, NULL);
if (zx81.NTSC) VSYNC_TOLLERANCE-=60;
if ((resize) && (!Form1->FullScreen))
{
Form1->BaseWidth=WinR-WinL;
Form1->BaseHeight=WinB-WinT;
OrigW = Form1->BaseWidth * ScaleW;
OrigH = Form1->BaseHeight * ScaleH;
if (Form1->StatusBar1->Visible) OrigH += Form1->StatusBar1->Height;
Form1->ClientWidth = OrigW;
Form1->ClientHeight = OrigH;
}
DDFrame=m_pddsFrame;
ZeroMemory(&DDFrameSurface, sizeof(DDFrameSurface));
DDFrameSurface.dwSize = sizeof(DDFrameSurface);
//.........这里部分代码省略.........
示例3: Game_Init
int Game_Init(void *parms = NULL, int num_parms = 0)
{
// this is called once after the initial window is created and
// before the main event loop is entered, do all your initialization
// here
int retval = 0;
colors16 = new WORD[65536];
// create IDirectDraw interface 7.0 object and test for error
if (FAILED(DirectDrawCreateEx(NULL, (void **)&lpdd, IID_IDirectDraw7, NULL)))
{
// something bad happened during initialization, buh-bye!
SendMessage(main_window_handle,WM_CLOSE,0,0);
g_ddStepFailure = DDSF_DDACCESS;
retval = 0;
}
else
{
// set cooperation to normal since this will be a windowed app
lpdd->SetCooperativeLevel( main_window_handle,
DDSCL_FULLSCREEN
| DDSCL_ALLOWMODEX
| DDSCL_EXCLUSIVE
| DDSCL_ALLOWREBOOT
| DDSCL_MULTITHREADED );
if (FAILED(lpdd->SetDisplayMode( screen_width,
screen_height,
screen_bpp,
0, // refresh rate (use default)
0 ) // flags..
)
)
{
SendMessage(main_window_handle,WM_CLOSE,0,0);
g_ddStepFailure = DDSF_SETDISPLAYMODE;
retval = 0;
}
else
{
{
// create direct draw surface..
memset(&ddsd,0,sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS;
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
if (FAILED(lpdd->CreateSurface(&ddsd,
&lpddsprimary,
NULL)
)
)
{
SendMessage(main_window_handle,WM_CLOSE,0,0);
g_ddStepFailure = DDSF_SURFACECREATE;
retval = 0;
}
else
{
{
// now get the pixel format..
//
memset(&ddpixel,0,sizeof(ddpixel));
ddpixel.dwSize = sizeof(ddpixel);
lpddsprimary->GetPixelFormat(&ddpixel);
if (ddpixel.dwFlags & DDPF_RGB)
{
// RGB mode..
switch(ddpixel.dwRGBBitCount)
{
case 15:
{
// 5.5.5
g_rgb16bitmode = RGB16MODE_555;
makeColors555();
MessageBox(main_window_handle,
"5.5.5",
"bit mode detected...",
MB_OK | MB_ICONEXCLAMATION );
}
break;
case 16:
{
// 5.6.5
g_rgb16bitmode = RGB16MODE_565;
makeColors565();
MessageBox(main_window_handle,
"5.6.5",
"bit mode detected...",
MB_OK | MB_ICONEXCLAMATION );
//.........这里部分代码省略.........