本文整理汇总了C++中LPDIRECTDRAWSURFACE::GetAttachedSurface方法的典型用法代码示例。如果您正苦于以下问题:C++ LPDIRECTDRAWSURFACE::GetAttachedSurface方法的具体用法?C++ LPDIRECTDRAWSURFACE::GetAttachedSurface怎么用?C++ LPDIRECTDRAWSURFACE::GetAttachedSurface使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LPDIRECTDRAWSURFACE
的用法示例。
在下文中一共展示了LPDIRECTDRAWSURFACE::GetAttachedSurface方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DDInitFullscreen
int DDInitFullscreen(int width, int height, int bpp, HWND hwnd)
{
HRESULT ret;
// create object and test for error
if (DirectDrawCreate(NULL, &lpDD, NULL) != DD_OK) {
return(0);
}
// set cooperation level to windowed mode normal
if (lpDD->SetCooperativeLevel(hwnd, DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE) != DD_OK) {
return(0);
}
// set the display mode
if (lpDD->SetDisplayMode(width, height, bpp) != DD_OK) {
return(0);
}
// set globals
screen_height = height;
screen_width = width;
screen_bpp = bpp;
// Create the primary surface
memset(&ddsd, 0, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT;
// we need to let dd know that we want a complex
// flippable surface structure, set flags for that
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_FLIP | DDSCAPS_COMPLEX;
// set the backbuffer count to 1
ddsd.dwBackBufferCount = 1;
// create the primary surface
ret = lpDD->CreateSurface(&ddsd, &lpDDSPrimary, NULL);
// query for the backbuffer i.e the secondary surface
ddscaps.dwCaps = DDSCAPS_BACKBUFFER;
lpDDSPrimary->GetAttachedSurface(&ddscaps, &lpDDSBack);
// clear out both primary and secondary surfaces
DDFillSurface(lpDDSPrimary, 0);
DDFillSurface(lpDDSBack, 0);
DDGetRGB16();
return 1;
}
示例2: sizeof
static vmResult win32ddraw_enable(void)
{
DDSCAPS ddsCaps;
DDSURFACEDESC ddsd;
int ret;
int idx;
// log("enable\n");
/* Enable fullscreen mode so we can
properly create the surfaces. */
win_SetFullScreenMode();
/* Create primary surface */
memset((void *)&ddsd, 0, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT;
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP;
ddsd.dwBackBufferCount = 1;
ret = lpDD->CreateSurface(&ddsd, &lpDDSPrimary, NULL);
if (ret != DD_OK)
{
module_logger(&win32DirectDrawVideo, _L|LOG_ERROR, _("CreateSurface (%d)\n"), ret);
DDFAIL(_("CreateSurface (screen)"), ret);
}
/* Create back buffer, for page flipping */
ddsCaps.dwCaps = DDSCAPS_BACKBUFFER;
ret = lpDDSPrimary->GetAttachedSurface(&ddsCaps, &lpDDSBack);
if (ret != DD_OK)
DDFAIL(_("GetAttachedSurface (screen)"), ret);
#if 0
/* Create offscreen surface */
ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
ddsd.dwWidth = fsx;
ddsd.dwHeight = fsy;
ret = lpDD->CreateSurface(&ddsd, &lpDDSBitmap, NULL);
if (ret != DD_OK)
DDFAIL(_("CreateSurface (offscreen)"), ret);
#endif
/* Set up the palette. */
for (idx = 0; idx < 256; idx++)
{
DD_RGBTOPAL(idx,
idx == 0 ? 1 :
idx == 16 ? 15 :
idx > 16 ? 8 : idx);
}
/* for (idx = DD_PALBASE+17; idx < 246; idx++)
{
pals[idx].peFlags = PC_NOCOLLAPSE;
pals[idx].peRed = pals[idx].peGreen = pals[idx].peBlue = idx;
}
*/
/* for (idx = 0; idx < 256; idx++)
{
pals[idx].peFlags = PC_NOCOLLAPSE;
pals[idx].peRed = pals[idx].peGreen = pals[idx].peBlue = rand();
}
*/
/* Create the palette */
ret = lpDD->CreatePalette(DDPCAPS_8BIT | DDPCAPS_ALLOW256,
pals, &lpDDPal, (IUnknown FAR *)NULL);
if (ret != DD_OK)
DDFAIL(_("CreatePalette failed"), ret);
/* attach the palette [this may be redundant if we do it twice] */
if (lpDDPal)
{
ret = lpDDSPrimary->SetPalette(lpDDPal);
if (ret != DD_OK)
DDFAIL(_("deo failed (%d)\n"), ret);
// /* turn it on [it should already be so, but make sure] */
// ret = lpDDPal->SetEntries(0 /*flags */, 0, 256, pals);
// if (ret != DD_OK)
// DDFAIL(_("SetEntries failed (%d)\n"), ret);
}
/* Reset screen if we might not be primary */
win_ResetFullScreenMode();
// win_video_event_tag = TM_UniqueTag();
// TM_SetEvent(win_video_event_tag, TM_HZ*100/30, 0,
// TM_REPEAT|TM_FUNC, win_video_update);
return vmOk;
}
示例3: InitGraphics
//.........这里部分代码省略.........
SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE);
// Make sure our window does not hang outside of the work area
SystemParametersInfo( SPI_GETWORKAREA, 0, &rcWork, 0 );
GetWindowRect( g_hwndMain, &rc );
if( rc.left < rcWork.left ) rc.left = rcWork.left;
if( rc.top < rcWork.top ) rc.top = rcWork.top;
SetWindowPos( g_hwndMain, NULL, rc.left, rc.top, 0, 0,
SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE );
}
// Check the color key hardware capabilities
ddcaps.dwSize = sizeof( ddcaps );
memset( &ddsd, 0, sizeof( ddsd ) );
ddsd.dwSize = sizeof( ddsd );
if( g_bFullscreen )
{
// Create surfaces
ddsd.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT;
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE |
DDSCAPS_FLIP |
DDSCAPS_COMPLEX;
ddsd.dwBackBufferCount = 1;
if( FAILED( hr = g_pDD->CreateSurface( &ddsd, &g_pddsFrontBuffer,
NULL ) ) )
{
ShowError(IDS_DDRAW_ERROR_CREATESURFACE);
return E_FAIL;
}
// Get a pointer to the back buffer
ddscaps.dwCaps = DDSCAPS_BACKBUFFER;
if( FAILED( hr = g_pddsFrontBuffer->GetAttachedSurface( &ddscaps,
&g_pddsBackBuffer ) ) )
{
ShowError(IDS_DDRAW_ERROR_GAS);
return E_FAIL;
}
}
else
{
LPDIRECTDRAWCLIPPER pcClipper;
// Window case, create the primary surface
// and create a backbuffer in offscreen memory
ddsd.dwFlags = DDSD_CAPS;
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
if( FAILED( g_pDD->CreateSurface( &ddsd, &g_pddsFrontBuffer, NULL ) ) )
{
ShowError(IDS_DDRAW_ERROR_CREATESURFACE);
return E_FAIL;
}
ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
ddsd.dwWidth = MAX_DEFWIN_X;
ddsd.dwHeight = MAX_DEFWIN_Y;
if( FAILED( hr = g_pDD->CreateSurface( &ddsd, &g_pddsBackBuffer, NULL ) ) )
{
ShowError(IDS_DDRAW_ERROR_CREATESURFACE);
return E_FAIL;
}
if( FAILED( hr = g_pDD->CreateClipper( 0, &pcClipper, NULL) ) )
示例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;
}
示例5: WinMain
//.........这里部分代码省略.........
return FALSE;
}
/* Create a palette for the surfaces. */
ddreturn = lpDirectDrawObject->CreatePalette(DDPCAPS_8BIT | DDPCAPS_ALLOW256 | DDPCAPS_INITIALIZE,
(LPPALETTEENTRY)WinColormap,
&lpPalette,
NULL);
if (ddreturn != DD_OK)
{ DestroyWindow(hwnd);
return FALSE;
}
/* Set the video mode to XRESxYRESx8. */
ddreturn = lpDirectDrawObject->SetDisplayMode(XRES, YRES, 8);
if (ddreturn != DD_OK)
{ DestroyWindow(hwnd);
return FALSE;
}
/* Create a default font for the application. */
AppFont = CreateFont(11,
0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE,
ANSI_CHARSET,
OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS,
NONANTIALIASED_QUALITY,
VARIABLE_PITCH,
"Comic Sans MS");
/* Create the primary surface and one back buffer surface */
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT;
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE |
DDSCAPS_FLIP |
DDSCAPS_COMPLEX;
ddsd.dwBackBufferCount = 1;
ddreturn = lpDirectDrawObject->CreateSurface(&ddsd, &lpPrimary, NULL);
if (ddreturn != DD_OK)
{ DestroyWindow(hwnd);
return FALSE;
}
ddreturn = lpPrimary->SetPalette(lpPalette);
if (ddreturn != DD_OK)
{ DestroyWindow(hwnd);
return FALSE;
}
/* Get a surface pointer to our back buffer. */
ddscaps.dwCaps = DDSCAPS_BACKBUFFER;
ddreturn = lpPrimary->GetAttachedSurface(&ddscaps, &lpBackbuffer);
if (ddreturn != DD_OK)
{ DestroyWindow(hwnd);
return FALSE;
}
/* ddreturn = lpBackbuffer->SetPalette(lpPalette);
if (ddreturn != DD_OK)
{ DestroyWindow(hwnd);
return FALSE;
}
*/
{ /* Clear the background once for both buffers so we don't get anoying flicker effect. */
DDBLTFX BltFx;
BltFx.dwSize = sizeof(BltFx);
BltFx.dwFillColor = 255;
ddreturn = lpBackbuffer->Blt(NULL,
NULL,
NULL,
DDBLT_COLORFILL | DDBLT_WAIT,
&BltFx);
BltFx.dwSize = sizeof(BltFx);
BltFx.dwFillColor = 255;
ddreturn = lpPrimary->Blt(NULL,
NULL,
NULL,
DDBLT_COLORFILL | DDBLT_WAIT,
&BltFx);
}
while (1)
{ if (PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE))
{ if (!GetMessage(&msg, NULL, 0, 0))
return msg.wParam;
TranslateMessage(&msg);
DispatchMessage(&msg);
} else
{ if (ActiveApp && RealTime)
{ // Simulation Iteration should go here.
// Only do this when running Realtime.
SimLoop();
} else
{ WaitMessage();
}
}
}
}