bool StDXManager::checkAqbsSupport(const HWND theWinHandle) { if(!initDxLib()) { return false; } const UINT aD3dAdaptersNb = getAdapterCount(); D3DADAPTER_IDENTIFIER9 anAdapterInfo; for(UINT anAdapterIter = 0; anAdapterIter < aD3dAdaptersNb; ++anAdapterIter) { getAdapterIdentifier(anAdapterIter, 0, &anAdapterInfo); if(anAdapterInfo.VendorId != ST_DX_VENDOR_AMD) { continue; } // setup the present parameters if(getAdapterDisplayMode(anAdapterIter, &myCurrMode) == D3D_OK) { myD3dParams.BackBufferFormat = myCurrMode.Format; myRefreshRate = myCurrMode.RefreshRate; } // create temporary video device myD3dParams.hDeviceWindow = theWinHandle; myD3dDevice = createAqbsTmpDevice(anAdapterIter, theWinHandle, myD3dParams); if(myD3dDevice == NULL) { continue; } // create a surface to be used to communicate with the driver StHandle<StDXAqbsControl> anAqbsControl = new StDXAqbsControl(myD3dDevice); if(!anAqbsControl->isValid()) { myD3dDevice->Release(); myD3dDevice = NULL; return false; } // send the command to the driver using the temporary surface if(!anAqbsControl->enableStereo()) { anAqbsControl.nullify(); myD3dDevice->Release(); myD3dDevice = NULL; return false; } myWithAqbs = true; anAqbsControl.nullify(); myD3dDevice->Release(); myD3dDevice = NULL; return true; } return false; }
// プログラムは WinMain から始まります int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { // 初期化処理 initConsole(); if (!initDxLib()) { exit(1); } SceneManager smgr; BattleScene* start = new BattleScene(); //DrawableFactoryTest* start = new DrawableFactoryTest(); smgr.reserveNewScene(start); smgr.run(); // 終了処理 FreeConsole(); DxLib_End(); return 0; // ソフトの終了 }
bool StDXManager::init(const HWND theWinHandle, const int theSizeX, const int theSizeY, const bool theFullscreen, const StMonitor& theMonitor, const StDXAdapterClass theAdapter) { const StString anAdapterStr = theMonitor.getName().subString(0, 12); if(!initDxLib()) { stError("StDXManager, Direct3DCreate9 failed!"); return false; } const UINT aD3dAdaptersNb = getAdapterCount(); UINT anAdapterId = UINT(-1); UINT anAdapterVendor = UINT(-1); D3DADAPTER_IDENTIFIER9 anAdapterInfo; for(UINT anAdapterIter = 0; anAdapterIter < aD3dAdaptersNb; ++anAdapterIter) { getAdapterIdentifier(anAdapterIter, 0, &anAdapterInfo); switch(theAdapter) { case ST_DX_ADAPTER_AMD: { if(anAdapterInfo.VendorId != ST_DX_VENDOR_AMD) { continue; } anAdapterVendor = anAdapterIter; break; } case ST_DX_ADAPTER_NVIDIA: { if(anAdapterInfo.VendorId != ST_DX_VENDOR_NVIDIA) { continue; } anAdapterVendor = anAdapterIter; break; } case ST_DX_ADAPTER_ANY: default: break; } if(anAdapterStr == StString(anAdapterInfo.DeviceName)) { anAdapterId = anAdapterIter; break; } } if(theAdapter != ST_DX_ADAPTER_ANY) { if(anAdapterId == UINT(-1) && anAdapterVendor != UINT(-1)) { anAdapterId = anAdapterVendor; } if(anAdapterId == UINT(-1)) { return false; } } if(anAdapterId == UINT(-1)) { // the default adapter is the primary display adapter anAdapterId = D3DADAPTER_DEFAULT; } // setup the present parameters if(getAdapterDisplayMode(anAdapterId, &myCurrMode) == D3D_OK) { myD3dParams.BackBufferFormat = myCurrMode.Format; myRefreshRate = myCurrMode.RefreshRate; } myD3dParams.Windowed = !theFullscreen; // is windowed? myD3dParams.BackBufferWidth = theSizeX; myD3dParams.BackBufferHeight = theSizeY; myD3dParams.hDeviceWindow = theWinHandle; // create the Video Device myD3dDevice = createAqbsDevice(anAdapterId, theWinHandle, myD3dParams); if(myD3dDevice == NULL) { HRESULT isOK = myD3dLib->CreateDevice(anAdapterId, D3DDEVTYPE_HAL, // the HAL (hardware accelerated layer) uses your 3d accelerator card theWinHandle, ST_D3D_DEVICE_FLAGS, &myD3dParams, &myD3dDevice); if(isOK < 0) { return false; } } // this normalizes the normal values (this is important for how lighting effects your models) ///myD3dDevice->SetRenderState(D3DRS_NORMALIZENORMALS, TRUE); ST_DEBUG_LOG("Direct3D9, Created StDXManager device (WxH= " + theSizeX + "x"+ theSizeY + ")"); return myD3dDevice != NULL; }