当前位置: 首页>>代码示例>>C++>>正文


C++ LPDIRECTDRAWSURFACE::SetPalette方法代码示例

本文整理汇总了C++中LPDIRECTDRAWSURFACE::SetPalette方法的典型用法代码示例。如果您正苦于以下问题:C++ LPDIRECTDRAWSURFACE::SetPalette方法的具体用法?C++ LPDIRECTDRAWSURFACE::SetPalette怎么用?C++ LPDIRECTDRAWSURFACE::SetPalette使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在LPDIRECTDRAWSURFACE的用法示例。


在下文中一共展示了LPDIRECTDRAWSURFACE::SetPalette方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: BltSplashScreen

//-----------------------------------------------------------------------------
// Name: BltSplashScreen()
// Desc:
//-----------------------------------------------------------------------------
HRESULT BltSplashScreen( RECT* prc )
{
    HRESULT hr;
    HBITMAP hbm;

    if( ( g_pddsFrontBuffer == NULL ) || ( g_pSplashPalette == NULL ) ||
        ( g_pddsBackBuffer == NULL ) )
        return E_FAIL;

    // Set the palette before loading the splash screen
    g_pddsFrontBuffer->SetPalette( g_pSplashPalette );

    hbm = (HBITMAP)LoadImage( GetModuleHandle( NULL ), TEXT("SPLASH"),
                              IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION );
    if( NULL == hbm )
        return E_FAIL;
    
    // If the surface is lost, DDUtil_CopyBitmap will fail and the surface will
    // be restored below.
    hr = DDUtil_CopyBitmap( g_pddsBackBuffer, hbm, 0, 0, 0, 0 );

    DeleteObject( hbm );

    while( 1 )
    {
        hr = g_pddsFrontBuffer->Blt( &g_rcWindow, g_pddsBackBuffer,
                                     prc, DDBLT_WAIT, NULL);
        if( SUCCEEDED(hr) )
            return S_OK;
        if( hr == DDERR_SURFACELOST )
            if( FAILED( RestoreSurfaces() ) )
                return E_FAIL;
        if( hr != DDERR_WASSTILLDRAWING )
            return E_FAIL;
    }
}
开发者ID:grakidov,项目名称:Render3D,代码行数:40,代码来源:gfx.cpp

示例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;
}
开发者ID:eswartz,项目名称:emul,代码行数:96,代码来源:video_win32_ddraw.cpp

示例3: SetGamePalette

//-----------------------------------------------------------------------------
// Name: SetGamePalette()
// Desc:
//-----------------------------------------------------------------------------
VOID SetGamePalette()
{
    if( g_pddsFrontBuffer )
        g_pddsFrontBuffer->SetPalette( g_pArtPalette );
}
开发者ID:grakidov,项目名称:Render3D,代码行数:9,代码来源:gfx.cpp

示例4: RestoreSurfaces

//-----------------------------------------------------------------------------
// Name: RestoreSurfaces()
// Desc:
//-----------------------------------------------------------------------------
HRESULT RestoreSurfaces()
{
    HRESULT hr;
    HBITMAP hbm;

    if( FAILED( hr = g_pddsFrontBuffer->Restore() ) )
        return hr;
    if( FAILED( hr = g_pddsBackBuffer->Restore() ) )
        return hr;

    for( DWORD i=0; i<4; i++ )
        if( FAILED( hr = g_pddsShip[i]->Restore() ) )
            return hr;

    // Create and set the palette for the splash bitmap
    g_pSplashPalette = DDUtil_LoadPalette( g_pDD, TEXT("SPLASH") );
    if( NULL == g_pSplashPalette )
        return E_FAIL;

    // Create and set the palette for the art bitmap
    g_pArtPalette = DDUtil_LoadPalette( g_pDD, TEXT("Duel8") );
    if( NULL == g_pArtPalette )
        return E_FAIL;

    // set the palette before loading the art
    g_pddsFrontBuffer->SetPalette( g_pArtPalette );

    hbm = (HBITMAP)LoadImage( GetModuleHandle(NULL), TEXT("Duel8"),
                              IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION );
    if( NULL == hbm )
        return E_FAIL;

    if( FAILED( hr = DDUtil_CopyBitmap( g_pddsShip[0], hbm, 0, 0, 320, 128 ) ) )
    {
        DeleteObject( hbm );
        return E_FAIL;
    }

    if( FAILED( hr = DDUtil_CopyBitmap( g_pddsShip[1], hbm, 0, 128, 320, 128 ) ) )
    {
        DeleteObject( hbm );
        return E_FAIL;
    }

    if( FAILED( hr = DDUtil_CopyBitmap( g_pddsShip[2], hbm, 0, 256, 320, 128 ) ) )
    {
        DeleteObject( hbm );
        return E_FAIL;
    }

    if( FAILED( hr = DDUtil_CopyBitmap( g_pddsShip[3], hbm, 0, 384, 320, 128 ) ) )
    {
        DeleteObject( hbm );
        return E_FAIL;
    }

    if( FAILED( hr = DDUtil_CopyBitmap( g_pddsNumbers, hbm, 0, 512, 320, 16 ) ) )
    {
        DeleteObject( hbm );
        return E_FAIL;
    }

    DeleteObject( hbm );

    // set colorfill colors and colorkeys according to bitmap contents
    g_dwFillColor = DDUtil_ColorMatch( g_pddsShip[0], CLR_INVALID );
    
    DDUtil_SetColorKey( g_pddsShip[0], CLR_INVALID );
    DDUtil_SetColorKey( g_pddsShip[1], CLR_INVALID );
    DDUtil_SetColorKey( g_pddsShip[2], CLR_INVALID );
    DDUtil_SetColorKey( g_pddsShip[3], CLR_INVALID );
    DDUtil_SetColorKey( g_pddsNumbers, CLR_INVALID );

    return S_OK;
}
开发者ID:grakidov,项目名称:Render3D,代码行数:79,代码来源:gfx.cpp

示例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();
			}
		}
	}
}
开发者ID:kingletbv,项目名称:chrome2k,代码行数:101,代码来源:dxmain.cpp


注:本文中的LPDIRECTDRAWSURFACE::SetPalette方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。