本文整理汇总了C++中LPDIRECTDRAW::QueryInterface方法的典型用法代码示例。如果您正苦于以下问题:C++ LPDIRECTDRAW::QueryInterface方法的具体用法?C++ LPDIRECTDRAW::QueryInterface怎么用?C++ LPDIRECTDRAW::QueryInterface使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LPDIRECTDRAW
的用法示例。
在下文中一共展示了LPDIRECTDRAW::QueryInterface方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DirectDrawCreate
static vmResult win32ddraw_init(void)
{
LPDIRECTDRAW oldDraw;
int ret;
int x;
if (!win_registerDirectDrawWindowClass(myHInst, myHPreInst) ||
!win_createDirectDrawWindows(myHInst, mynCmdShow))
return vmInternalError;
// log("init\n");
for (x=0; x<16; x++)
win_rgbmap[x]=x;
win_rgbmap[16] = 15;
/* DirectDraw initialization */
ret = DirectDrawCreate((GUID *)NULL, &oldDraw, NULL);
if (ret != DD_OK)
DDFAIL("DirectDrawCreate", ret);
if (!SUCCEEDED(oldDraw->QueryInterface(IID_IDirectDraw2,
reinterpret_cast<void**>(&lpDD))))
DDFAIL("QueryInterface", -1);
// --
features|=FE_SHOWVIDEO|FE_VIDEO;
return vmOk;
}
示例2: QueryVideoMemorySize
HRESULT CUtilGPU::QueryVideoMemorySize(DWORD dwCaps, DWORD* pdwTotalMem, DWORD* pdwFreeMem)
{
LPDIRECTDRAW lpdd = NULL;
HRESULT hr = DirectDrawCreate(NULL, &lpdd, NULL);
if(SUCCEEDED(hr))
{
LPDIRECTDRAW7 lpdd7 = NULL;
hr = lpdd->QueryInterface(IID_IDirectDraw7, (LPVOID*)&lpdd7);
if(SUCCEEDED(hr))
{
DDSCAPS2 ddsCaps2;
DWORD dwTotal=0, dwFree=0;
// Initialize the structure.
ZeroMemory(&ddsCaps2, sizeof(ddsCaps2));
ddsCaps2.dwCaps = dwCaps;
hr = lpdd7->GetAvailableVidMem(&ddsCaps2, &dwTotal, &dwFree);
if(SUCCEEDED(hr))
{
if(pdwTotalMem)
*pdwTotalMem =(dwTotal>>20); //rounded to MB
if(pdwFreeMem)
*pdwFreeMem = (dwFree>>20); //rounded to MB
}
lpdd7->Release();
}
lpdd->Release();
}
return hr;
}
示例3: DDEnumDevCallback
BOOL WINAPI DDEnumDevCallback(GUID FAR *lpGUID, LPSTR lpDriverDescription, LPSTR lpDriverName, LPVOID lpContext, HMONITOR hm)
{
LPDIRECTDRAW ddp;
LPDIRECTDRAW4 dd4p;
DDDEVICEIDENTIFIER ddDev;
BOOL ret = FALSE;
if (DirectDrawCreate(lpGUID,&ddp,0) == DD_OK)
{
if(ddp->QueryInterface(IID_IDirectDraw4,(void **)&dd4p) == S_OK)
{
ZeroMemory(&ddDev,sizeof(ddDev));
if(GetDeviceIdentifierEx(dd4p,&ddDev, DDGDI_GETHOSTIDENTIFIER) == DD_OK)
{
// add to table
USES_CONVERSION;
CUtilGPU::AddDisplayDevice(A2CT(lpDriverName), ddDev.dwVendorId, ddDev.dwDeviceId, ddDev.szDescription, ddDev.szDriver);
ret = TRUE;
}
dd4p->Release();
}
ddp->Release();
}
return ret;
}
示例4: InitDirectDraw
HRESULT DDVideo::InitDirectDraw()
{
DDSURFACEDESC2 ddsd;
DDSCAPS2 ddscaps;
HRESULT hRet;
//Create the main DirectDraw object - updated to do it the hard way.... 7/10
LPDIRECTDRAW pDD;
HINSTANCE hInstDDraw;
LPDIRECTDRAWCREATE pDDCreate = NULL;
hInstDDraw = LoadLibrary("ddraw.dll");
pDDCreate = ( LPDIRECTDRAWCREATE )GetProcAddress( hInstDDraw, "DirectDrawCreate" );
pDDCreate( NULL, &pDD, NULL );
//hRet = DirectDrawCreate(NULL,&pDD, NULL);
hRet = pDD->QueryInterface(IID_IDirectDraw7, (LPVOID *) & m_lpDD);
//Set cooperative level
if (m_bWindowed) { //#112
m_lpDD->SetCooperativeLevel(m_hWnd, DDSCL_ALLOWREBOOT | DDSCL_NORMAL | DDSCL_MULTITHREADED);
} else {
hRet = m_lpDD->SetCooperativeLevel(m_hWnd,DDSCL_EXCLUSIVE |DDSCL_ALLOWREBOOT| DDSCL_ALLOWMODEX | DDSCL_FULLSCREEN | DDSCL_MULTITHREADED);
m_lpDD->SetDisplayMode(800,600,16,g_DX9Settings.m_refreshrate,0);
}
ZeroMemory(&ddsd, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
//#112
ddsd.dwFlags = (m_bWindowed) ? DDSD_CAPS : DDSD_CAPS | DDSD_BACKBUFFERCOUNT;
ddsd.ddsCaps.dwCaps = (m_bWindowed) ? DDSCAPS_PRIMARYSURFACE : DDSCAPS_PRIMARYSURFACE | DDSCAPS_FLIP | DDSCAPS_COMPLEX;
if (m_bWindowed) {
LPDIRECTDRAWCLIPPER lpClipper;
hRet = m_lpDD->CreateSurface(&ddsd, &m_lpDDSPrimary, NULL);
hRet = m_lpDD->CreateClipper( 0, &lpClipper, NULL );
hRet = lpClipper->SetHWnd( 0, m_hWnd );
hRet = m_lpDDSPrimary->SetClipper( lpClipper );
ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH;
ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
ddsd.dwWidth = 800;
ddsd.dwHeight = 600;
hRet = m_lpDD->CreateSurface(&ddsd, &m_lpDDSBack, NULL);
} else {
ddsd.dwBackBufferCount = 1;
hRet = m_lpDD->CreateSurface(&ddsd, &m_lpDDSPrimary, NULL);
ZeroMemory( &ddscaps, sizeof( ddscaps ) );
ddscaps.dwCaps=DDSCAPS_BACKBUFFER;
hRet = m_lpDDSPrimary->GetAttachedSurface(&ddscaps,&m_lpDDSBack);
}
pDD->Release();
return hRet;
}
示例5: GetVideoMemoryViaDirectDraw
//-----------------------------------------------------------------------------
HRESULT GetVideoMemoryViaDirectDraw( HMONITOR hMonitor, DWORD* pdwAvailableVidMem )
{
LPDIRECTDRAW pDDraw = nullptr;
LPDIRECTDRAWENUMERATEEXA pDirectDrawEnumerateEx = nullptr;
HRESULT hr;
bool bGotMemory = false;
*pdwAvailableVidMem = 0;
HINSTANCE hInstDDraw;
LPDIRECTDRAWCREATE pDDCreate = nullptr;
hInstDDraw = LoadLibrary( L"ddraw.dll" );
if( hInstDDraw )
{
DDRAW_MATCH match = {};
match.hMonitor = hMonitor;
pDirectDrawEnumerateEx = ( LPDIRECTDRAWENUMERATEEXA )GetProcAddress( hInstDDraw, "DirectDrawEnumerateExA" );
if( pDirectDrawEnumerateEx )
{
hr = pDirectDrawEnumerateEx( DDEnumCallbackEx, ( VOID* )&match, DDENUM_ATTACHEDSECONDARYDEVICES );
}
pDDCreate = ( LPDIRECTDRAWCREATE )GetProcAddress( hInstDDraw, "DirectDrawCreate" );
if( pDDCreate )
{
pDDCreate( &match.guid, &pDDraw, nullptr );
LPDIRECTDRAW7 pDDraw7;
if( SUCCEEDED( pDDraw->QueryInterface( IID_IDirectDraw7, ( VOID** )&pDDraw7 ) ) )
{
DDSCAPS2 ddscaps = {};
ddscaps.dwCaps = DDSCAPS_VIDEOMEMORY | DDSCAPS_LOCALVIDMEM;
hr = pDDraw7->GetAvailableVidMem( &ddscaps, pdwAvailableVidMem, nullptr );
if( SUCCEEDED( hr ) )
bGotMemory = true;
pDDraw7->Release();
}
}
FreeLibrary( hInstDDraw );
}
if( bGotMemory )
return S_OK;
else
return E_FAIL;
}
示例6: CreateD3D
// Direct3D 생성
BOOL CreateD3D()
{
// DirectDraw 인터페이스 생성
LPDIRECTDRAW lpdd;
// 설정된 DirectDraw Device
HRESULT hresult = DirectDrawCreate( NULL, &lpdd, NULL );
if ( hresult != DD_OK )
{
MESSAGE( "DirectDrawCreate" );
return FALSE;
}
// DirectDraw2 인터페이스 얻기
hresult = lpdd->QueryInterface( IID_IDirectDraw4, (LPVOID*)&lpDD );
if ( hresult != DD_OK )
{
MESSAGE( "lpdd->QueryInterface" );
return FALSE;
}
// DirectDraw 인터페이스 제거
lpdd->Release();
// Direct3D 인터페이스 얻기
hresult = lpDD->QueryInterface( IID_IDirect3D3, (LPVOID*)&lpD3D );
if ( hresult != DD_OK )
{
MESSAGE( "lpDD3->QueryInterface" );
return FALSE;
}
// Direct3D Device 인터페이스 얻기
hresult = lpD3D->EnumDevices( DeviceEnumCallback, (LPVOID)&lpDeviceDesc );
if ( hresult != DD_OK )
{
MESSAGE( "lpD3D->EnumDevices" );
return FALSE;
}
lpD3DDeviceDesc = FindBestDevice( lpDeviceDesc );
if ( !lpD3DDeviceDesc )
return FALSE;
return TRUE;
}
示例7: _GameMode
BOOL _GameMode( HINSTANCE hInstance, int nCmdShow, int x, int y, int bpp )
{
HRESULT result;
WNDCLASS wc;
DDSURFACEDESC ddsd;
DDSCAPS ddscaps;
LPDIRECTDRAW pdd;
wc.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS;
wc.lpfnWndProc = WindowProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon( NULL, IDI_APPLICATION );
wc.hCursor = LoadCursor( NULL, IDC_ARROW );
wc.hbrBackground = GetStockBrush(BLACK_BRUSH);
wc.lpszMenuName = NULL;
wc.lpszClassName = "EXAM3";
RegisterClass( &wc );
MainHwnd = CreateWindowEx (
0, "EXAM3", NULL, WS_POPUP, 0, 0,
GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN),
NULL, NULL, hInstance, NULL );
if ( !MainHwnd ) return FALSE;
SetFocus( MainHwnd );
ShowWindow( MainHwnd, nCmdShow );
UpdateWindow( MainHwnd );
ShowCursor( FALSE );
result = DirectDrawCreate( NULL, &pdd, NULL );
if ( result != DD_OK ) return Fail( MainHwnd );
result = pdd->QueryInterface(IID_IDirectDraw, (LPVOID *) &DirectOBJ);
if ( result != DD_OK ) return Fail( MainHwnd );
gWidth=x;
gHeight=y;
// 윈도우 핸들의 협력 단계를 설정한다.
if(gFullScreen){
result = DirectOBJ->SetCooperativeLevel( MainHwnd, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN );
if ( result != DD_OK ) return Fail( MainHwnd );
result = DirectOBJ->SetDisplayMode( x, y, bpp);
if ( result != DD_OK ) return Fail( MainHwnd );
memset( &ddsd, 0, sizeof(ddsd) );
ddsd.dwSize = sizeof( ddsd );
ddsd.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT;
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_FLIP | DDSCAPS_COMPLEX;
ddsd.dwBackBufferCount = 1;
result = DirectOBJ -> CreateSurface( &ddsd, &RealScreen, NULL );
if ( result != DD_OK ) return Fail( MainHwnd );
memset( &ddscaps, 0, sizeof(ddscaps) );
ddscaps.dwCaps = DDSCAPS_BACKBUFFER;
result = RealScreen -> GetAttachedSurface( &ddscaps, &BackScreen );
if ( result != DD_OK ) return Fail( MainHwnd );
}
else{
result = DirectOBJ->SetCooperativeLevel( MainHwnd, DDSCL_NORMAL );
if ( result != DD_OK ) return Fail( MainHwnd );
memset( &ddsd, 0, sizeof(ddsd) );
ddsd.dwSize = sizeof( ddsd );
ddsd.dwFlags = DDSD_CAPS;
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
ddsd.dwBackBufferCount = 0;
result = DirectOBJ -> CreateSurface( &ddsd, &RealScreen, NULL );
if(result != DD_OK) return Fail(MainHwnd);
memset( &ddsd, 0, sizeof(ddsd) );
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH;
ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
ddsd.dwWidth = x;
ddsd.dwHeight = y;
result = DirectOBJ->CreateSurface( &ddsd, &BackScreen, NULL );
if ( result != DD_OK ) return Fail( MainHwnd );
result = DirectOBJ->CreateClipper( 0, &ClipScreen, NULL);
if ( result != DD_OK ) return Fail( MainHwnd );
result = ClipScreen->SetHWnd( 0, MainHwnd );
if ( result != DD_OK ) return Fail( MainHwnd );
result = RealScreen->SetClipper( ClipScreen );
if ( result != DD_OK ) return Fail( MainHwnd );
SetWindowPos(MainHwnd, NULL, 100, 100, x, y, SWP_NOZORDER | SWP_NOACTIVATE);
}
//.........这里部分代码省略.........
示例8: GetDXVersion
//-----------------------------------------------------------------------------
// Name: GetDXVersion()
// Desc: This function returns the DirectX version number as follows:
// 0x0000 = No DirectX installed
// 0x0100 = DirectX version 1 installed
// 0x0200 = DirectX 2 installed
// 0x0300 = DirectX 3 installed
// 0x0500 = At least DirectX 5 installed.
// 0x0600 = At least DirectX 6 installed.
// 0x0601 = At least DirectX 6.1 installed.
// 0x0700 = At least DirectX 7 installed.
// 0x0800 = At least DirectX 8 installed.
//
// Please note that this code is intended as a general guideline. Your
// app will probably be able to simply query for functionality (via
// QueryInterface) for one or two components.
//
// Please also note:
// "if( dwDXVersion != 0x500 ) return FALSE;" is VERY BAD.
// "if( dwDXVersion < 0x500 ) return FALSE;" is MUCH BETTER.
// to ensure your app will run on future releases of DirectX.
//-----------------------------------------------------------------------------
DWORD GetDXVersion()
{
DIRECTDRAWCREATE DirectDrawCreate = NULL;
DIRECTDRAWCREATEEX DirectDrawCreateEx = NULL;
DIRECTINPUTCREATE DirectInputCreate = NULL;
HINSTANCE hDDrawDLL = NULL;
HINSTANCE hDInputDLL = NULL;
HINSTANCE hD3D8DLL = NULL;
HINSTANCE hDPNHPASTDLL = NULL;
LPDIRECTDRAW pDDraw = NULL;
LPDIRECTDRAW2 pDDraw2 = NULL;
LPDIRECTDRAWSURFACE pSurf = NULL;
LPDIRECTDRAWSURFACE3 pSurf3 = NULL;
LPDIRECTDRAWSURFACE4 pSurf4 = NULL;
DWORD dwDXVersion = 0;
HRESULT hr;
// First see if DDRAW.DLL even exists.
hDDrawDLL = LoadLibrary(_T("DDRAW.DLL"));
if( hDDrawDLL == NULL )
{
dwDXVersion = 0;
OutputDebugString(_T("Couldn't LoadLibrary DDraw\r\n"));
return dwDXVersion;
}
// See if we can create the DirectDraw object.
DirectDrawCreate = (DIRECTDRAWCREATE)GetProcAddress( hDDrawDLL, "DirectDrawCreate" );
if( DirectDrawCreate == NULL )
{
dwDXVersion = 0;
FreeLibrary( hDDrawDLL );
OutputDebugString(_T("Couldn't GetProcAddress DirectDrawCreate\r\n"));
return dwDXVersion;
}
hr = DirectDrawCreate( NULL, &pDDraw, NULL );
if( FAILED(hr) )
{
dwDXVersion = 0;
FreeLibrary( hDDrawDLL );
OutputDebugString(_T("Couldn't create DDraw\r\n"));
return dwDXVersion;
}
// So DirectDraw exists. We are at least DX1.
dwDXVersion = 0x100;
// Let's see if IID_IDirectDraw2 exists.
hr = pDDraw->QueryInterface( IID_IDirectDraw2, (VOID**)&pDDraw2 );
if( FAILED(hr) )
{
// No IDirectDraw2 exists... must be DX1
pDDraw->Release();
FreeLibrary( hDDrawDLL );
OutputDebugString(_T("Couldn't QI DDraw2\r\n"));
return dwDXVersion;
}
// IDirectDraw2 exists. We must be at least DX2
pDDraw2->Release();
dwDXVersion = 0x200;
//-------------------------------------------------------------------------
// DirectX 3.0 Checks
//-------------------------------------------------------------------------
// DirectInput was added for DX3
hDInputDLL = LoadLibrary(_T("DINPUT.DLL"));
if( hDInputDLL == NULL )
{
// No DInput... must not be DX3
pDDraw->Release();
FreeLibrary( hDDrawDLL );
OutputDebugString(_T("Couldn't LoadLibrary DInput\r\n"));
return dwDXVersion;
}
//.........这里部分代码省略.........
示例9: GetDXVersion
//.........这里部分代码省略.........
if( DDHinst == 0 )
{
(*pdwDXVersion) = 0;
(*pdwDXPlatform) = 0;
FreeLibrary( DDHinst );
return;
}
// See if we can create the DirectDraw object.
DirectDrawCreate = (DIRECTDRAWCREATE)GetProcAddress( DDHinst, "DirectDrawCreate" );
if( DirectDrawCreate == 0 )
{
(*pdwDXVersion) = 0;
(*pdwDXPlatform) = 0;
FreeLibrary( DDHinst );
OutputDebugString( "Couldn't LoadLibrary DDraw\r\n" );
return;
}
hr = DirectDrawCreate( NULL, &pDDraw, NULL );
if( FAILED(hr) )
{
(*pdwDXVersion) = 0;
(*pdwDXPlatform) = 0;
FreeLibrary( DDHinst );
OutputDebugString( "Couldn't create DDraw\r\n" );
return;
}
// So DirectDraw exists. We are at least DX1.
(*pdwDXVersion) = 0x100;
// Let's see if IID_IDirectDraw2 exists.
hr = pDDraw->QueryInterface( IID_IDirectDraw2, (VOID**)&pDDraw2 );
if( FAILED(hr) )
{
// No IDirectDraw2 exists... must be DX1
pDDraw->Release();
FreeLibrary( DDHinst );
OutputDebugString( "Couldn't QI DDraw2\r\n" );
return;
}
// IDirectDraw2 exists. We must be at least DX2
pDDraw2->Release();
(*pdwDXVersion) = 0x200;
///////////////////////////////////////////////////////////////////////////
// DirectX 3.0 Checks
///////////////////////////////////////////////////////////////////////////
// DirectInput was added for DX3
DIHinst = LoadLibrary( "DINPUT.DLL" );
if( DIHinst == 0 )
{
// No DInput... must not be DX3
OutputDebugString( "Couldn't LoadLibrary DInput\r\n" );
pDDraw->Release();
FreeLibrary( DDHinst );
return;
}
DirectInputCreate = (DIRECTINPUTCREATE)GetProcAddress( DIHinst,
"DirectInputCreateA" );
if( DirectInputCreate == 0 )
示例10: CheckDXVersion
//.........这里部分代码省略.........
if( DDHinst == 0 )
{
(*pdwDXVersion) = 0;
(*pdwDXPlatform) = 0;
FreeLibrary( DDHinst );
return;
}
// See if we can create the DirectDraw object.
DirectDrawCreate = (DIRECTDRAWCREATE)GetProcAddress( DDHinst, "DirectDrawCreate" );
if( DirectDrawCreate == 0 )
{
(*pdwDXVersion) = 0;
(*pdwDXPlatform) = 0;
FreeLibrary( DDHinst );
OutputDebugString( "Couldn't LoadLibrary DDraw\r\n" );
return;
}
hr = DirectDrawCreate( NULL, &pDDraw, NULL );
if( FAILED(hr) )
{
(*pdwDXVersion) = 0;
(*pdwDXPlatform) = 0;
FreeLibrary( DDHinst );
OutputDebugString( "Couldn't create DDraw\r\n" );
return;
}
// So DirectDraw exists. We are at least DX1.
(*pdwDXVersion) = 0x100;
// Let's see if IID_IDirectDraw2 exists.
hr = pDDraw->QueryInterface( IID_IDirectDraw2, (VOID * *)&pDDraw2 );
if( FAILED(hr) )
{
// No IDirectDraw2 exists... must be DX1
pDDraw->Release();
FreeLibrary( DDHinst );
OutputDebugString( "Couldn't QI DDraw2\r\n" );
return;
}
// IDirectDraw2 exists. We must be at least DX2
pDDraw2->Release();
(*pdwDXVersion) = 0x200;
///////////////////////////////////////////////////////////////////////////
// DirectX 3.0 Checks
///////////////////////////////////////////////////////////////////////////
// DirectInput was added for DX3
DIHinst = LoadLibrary( "DINPUT.DLL" );
if( DIHinst == 0 )
{
// No DInput... must not be DX3
OutputDebugString( "Couldn't LoadLibrary DInput\r\n" );
pDDraw->Release();
FreeLibrary( DDHinst );
return;
}
DirectInputCreate = (DIRECTINPUTCREATE)GetProcAddress( DIHinst,
"DirectInputCreateA" );
if( DirectInputCreate == 0 )
示例11:
int PisteDraw_Alusta(HWND &main_window_handle, HINSTANCE &hinstance_app,
int leveys, int korkeus, int bpp,
int max_colors)
{
if (PD_unload) {
strcpy(virhe,"Uh, oh, I think we have a bug...");
PD_main_window_handle = (HWND &)main_window_handle;
PD_hinstance_app = (HINSTANCE &)hinstance_app;
PD_ruudun_leveys = leveys;
PD_ruudun_korkeus = korkeus;
PD_ruudun_bpp = bpp;
PD_max_varit = max_colors;
LPDIRECTDRAW temp = NULL; // väliaikainen rajapinta jolla haetaan uusin versio
int i;
if (FAILED(DirectDrawCreate(NULL, &temp, NULL))) // luo rajapintaosoitin versioon 1.0
{
strcpy(virhe,"Cannot initialize DirectDraw!");
PisteLog_Kirjoita("[Error] Piste Draw: Cannot initialize DirectDraw! \n");
return PD_VIRHE;
}
if (FAILED(temp->QueryInterface(IID_IDirectDraw4,(LPVOID *)&PD_lpdd))) // osoitin v 4.0
{
strcpy(virhe,"Cannot initialize DirectDraw4!");
PisteLog_Kirjoita("[Error] Piste Draw: Cannot initialize DirectDraw4! \n");
return PD_VIRHE;
}
temp->Release(); // tuhotaan väliaikainen rajapinta
temp = NULL;
if (FAILED(PD_lpdd->SetCooperativeLevel(PD_main_window_handle, // Yhteistyö Windowsin kanssa..
DDSCL_FULLSCREEN | DDSCL_ALLOWMODEX |
DDSCL_EXCLUSIVE | DDSCL_ALLOWREBOOT)))
{
strcpy(virhe,"Failed to cooperate with Windows!");
PisteLog_Kirjoita("[Error] Piste Draw: Failed to cooperate with Windows! \n");
return PD_VIRHE;
}
if (FAILED(PD_lpdd->SetDisplayMode(PD_ruudun_leveys, PD_ruudun_korkeus, PD_ruudun_bpp,0,0)))
{
strcpy(virhe,"Unable to change video mode!");
PisteLog_Kirjoita("[Error] Piste Draw: Unable to change video mode! \n");
return PD_VIRHE;
}
DD_INIT_STRUCT(PD_ddsd);
PD_ddsd.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT;
PD_ddsd.dwBackBufferCount = 2; //Kolmoispuskurointi = primary + 2 taustapuskuria
PD_ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP;
if (FAILED(PD_lpdd->CreateSurface(&PD_ddsd, &PD_lpddsprimary, NULL)))
{
strcpy(virhe,"Cannot create primary surface!");
PisteLog_Kirjoita("[Error] Piste Draw: Cannot create primary surface! \n");
return PD_VIRHE;
}
PD_buffers[PD_TAUSTABUFFER].leveys = leveys;
PD_buffers[PD_TAUSTABUFFER].korkeus = korkeus;
PisteDraw_Aseta_Klipperi(PD_TAUSTABUFFER,0,0,leveys,korkeus);
PD_ddsd.ddsCaps.dwCaps = DDSCAPS_BACKBUFFER;
if (FAILED(PD_lpddsprimary->GetAttachedSurface(&PD_ddsd.ddsCaps, &PD_buffers[PD_TAUSTABUFFER].lpdds)))
{
strcpy(virhe,"Cannot attach back buffer to primary surface!");
PisteLog_Kirjoita("[Error] Piste Draw: Cannot attach back buffer to primary surface! \n");
return PD_VIRHE;
}
PD_buffers[PD_TAUSTABUFFER2].leveys = leveys;
PD_buffers[PD_TAUSTABUFFER2].korkeus = korkeus;
PisteDraw_Aseta_Klipperi(PD_TAUSTABUFFER2,0,0,leveys,korkeus);
for (i=1;i<255;i++) //Luodaan 8-bittinen paletti
{
PD_paletti[i].peRed = 0;
PD_paletti[i].peGreen = 0;
PD_paletti[i].peBlue = 0;
PD_paletti[i].peFlags = PC_NOCOLLAPSE;
}
if (FAILED(PD_lpdd->CreatePalette(DDPCAPS_8BIT |
DDPCAPS_ALLOW256 |
DDPCAPS_INITIALIZE,
PD_paletti,
&PD_lpddpal,
NULL)))
{
PisteLog_Kirjoita("[Error] Piste Draw: Cannot create 8-bit palette! \n");
strcpy(virhe,"Cannot create 8-bit palette!");
return PD_VIRHE;
}
//.........这里部分代码省略.........
示例12: DD_Init
int DD_Init(HWND hwnd)
{
int index;
if(DirectDrawCreate(NULL,&pdd,NULL)!=DD_OK)
{
DD_Shutdown();
return 0;
}
if(pdd->QueryInterface(IID_IDirectDraw4, (LPVOID *) & lpdd ) != DD_OK)
{
DD_Shutdown();
return 0;
}
if(lpdd->SetCooperativeLevel(hwnd, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN ) != DD_OK )
{
DD_Shutdown();
return 0;
}
if(lpdd->SetDisplayMode(SCREEN_WIDTH,SCREEN_HEIGHT,SCREEN_BPP,0,0) != DD_OK)
{
DD_Shutdown();
return 0;
}
ZeroMemory(&ddsd, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT;
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_FLIP | DDSCAPS_COMPLEX;
ddsd.dwBackBufferCount = 1;
if (lpdd->CreateSurface(&ddsd,&lpddsprimary,NULL) != DD_OK)
{
DD_Shutdown();
return 0;
}
ddscaps.dwCaps = DDSCAPS_BACKBUFFER;
if (lpddsprimary->GetAttachedSurface(&ddscaps,&lpddsback) != DD_OK)
{
DD_Shutdown();
return 0;
}
memset(colour_palette,0,256*sizeof(PALETTEENTRY));
for(index = 0; index < 256; index++ )
{
colour_palette[index].peRed = colour_bmp_file.palette[index].peBlue ;
colour_palette[index].peBlue = colour_bmp_file.palette[index].peRed;
colour_palette[index].peGreen = colour_bmp_file.palette[index].peGreen;
colour_palette[index].peFlags = PC_NOCOLLAPSE;
}
if(lpdd->CreatePalette((DDPCAPS_8BIT | DDPCAPS_INITIALIZE),colour_palette,&lpddpal,NULL)!=DD_OK)
{
DD_Shutdown();
return 0;
}
lpddsprimary->SetPalette(lpddpal);
// lpddsback->SetPalette(lpddpal);
return 1;
} // end DD_Init