void CRenderTarget::accum_omnip_geom_create () { u32 dwUsage = D3DUSAGE_WRITEONLY; // vertices { u32 vCount = DU_SPHERE_PART_NUMVERTEX; u32 vSize = 3*4; R_CHK (HW.pDevice->CreateVertexBuffer( vCount*vSize, dwUsage, 0, D3DPOOL_MANAGED, &g_accum_omnip_vb, 0)); BYTE* pData = 0; R_CHK (g_accum_omnip_vb->Lock(0,0,(void**)&pData,0)); CopyMemory (pData,du_sphere_part_vertices,vCount*vSize); g_accum_omnip_vb->Unlock (); } // Indices { u32 iCount = DU_SPHERE_PART_NUMFACES*3; BYTE* pData = 0; R_CHK (HW.pDevice->CreateIndexBuffer(iCount*2,dwUsage,D3DFMT_INDEX16,D3DPOOL_MANAGED,&g_accum_omnip_ib,0)); R_CHK (g_accum_omnip_ib->Lock(0,0,(void**)&pData,0)); CopyMemory (pData,du_sphere_part_faces,iCount*2); g_accum_omnip_ib->Unlock (); } }
void CBackend::CreateQuadIB () { const u32 dwTriCount = 4*1024; const u32 dwIdxCount = dwTriCount*2*3; u16 *Indices = 0; u32 dwUsage = D3DUSAGE_WRITEONLY; if (HW.Caps.geometry.bSoftware) dwUsage|=D3DUSAGE_SOFTWAREPROCESSING; R_CHK(HW.pDevice->CreateIndexBuffer (dwIdxCount*2,dwUsage,D3DFMT_INDEX16,D3DPOOL_DEFAULT,&QuadIB,NULL)); HW.stats_manager.increment_stats_ib (QuadIB); // Msg("CBackend::CreateQuadIB(). Created buffer size = %d ", dwIdxCount*2 ); R_CHK(QuadIB->Lock(0,0,(void**)&Indices,0)); { int Cnt = 0; int ICnt= 0; for (int i=0; i<dwTriCount; i++) { Indices[ICnt++]=u16(Cnt+0); Indices[ICnt++]=u16(Cnt+1); Indices[ICnt++]=u16(Cnt+2); Indices[ICnt++]=u16(Cnt+3); Indices[ICnt++]=u16(Cnt+2); Indices[ICnt++]=u16(Cnt+1); Cnt+=4; } } R_CHK(QuadIB->Unlock()); }
void CEngineAPI::Initialize(void) { ////////////////////////////////////////////////////////////////////////// // render #if defined(R1_EXCLUDE) LPCSTR r1_name = "xrRender_R2.dll"; #else LPCSTR r1_name = "xrRender_R1.dll"; #endif LPCSTR r2_name = "xrRender_R2.dll"; #ifndef DEDICATED_SERVER if (psDeviceFlags.test(rsR2) ) { // try to initialize R2 Log ("Loading DLL:", r2_name); hRender = LoadLibrary (r2_name); if (0==hRender) { // try to load R1 Msg ("...Failed - incompatible hardware."); } } #endif if (0==hRender) { // try to load R1 psDeviceFlags.set (rsR2,FALSE); renderer_value = 0; //con cmd Log ("Loading DLL:", r1_name); hRender = LoadLibrary (r1_name); if (0==hRender) R_CHK (GetLastError()); R_ASSERT (hRender); } // game { LPCSTR g_name = "xrGame.dll"; Log ("Loading DLL:",g_name); hGame = LoadLibrary (g_name); if (0==hGame) R_CHK (GetLastError()); R_ASSERT2 (hGame,"Game DLL raised exception during loading or there is no game DLL at all"); pCreate = (Factory_Create*) GetProcAddress(hGame,"xrFactory_Create" ); R_ASSERT(pCreate); pDestroy = (Factory_Destroy*) GetProcAddress(hGame,"xrFactory_Destroy" ); R_ASSERT(pDestroy); } ////////////////////////////////////////////////////////////////////////// // vTune tune_enabled = FALSE; if (strstr(Core.Params,"-tune")) { LPCSTR g_name = "vTuneAPI.dll"; Log ("Loading DLL:",g_name); hTuner = LoadLibrary (g_name); if (0==hTuner) R_CHK (GetLastError()); R_ASSERT2 (hTuner,"Intel vTune is not installed"); tune_enabled = TRUE; tune_pause = (VTPause*) GetProcAddress(hTuner,"VTPause" ); R_ASSERT(tune_pause); tune_resume = (VTResume*) GetProcAddress(hTuner,"VTResume" ); R_ASSERT(tune_resume); } }
void CSoundRender_TargetD::stop () { if (rendering){ R_CHK (pBuffer->Stop()); R_CHK (pControl->SetMode(DS3DMODE_HEADRELATIVE,DS3D_DEFERRED)); // R_CHK (pControl->SetMode(DS3DMODE_DISABLE,DS3D_DEFERRED)); } inherited::stop (); }
void CHW::Reset (HWND hwnd) { #ifdef DEBUG _RELEASE (dwDebugSB); #endif _RELEASE (pBaseZB); _RELEASE (pBaseRT); #ifndef _EDITOR //#ifndef DEDICATED_SERVER // BOOL bWindowed = !psDeviceFlags.is (rsFullscreen); //#else // BOOL bWindowed = TRUE; //#endif BOOL bWindowed = TRUE; if (!g_dedicated_server) bWindowed = !psDeviceFlags.is (rsFullscreen); selectResolution (DevPP.BackBufferWidth, DevPP.BackBufferHeight, bWindowed); // Windoze DevPP.SwapEffect = bWindowed?D3DSWAPEFFECT_COPY:D3DSWAPEFFECT_DISCARD; DevPP.Windowed = bWindowed; //AVO: fucntional vsync by avbaula #ifdef VSYNC_FIX DevPP.PresentationInterval = selectPresentInterval(); // Vsync if(!bWindowed) // Refresh rate DevPP.FullScreen_RefreshRateInHz = selectRefresh(DevPP.BackBufferWidth,DevPP.BackBufferHeight,Caps.fTarget); else DevPP.FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT; #else //!VSYNC_FIX DevPP.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE; if( !bWindowed ) DevPP.FullScreen_RefreshRateInHz = selectRefresh (DevPP.BackBufferWidth,DevPP.BackBufferHeight,Caps.fTarget); else DevPP.FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT; #endif //-VSYNC_FIX //-AVO #endif //-_EDITOR while (TRUE) { HRESULT _hr = HW.pDevice->Reset (&DevPP); if (SUCCEEDED(_hr)) break; Msg ("! ERROR: [%dx%d]: %s",DevPP.BackBufferWidth,DevPP.BackBufferHeight,Debug.error2string(_hr)); Sleep (100); } R_CHK (pDevice->GetRenderTarget (0,&pBaseRT)); R_CHK (pDevice->GetDepthStencilSurface (&pBaseZB)); #ifdef DEBUG R_CHK (pDevice->CreateStateBlock (D3DSBT_ALL,&dwDebugSB)); #endif #ifndef _EDITOR updateWindowProps (hwnd); #endif }
void CRender::reset_end() { R_CHK (HW.pDevice->CreateQuery(D3DQUERYTYPE_EVENT,&q_sync_point[0])); R_CHK (HW.pDevice->CreateQuery(D3DQUERYTYPE_EVENT,&q_sync_point[1])); HWOCC.occq_create (occq_size); Target = xr_new<CRenderTarget> (); xrRender_apply_tf (); }
ID3DTexture2D* TW_LoadTextureFromTexture ( ID3DTexture2D* t_from, D3DFORMAT& t_dest_fmt, int levels_2_skip, u32& w, u32& h ) { // Calculate levels & dimensions ID3DTexture2D* t_dest = NULL; D3DSURFACE_DESC t_from_desc0 ; R_CHK (t_from->GetLevelDesc (0,&t_from_desc0)); int levels_exist = t_from->GetLevelCount(); int top_width = t_from_desc0.Width; int top_height = t_from_desc0.Height; Reduce (top_width,top_height,levels_exist,levels_2_skip); // Create HW-surface if (D3DX_DEFAULT==t_dest_fmt) t_dest_fmt = t_from_desc0.Format; R_CHK (D3DXCreateTexture( HW.pDevice, top_width,top_height, levels_exist,0,t_dest_fmt, D3DPOOL_MANAGED,&t_dest )); // Copy surfaces & destroy temporary ID3DTexture2D* T_src= t_from; ID3DTexture2D* T_dst= t_dest; int L_src = T_src->GetLevelCount ()-1; int L_dst = T_dst->GetLevelCount ()-1; for (; L_dst>=0; L_src--,L_dst--) { // Get surfaces IDirect3DSurface9 *S_src, *S_dst; R_CHK (T_src->GetSurfaceLevel (L_src,&S_src)); R_CHK (T_dst->GetSurfaceLevel (L_dst,&S_dst)); // Copy R_CHK (D3DXLoadSurfaceFromSurface(S_dst,NULL,NULL,S_src,NULL,NULL,D3DX_FILTER_NONE,0)); // Release surfaces _RELEASE (S_src); _RELEASE (S_dst); } // OK w = top_width; h = top_height; return t_dest; }
void CEngineAPI::Initialize(void) { ////////////////////////////////////////////////////////////////////////// // render LPCSTR r1_name = "xrRender_R1.dll"; #ifndef DEDICATED_SERVER InitializeNotDedicated(); #endif // DEDICATED_SERVER if (0==hRender) { // try to load R1 psDeviceFlags.set (rsR4,FALSE); psDeviceFlags.set (rsR3,FALSE); psDeviceFlags.set (rsR2,FALSE); renderer_value = 0; //con cmd Log ("Loading DLL:", r1_name); hRender = LoadLibrary (r1_name); if (0==hRender) R_CHK (GetLastError()); R_ASSERT (hRender); g_current_renderer = 1; } Device.ConnectToRender(); // game { LPCSTR g_name = "xrGame.dll"; Log ("Loading DLL:",g_name); hGame = LoadLibrary (g_name); if (0==hGame) R_CHK (GetLastError()); R_ASSERT2 (hGame,"Game DLL raised exception during loading or there is no game DLL at all"); pCreate = (Factory_Create*) GetProcAddress(hGame,"xrFactory_Create" ); R_ASSERT(pCreate); pDestroy = (Factory_Destroy*) GetProcAddress(hGame,"xrFactory_Destroy" ); R_ASSERT(pDestroy); } ////////////////////////////////////////////////////////////////////////// // vTune tune_enabled = FALSE; if (strstr(Core.Params,"-tune")) { LPCSTR g_name = "vTuneAPI.dll"; Log ("Loading DLL:",g_name); hTuner = LoadLibrary (g_name); if (0==hTuner) R_CHK (GetLastError()); R_ASSERT2 (hTuner,"Intel vTune is not installed"); tune_enabled = TRUE; tune_pause = (VTPause*) GetProcAddress(hTuner,"VTPause" ); R_ASSERT(tune_pause); tune_resume = (VTResume*) GetProcAddress(hTuner,"VTResume" ); R_ASSERT(tune_resume); } }
void TW_Save (ID3DTexture2D* T, LPCSTR name, LPCSTR prefix, LPCSTR postfix) { string256 fn; strconcat (sizeof(fn),fn,name,"_",prefix,"-",postfix); for (int it=0; it<int(xr_strlen(fn)); it++) if ('\\'==fn[it]) fn[it] = '_'; string256 fn2; strconcat (sizeof(fn2),fn2,"debug\\",fn,".dds"); Log ("* debug texture save: ",fn2); #ifdef USE_DX11 R_CHK (D3DX11SaveTextureToFile(HW.pContext, T, D3DX11_IFF_DDS, fn2)); #else R_CHK (D3DX10SaveTextureToFile(T, D3DX10_IFF_DDS, fn2)); #endif }
void CSoundRender_TargetD::render () { fill_block (); fill_block (); R_CHK (pBuffer->SetCurrentPosition (0)); HRESULT _hr = pBuffer->Play(0,0,DSBPLAY_LOOPING); if (DSERR_BUFFERLOST==_hr) { R_CHK(pBuffer->Restore()); R_CHK(pBuffer->Play(0,0,DSBPLAY_LOOPING)); }else{ R_CHK (_hr); } inherited::render(); }
//----------------------------------------------------------------------------- // Name: CreateInputDevice() // Desc: Create a DirectInput device. //----------------------------------------------------------------------------- HRESULT CInput::CreateInputDevice( LPDIRECTINPUTDEVICE8* device, GUID guidDevice, const DIDATAFORMAT* pdidDataFormat, u32 dwFlags, u32 buf_size ) { // Obtain an interface to the input device //. CHK_DX( pDI->CreateDeviceEx( guidDevice, IID_IDirectInputDevice8, (void**)device, NULL ) ); CHK_DX( pDI->CreateDevice( guidDevice, /*IID_IDirectInputDevice8,*/ device, NULL ) ); // Set the device data format. Note: a data format specifies which // controls on a device we are interested in, and how they should be // reported. CHK_DX((*device)->SetDataFormat( pdidDataFormat ) ); // Set the cooperativity level to let DirectInput know how this device // should interact with the system and with other DirectInput applications. HRESULT _hr = (*device)->SetCooperativeLevel( Device.m_hWnd, dwFlags ); if (FAILED(_hr) && (_hr==E_NOTIMPL)) Msg("! INPUT: Can't set coop level. Emulation???"); else R_CHK(_hr); // setup the buffer size for the keyboard data DIPROPDWORD dipdw; dipdw.diph.dwSize = sizeof(DIPROPDWORD); dipdw.diph.dwHeaderSize = sizeof(DIPROPHEADER); dipdw.diph.dwObj = 0; dipdw.diph.dwHow = DIPH_DEVICE; dipdw.dwData = buf_size; CHK_DX( (*device)->SetProperty( DIPROP_BUFFERSIZE, &dipdw.diph ) ); return S_OK; }
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { xrDebug::Initialize(false); Core._initialize ("xrai",0); buffer_vector_test (); HMODULE hFactory; LPCSTR g_name = "xrSE_Factory.dll"; Log ("Loading DLL:",g_name); hFactory = LoadLibrary (g_name); if (0==hFactory) R_CHK (GetLastError()); R_ASSERT2 (hFactory,"Factory DLL raised exception during loading or there is no factory DLL at all"); create_entity = (Factory_Create*) GetProcAddress(hFactory,"_create_entity@4"); R_ASSERT(create_entity); destroy_entity = (Factory_Destroy*) GetProcAddress(hFactory,"_destroy_entity@4"); R_ASSERT(destroy_entity); Startup (lpCmdLine); FreeLibrary (hFactory); Core._destroy (); return (0); }
void dump_URL (LPCSTR p, IDirectPlay8Address* A) { string256 aaaa; DWORD aaaa_s = sizeof(aaaa); R_CHK (A->GetURLA(aaaa,&aaaa_s)); Log (p,aaaa); }
void CTexture::desc_update () { desc_cache = pSurface; if (pSurface && (D3DRTYPE_TEXTURE == pSurface->GetType())) { ID3DTexture2D* T = (ID3DTexture2D*)pSurface; R_CHK (T->GetLevelDesc(0,&desc)); } }
void r_pixel_calculator::begin () { rt.create ("$user$test", rt_dimensions,rt_dimensions,HW.Caps.fTarget); R_CHK (HW.pDevice->CreateDepthStencilSurface (rt_dimensions,rt_dimensions,HW.Caps.fDepth,D3DMULTISAMPLE_NONE,0,TRUE,&zb,NULL)); RCache.set_RT (rt->pRT); RCache.set_ZB (zb); R_ASSERT (Device.Begin()); }
void CTexture::apply_avi (u32 dwStage) { if (pAVI->NeedUpdate()){ R_ASSERT(D3DRTYPE_TEXTURE == pSurface->GetType()); ID3DTexture2D* T2D = (ID3DTexture2D*)pSurface; // AVI D3DLOCKED_RECT R; R_CHK (T2D->LockRect(0,&R,NULL,0)); R_ASSERT(R.Pitch == int(pAVI->m_dwWidth*4)); // R_ASSERT(pAVI->DecompressFrame((u32*)(R.pBits))); BYTE* ptr; pAVI->GetFrame(&ptr); CopyMemory(R.pBits,ptr,pAVI->m_dwWidth*pAVI->m_dwHeight*4); // R_ASSERT(pAVI->GetFrame((BYTE*)(&R.pBits))); R_CHK (T2D->UnlockRect(0)); } CHK_DX(HW.pDevice->SetTexture(dwStage,pSurface)); };
void CGameSpy_Full::LoadGameSpy() { LPCSTR g_name = "xrGameSpy.dll"; Log ("Loading DLL:",g_name); m_hGameSpyDLL = LoadLibrary (g_name); if (0==m_hGameSpyDLL) R_CHK (GetLastError()); R_ASSERT2 (m_hGameSpyDLL,"GameSpy DLL raised exception during loading or there is no game DLL at all"); HMODULE hGameSpyDLL = m_hGameSpyDLL; GAMESPY_LOAD_FN(xrGS_GetGameVersion); }
void TW_Save (ID3DTexture2D* T, LPCSTR name, LPCSTR prefix, LPCSTR postfix) { string256 fn; strconcat (sizeof(fn),fn,name,"_",prefix,"-",postfix); for (int it=0; it<int(xr_strlen(fn)); it++) if ('\\'==fn[it]) fn[it] = '_'; string256 fn2; strconcat (sizeof(fn2),fn2,"debug\\",fn,".dds"); Log ("* debug texture save: ",fn2); R_CHK (D3DXSaveTextureToFile (fn2,D3DXIFF_DDS,T,0)); }
void CRTC::create (LPCSTR Name, u32 size, D3DFORMAT f) { R_ASSERT (HW.pDevice && Name && Name[0] && size && btwIsPow2(size)); _order = CPU::GetCLK(); //Device.GetTimerGlobal()->GetElapsed_clk(); HRESULT _hr; dwSize = size; fmt = f; // Get caps D3DCAPS9 caps; R_CHK (HW.pDevice->GetDeviceCaps(&caps)); // Check width-and-height of render target surface if (size>caps.MaxTextureWidth) return; if (size>caps.MaxTextureHeight) return; // Validate render-target usage _hr = HW.pD3D->CheckDeviceFormat( HW.DevAdapter, HW.DevT, HW.Caps.fTarget, D3DUSAGE_RENDERTARGET, D3DRTYPE_CUBETEXTURE, f ); if (FAILED(_hr)) return; // Try to create texture/surface Device.Resources->Evict (); _hr = HW.pDevice->CreateCubeTexture (size, 1, D3DUSAGE_RENDERTARGET, f, D3DPOOL_DEFAULT, &pSurface,NULL); if (FAILED(_hr) || (0==pSurface)) return; // OK Msg ("* created RTc(%s), 6(%d)",Name,size); for (u32 face=0; face<6; face++) R_CHK (pSurface->GetCubeMapSurface ((D3DCUBEMAP_FACES)face, 0, pRT+face)); pTexture = Device.Resources->_CreateTexture (Name); pTexture->surface_set (pSurface); }
CGameSpy_GCD_Server::CGameSpy_GCD_Server() { m_hGameSpyDLL = NULL; LPCSTR g_name = "xrGameSpy.dll"; Log ("Loading DLL:",g_name); m_hGameSpyDLL = LoadLibrary (g_name); if (0==m_hGameSpyDLL) R_CHK (GetLastError()); R_ASSERT2 (m_hGameSpyDLL,"GameSpy DLL raised exception during loading or there is no game DLL at all"); LoadGameSpy(m_hGameSpyDLL); };
void CSoundRender_TargetD::fill_block () { #pragma todo("check why pEmitter is NULL") if (0==pEmitter) return; // Obtain memory address of write block. This will be in two parts if the block wraps around. LPVOID ptr1, ptr2; u32 bytes1,bytes2; R_CHK (pBuffer->Lock(pos_write%buf_size, buf_block, &ptr1, LPDWORD(&bytes1), &ptr2, LPDWORD(&bytes2), 0)); R_ASSERT (0==ptr2 && 0==bytes2); // Copy data (and clear the end) pEmitter->fill_block(ptr1,buf_block); pos_write += buf_block; // wrap around for the sake of sanity // ??? is it possible to do this at every iteration ??? if (pos_write > (2ul<<24ul)) pos_write %= buf_size; R_CHK (pBuffer->Unlock(ptr1, bytes1, ptr2, bytes2)); }
void CSoundRender_TargetD::update () { inherited::update(); // Analyze if we really need more data to stream them ahead u32 cursor_write; R_CHK (pBuffer->GetCurrentPosition(0,LPDWORD(&cursor_write))); u32 r_write = calc_interval(pos_write); u32 r_cursor = (calc_interval(cursor_write)+1)%sdef_target_count; if (r_write==r_cursor) fill_block (); // Msg ("write: 0x%8x",cursor_write); }
void CSoundRender_TargetD::fill_parameters() { inherited::fill_parameters(); // 1. Set 3D params (including mode) { Fvector& p_pos = pEmitter->p_source.position; R_CHK(pControl->SetMode (pEmitter->b2D ? DS3DMODE_HEADRELATIVE : DS3DMODE_NORMAL,DS3D_DEFERRED)); R_CHK(pControl->SetMinDistance (pEmitter->p_source.min_distance, DS3D_DEFERRED)); R_CHK(pControl->SetMaxDistance (pEmitter->p_source.max_distance, DS3D_DEFERRED)); R_CHK(pControl->SetPosition (p_pos.x,p_pos.y,p_pos.z, DS3D_DEFERRED)); } // 2. Set 2D params (volume, freq) + position(rewind) { float _volume = pEmitter->smooth_volume; clamp (_volume,EPS_S,1.f); s32 hw_volume = iFloor (7000.f*logf(_volume)/5.f); clamp (hw_volume,DSBVOLUME_MIN,DSBVOLUME_MAX); if (_abs(hw_volume-cache_hw_volume)>50){ cache_hw_volume = hw_volume; R_CHK(pBuffer->SetVolume(hw_volume)); } float _freq = pEmitter->p_source.freq; s32 hw_freq = iFloor (_freq * float(wfx.nSamplesPerSec) + EPS); if (_abs(hw_freq-cache_hw_freq)>50) { cache_hw_freq = hw_freq; s32 hw_freq_set = hw_freq; clamp (hw_freq_set,s32(SoundRenderD->dsCaps.dwMinSecondarySampleRate),s32(SoundRenderD->dsCaps.dwMaxSecondarySampleRate)); R_CHK (pBuffer->SetFrequency ( hw_freq_set )); } } }
void SPrimitiveBuffer::CreateFromData(D3DPRIMITIVETYPE _pt, u32 _p_cnt, u32 FVF, LPVOID vertices, u32 _v_cnt, u16* indices, u32 _i_cnt) { #ifdef USE_DX10 // TODO: DX10: Implement SPrimitiveBuffer::CreateFromData for DX10 // VERIFY(!"SPrimitiveBuffer::CreateFromData not implemented for dx10"); #else // USE_DX10 ID3DVertexBuffer* pVB=0; ID3DIndexBuffer* pIB=0; p_cnt = _p_cnt; p_type = _pt; v_cnt = _v_cnt; i_cnt = _i_cnt; u32 stride = D3DXGetFVFVertexSize(FVF); R_CHK(HW.pDevice->CreateVertexBuffer(v_cnt*stride, D3DUSAGE_WRITEONLY, 0, D3DPOOL_MANAGED, &pVB, 0)); u8* bytes; R_CHK (pVB->Lock(0,0,(LPVOID*)&bytes,0)); FLvertexVec verts (v_cnt); for (u32 k=0; k<v_cnt; ++k) verts[k].set (((Fvector*)vertices)[k],0xFFFFFFFF); Memory.mem_copy (bytes,&*verts.begin(),v_cnt*stride); R_CHK (pVB->Unlock()); if (i_cnt){ R_CHK(HW.pDevice->CreateIndexBuffer(i_cnt*sizeof(u16),D3DUSAGE_WRITEONLY,D3DFMT_INDEX16,D3DPOOL_MANAGED,&pIB,NULL)); R_CHK (pIB->Lock(0,0,(LPVOID*)&bytes,0)); Memory.mem_copy (bytes,indices,i_cnt*sizeof(u16)); R_CHK (pIB->Unlock()); OnRender.bind (this,&SPrimitiveBuffer::RenderDIP); }else{ OnRender.bind (this,&SPrimitiveBuffer::RenderDP); } pGeom.create (FVF,pVB,pIB); #endif // USE_DX10 }
void CRenderTarget::accum_spot_geom_create () { // u32 dwUsage = D3DUSAGE_WRITEONLY; // vertices { u32 vCount = DU_CONE_NUMVERTEX; u32 vSize = 3*4; //R_CHK (HW.pDevice->CreateVertexBuffer( // vCount*vSize, // dwUsage, // 0, // D3DPOOL_MANAGED, // &g_accum_spot_vb, // 0)); //BYTE* pData = 0; //R_CHK (g_accum_spot_vb->Lock(0,0,(void**)&pData,0)); //CopyMemory (pData,du_cone_vertices,vCount*vSize); //g_accum_spot_vb->Unlock (); R_CHK(dx10BufferUtils::CreateVertexBuffer ( &g_accum_spot_vb, du_cone_vertices,vCount*vSize)); HW.stats_manager.increment_stats_vb ( g_accum_spot_vb ); } // Indices { u32 iCount = DU_CONE_NUMFACES*3; //BYTE* pData = 0; //R_CHK (HW.pDevice->CreateIndexBuffer(iCount*2,dwUsage,D3DFMT_INDEX16,D3DPOOL_MANAGED,&g_accum_spot_ib,0)); //R_CHK (g_accum_spot_ib->Lock(0,0,(void**)&pData,0)); //CopyMemory (pData,du_cone_faces,iCount*2); //g_accum_spot_ib->Unlock (); R_CHK( dx10BufferUtils::CreateIndexBuffer ( &g_accum_spot_ib, du_cone_faces, iCount*2 ) ); HW.stats_manager.increment_stats_ib ( g_accum_spot_ib ); } }
void CTexture::apply_theora (u32 dwStage) { if (pTheora->Update(m_play_time!=0xFFFFFFFF?m_play_time:Device.dwTimeContinual)){ R_ASSERT(D3DRTYPE_TEXTURE == pSurface->GetType()); ID3DTexture2D* T2D = (ID3DTexture2D*)pSurface; D3DLOCKED_RECT R; RECT rect; rect.left = 0; rect.top = 0; rect.right = pTheora->Width(true); rect.bottom = pTheora->Height(true); u32 _w = pTheora->Width(false); R_CHK (T2D->LockRect(0,&R,&rect,0)); R_ASSERT (R.Pitch == int(pTheora->Width(false)*4)); int _pos = 0; pTheora->DecompressFrame((u32*)R.pBits, _w - rect.right, _pos); VERIFY (u32(_pos) == rect.bottom*_w); R_CHK (T2D->UnlockRect(0)); } CHK_DX(HW.pDevice->SetTexture(dwStage,pSurface)); };
// Igor: is used to test bug with rain, particles corruption void CBackend::RestoreQuadIBData() { const u32 dwTriCount = 4*1024; u16 *Indices = 0; R_CHK(QuadIB->Lock(0,0,(void**)&Indices,0)); { int Cnt = 0; int ICnt= 0; for (int i=0; i<dwTriCount; i++) { Indices[ICnt++]=u16(Cnt+0); Indices[ICnt++]=u16(Cnt+1); Indices[ICnt++]=u16(Cnt+2); Indices[ICnt++]=u16(Cnt+3); Indices[ICnt++]=u16(Cnt+2); Indices[ICnt++]=u16(Cnt+1); Cnt+=4; } } R_CHK(QuadIB->Unlock()); }
CGameSpy_HTTP::CGameSpy_HTTP() { m_hGameSpyDLL = NULL; m_LastRequest = -1; LPCSTR g_name = "xrGameSpy.dll"; Log ("Loading DLL:",g_name); m_hGameSpyDLL = LoadLibrary (g_name); if (0==m_hGameSpyDLL) R_CHK (GetLastError()); R_ASSERT2 (m_hGameSpyDLL,"GameSpy DLL raised exception during loading or there is no game DLL at all"); LoadGameSpy(m_hGameSpyDLL); StartUp(); };
void CBackend::CreateQuadIB () { static const u32 dwTriCount = 4*1024; static const u32 dwIdxCount = dwTriCount*2*3; u16 IndexBuffer[dwIdxCount]; u16 *Indices = IndexBuffer; //u32 dwUsage = D3DUSAGE_WRITEONLY; //if (HW.Caps.geometry.bSoftware) dwUsage|=D3DUSAGE_SOFTWAREPROCESSING; //R_CHK(HW.pDevice->CreateIndexBuffer(dwIdxCount*2,dwUsage,D3DFMT_INDEX16,D3DPOOL_MANAGED,&QuadIB,NULL)); D3D_BUFFER_DESC desc; desc.ByteWidth = dwIdxCount*2; //desc.Usage = D3D_USAGE_IMMUTABLE; desc.Usage = D3D_USAGE_DEFAULT; desc.BindFlags = D3D_BIND_INDEX_BUFFER; desc.CPUAccessFlags = 0; desc.MiscFlags = 0; D3D_SUBRESOURCE_DATA subData; subData.pSysMem = IndexBuffer; //R_CHK(QuadIB->Lock(0,0,(void**)&Indices,0)); { int Cnt = 0; int ICnt= 0; for (int i=0; i<dwTriCount; i++) { Indices[ICnt++]=u16(Cnt+0); Indices[ICnt++]=u16(Cnt+1); Indices[ICnt++]=u16(Cnt+2); Indices[ICnt++]=u16(Cnt+3); Indices[ICnt++]=u16(Cnt+2); Indices[ICnt++]=u16(Cnt+1); Cnt+=4; } } //R_CHK(QuadIB->Unlock()); //R_CHK(HW.pDevice->CreateIndexBuffer(dwIdxCount*2,dwUsage,D3DFMT_INDEX16,D3DPOOL_MANAGED,&QuadIB,NULL)); R_CHK(HW.pDevice->CreateBuffer ( &desc, &subData, &QuadIB)); HW.stats_manager.increment_stats_ib ( QuadIB); }
BOOL CSoundRender_TargetD::_initialize () { inherited::_initialize(); // Calc storage buf_size = sdef_target_size*wfx.nAvgBytesPerSec/1000; buf_block = sdef_target_block*wfx.nAvgBytesPerSec/1000; // Fill caps structure DSBUFFERDESC dsBD = {0}; dsBD.dwSize = sizeof(dsBD); dsBD.dwFlags = DSBCAPS_CTRL3D | DSBCAPS_CTRLFREQUENCY | DSBCAPS_CTRLVOLUME | DSBCAPS_GETCURRENTPOSITION2 | (psSoundFlags.test(ss_Hardware) ? 0 : (DSBCAPS_LOCSOFTWARE)); dsBD.dwBufferBytes = buf_size; dsBD.dwReserved = 0; dsBD.lpwfxFormat = &wfx; switch (psSoundModel) { case sq_DEFAULT: dsBD.guid3DAlgorithm = DS3DALG_DEFAULT; break; case sq_NOVIRT: dsBD.guid3DAlgorithm = DS3DALG_NO_VIRTUALIZATION; break; case sq_LIGHT: dsBD.guid3DAlgorithm = DS3DALG_HRTF_LIGHT; break; case sq_HIGH: dsBD.guid3DAlgorithm = DS3DALG_HRTF_FULL; break; default: FATAL("Unknown 3D-ref_sound algorithm"); break; } if (psSoundFlags.test(ss_Hardware)) dsBD.guid3DAlgorithm = DS3DALG_HRTF_FULL; // Create bDX7 = FALSE; R_CHK (SoundRenderD->pDevice->CreateSoundBuffer(&dsBD, &pBuffer_base, NULL)); R_CHK (pBuffer_base->QueryInterface(IID_IDirectSoundBuffer8,(void **)&pBuffer)); R_CHK (pBuffer->QueryInterface(IID_IDirectSound3DBuffer8, (void **)&pControl)); R_ASSERT(pBuffer_base && pBuffer && pControl); R_CHK (pControl->SetConeAngles (DS3D_DEFAULTCONEANGLE,DS3D_DEFAULTCONEANGLE,DS3D_DEFERRED)); R_CHK (pControl->SetConeOrientation (0,0,1,DS3D_DEFERRED)); R_CHK (pControl->SetConeOutsideVolume (0,DS3D_DEFERRED)); R_CHK (pControl->SetVelocity (0,0,0,DS3D_DEFERRED)); return TRUE; }