// startup void CRenderTarget::phase_scene_prepare () { // Clear depth & stencil //u_setrt ( Device.dwWidth,Device.dwHeight,HW.pBaseRT,NULL,NULL,HW.pBaseZB ); //CHK_DX ( HW.pDevice->Clear ( 0L, NULL, D3DCLEAR_ZBUFFER|D3DCLEAR_STENCIL, 0x0, 1.0f, 0L) ); // Igor: soft particles CEnvDescriptor& E = *g_pGamePersistent->Environment().CurrentEnv; float fValue = E.m_fSunShaftsIntensity; // TODO: add multiplication by sun color here //if (fValue<0.0001) FlagSunShafts = 0; if ( RImplementation.o.advancedpp && ( ps_r2_ls_flags.test(R2FLAG_SOFT_PARTICLES|R2FLAG_DOF) || ( (ps_r_sun_shafts>0) && (fValue>=0.0001) ) || (ps_r_ssao>0) ) ) { u_setrt ( Device.dwWidth,Device.dwHeight,rt_Position->pRT,NULL,NULL,HW.pBaseZB ); CHK_DX ( HW.pDevice->Clear ( 0L, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER|D3DCLEAR_STENCIL, 0x0, 1.0f, 0L) ); } else { u_setrt ( Device.dwWidth,Device.dwHeight,HW.pBaseRT,NULL,NULL,HW.pBaseZB ); CHK_DX ( HW.pDevice->Clear ( 0L, NULL, D3DCLEAR_ZBUFFER|D3DCLEAR_STENCIL, 0x0, 1.0f, 0L) ); } // Igor: for volumetric lights m_bHasActiveVolumetric = false; // Clear later if try to draw volumetric }
//----------------------------------------------------------------------------- // 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; }
BOOL CEditorRenderDevice::Begin () { VERIFY(b_is_Ready); HW.Validate (); HRESULT _hr = HW.pDevice->TestCooperativeLevel(); if (FAILED(_hr)) { // If the device was lost, do not render until we get it back if (D3DERR_DEVICELOST==_hr) { Sleep (33); return FALSE; } // Check if the device is ready to be reset if (D3DERR_DEVICENOTRESET==_hr) { Reset (); } } VERIFY (FALSE==g_bRendering); CHK_DX (HW.pDevice->BeginScene()); CHK_DX(HW.pDevice->Clear(0,0, D3DCLEAR_ZBUFFER|D3DCLEAR_TARGET| (HW.Caps.bStencil?D3DCLEAR_STENCIL:0), EPrefs->scene_clear_color,1,0 )); RCache.OnFrameBegin (); g_bRendering = TRUE; return TRUE; }
//-------------------------------------------------------------------------------------------------- BOOL CSoundStream::Decompress(unsigned char *dest) { u32 dwSrcSize = dwSrcBufSize; BOOL r = true; VERIFY (hAcmStream); // check for EOF if (dwDecPos+dwSrcSize>dwTotalSize) { dwSrcSize=dwTotalSize-dwDecPos; r=false; } hf->r (WaveSource,dwSrcSize); stream.cbStruct=sizeof(stream); stream.fdwStatus=0; stream.pbSrc=WaveSource; stream.cbSrcLength=dwSrcSize; stream.pbDst=dest; stream.cbDstLength=dwDestBufSize; CHK_DX(acmStreamPrepareHeader(hAcmStream,&stream,0)); CHK_DX(acmStreamConvert(hAcmStream,&stream,0)); CHK_DX(acmStreamUnprepareHeader(hAcmStream,&stream,0)); dwDecPos+=stream.cbSrcLengthUsed; AppWriteDataToBuffer(writepos,WaveDest,stream.cbDstLengthUsed); return r; }
void CSoundStream::Play ( BOOL loop, int cnt ) { VERIFY(Sound); if (isPause) { Pause(); return; } if (dwStatus & DSBSTATUS_PLAYING) return; dwDecPos = 0; isPresentData = true; //---------------- if (hAcmStream){ CHK_DX(acmStreamClose(hAcmStream,0)); } CHK_DX(acmStreamOpen(&hAcmStream,0,psrc,pwfx,0,NULL,0,0)); CHK_DX(acmStreamSize(hAcmStream,dwDestBufSize,LPDWORD(&dwSrcBufSize),ACM_STREAMSIZEF_DESTINATION)); // alloc source data buffer VERIFY(dwSrcBufSize); xr_free(WaveSource); WaveSource = (unsigned char *)xr_malloc(dwSrcBufSize); // seek to data start hf->seek (DataPos); writepos = 0; Decompress (WaveDest); writepos =stream.cbDstLengthUsed; //------- iLoopCountRested= cnt; bMustLoop = loop; bMustPlay = true; }
void CBackend::dbg_Draw (D3DPRIMITIVETYPE T, FVF::L* pVerts, int pcnt) { #if defined(USE_DX10) || defined(USE_DX11) // TODO: DX10: implement //VERIFY(!"CBackend::dbg_Draw not implemented."); #else // USE_DX10 OnFrameEnd (); CHK_DX(HW.pDevice->SetFVF (FVF::F_L)); CHK_DX(HW.pDevice->DrawPrimitiveUP(T, pcnt, pVerts, sizeof(FVF::L) )); #endif // USE_DX10 }
void R_occlusion::occq_end (u32& ID ) { if (!enabled) return; // Msg ("end : [%2d] - %d", used[ID].order, ID); CHK_DX (used[ID].Q->Issue (D3DISSUE_END)); }
SGeometry* CResourceManager::CreateGeom (u32 FVF, IDirect3DVertexBuffer9* vb, IDirect3DIndexBuffer9* ib) { D3DVERTEXELEMENT9 dcl [MAX_FVF_DECL_SIZE]; CHK_DX (D3DXDeclaratorFromFVF(FVF,dcl)); SGeometry* g = CreateGeom (dcl,vb,ib); return g; }
void CRenderTarget::phase_smap_direct_tsh (light* L, u32 sub_phase) { VERIFY (RImplementation.o.Tshadows); u32 _clr = 0xffffffff; //color_rgba(127,127,12,12); RCache.set_ColorWriteEnable (); CHK_DX (HW.pDevice->Clear( 0L, NULL, D3DCLEAR_TARGET, _clr, 1.0f, 0L)); }
CInput::CInput ( BOOL bExclusive, int deviceForInit) { g_exclusive = !!bExclusive; Log("Starting INPUT device..."); pDI = NULL; pMouse = NULL; pKeyboard = NULL; //=====================Mouse mouse_property.mouse_dt = 25; ZeroMemory ( mouseState, sizeof(mouseState) ); ZeroMemory ( KBState, sizeof(KBState) ); ZeroMemory ( timeStamp, sizeof(timeStamp) ); ZeroMemory ( timeSave, sizeof(timeStamp) ); ZeroMemory ( offs, sizeof(offs) ); //===================== Dummy pack iCapture (&dummyController); if (!pDI) CHK_DX(DirectInput8Create( GetModuleHandle(NULL), DIRECTINPUT_VERSION, IID_IDirectInput8, (void**)&pDI, NULL )); // KEYBOARD if (deviceForInit & keyboard_device_key) CHK_DX(CreateInputDevice( &pKeyboard, GUID_SysKeyboard, &c_dfDIKeyboard, ((bExclusive)?DISCL_EXCLUSIVE:DISCL_NONEXCLUSIVE) | DISCL_FOREGROUND, KEYBOARDBUFFERSIZE )); // MOUSE if (deviceForInit & mouse_device_key) CHK_DX(CreateInputDevice( &pMouse, GUID_SysMouse, &c_dfDIMouse2, ((bExclusive)?DISCL_EXCLUSIVE:DISCL_NONEXCLUSIVE) | DISCL_FOREGROUND | DISCL_NOWINKEY, MOUSEBUFFERSIZE )); Debug.set_on_dialog (&on_error_dialog); #ifdef ENGINE_BUILD Device.seqAppActivate.Add (this); Device.seqAppDeactivate.Add (this); Device.seqFrame.Add (this, REG_PRIORITY_HIGH); #endif }
void CUIStaticItem::Render() { VERIFY(g_bRendering); // установить обязательно перед вызовом CustomItem::Render() !!! VERIFY(hShader); RCache.set_Shader (hShader); if(alpha_ref!=-1) CHK_DX(HW.pDevice->SetRenderState(D3DRS_ALPHAREF,alpha_ref)); // convert&set pos Fvector2 bp; UI()->ClientToScreenScaled (bp,float(iPos.x),float(iPos.y)); bp.x = (float)iFloor(bp.x); bp.y = (float)iFloor(bp.y); // actual rendering u32 vOffset; Fvector2 pos; Fvector2 f_len; UI()->ClientToScreenScaled (f_len, iVisRect.x2, iVisRect.y2 ); int tile_x = fis_zero(iRemX)?iTileX:iTileX+1; int tile_y = fis_zero(iRemY)?iTileY:iTileY+1; int x,y; if (!(tile_x&&tile_y)) return; // render FVF::TL* start_pv = (FVF::TL*)RCache.Vertex.Lock (8*tile_x*tile_y,hGeom_fan.stride(),vOffset); FVF::TL* pv = start_pv; for (x=0; x<tile_x; ++x){ for (y=0; y<tile_y; ++y){ pos.set (bp.x+f_len.x*x,bp.y+f_len.y*y); inherited::Render (pv,pos,dwColor); } } std::ptrdiff_t p_cnt = (pv-start_pv)/3; VERIFY((pv-start_pv)<=8*tile_x*tile_y); RCache.Vertex.Unlock (u32(pv-start_pv),hGeom_fan.stride()); // set scissor Frect clip_rect = {iPos.x,iPos.y,iPos.x+iVisRect.x2*iTileX+iRemX,iPos.y+iVisRect.y2*iTileY+iRemY}; UI()->PushScissor (clip_rect); // set geom RCache.set_Geometry (hGeom_fan); if (p_cnt!=0)RCache.Render (D3DPT_TRIANGLELIST,vOffset,u32(p_cnt)); if(alpha_ref!=-1) CHK_DX(HW.pDevice->SetRenderState(D3DRS_ALPHAREF,0)); UI()->PopScissor (); }
// begin void CRenderTarget::phase_scene_begin () { // Enable ANISO for (u32 i=0; i<HW.Caps.raster.dwStages; i++) CHK_DX(HW.pDevice->SetSamplerState( i, D3DSAMP_MAXANISOTROPY, ps_r__tf_Anisotropic )); // Targets, use accumulator for temporary storage if (RImplementation.o.albedo_wo) u_setrt (rt_Position, rt_Normal, rt_Accumulator, HW.pBaseZB); else u_setrt (rt_Position, rt_Normal, rt_Color, HW.pBaseZB); // Stencil - write 0x1 at pixel pos RCache.set_Stencil ( TRUE,D3DCMP_ALWAYS,0x01,0xff,0xff,D3DSTENCILOP_KEEP,D3DSTENCILOP_REPLACE,D3DSTENCILOP_KEEP); // Misc - draw only front-faces CHK_DX(HW.pDevice->SetRenderState ( D3DRS_TWOSIDEDSTENCILMODE,FALSE )); RCache.set_CullMode ( CULL_CCW ); RCache.set_ColorWriteEnable ( ); }
void dxRenderDeviceRender::ClearTarget() { #ifdef USE_DX10 FLOAT ColorRGBA[4] = {0.0f,0.0f,0.0f,0.0f}; HW.pDevice->ClearRenderTargetView(RCache.get_RT(), ColorRGBA); #else // USE_DX10 CHK_DX(HW.pDevice->Clear(0,0,D3DCLEAR_TARGET,D3DCOLOR_XRGB(0,0,0),1,0)); #endif // USE_DX10 }
void dxEnvironmentRender::OnFrame(CEnvironment &env) { dxEnvDescriptorMixerRender &mixRen = *(dxEnvDescriptorMixerRender*)&*env.CurrentEnv->m_pDescriptorMixer; if (::Render->get_generation()==IRender_interface::GENERATION_R2){ //. very very ugly hack if (HW.Caps.raster_major >= 3 && HW.Caps.geometry.bVTF){ // tonemapping in VS mixRen.sky_r_textures.push_back (mk_pair(u32(D3DVERTEXTEXTURESAMPLER0),tonemap)); //. hack mixRen.sky_r_textures_env.push_back (mk_pair(u32(D3DVERTEXTEXTURESAMPLER0),tonemap)); //. hack mixRen.clouds_r_textures.push_back (mk_pair(u32(D3DVERTEXTEXTURESAMPLER0),tonemap)); //. hack } else { // tonemapping in PS mixRen.sky_r_textures.push_back (mk_pair(2,tonemap)); //. hack mixRen.sky_r_textures_env.push_back (mk_pair(2,tonemap)); //. hack mixRen.clouds_r_textures.push_back (mk_pair(2,tonemap)); //. hack } } //. Setup skybox textures, somewhat ugly ID3DBaseTexture* e0 = mixRen.sky_r_textures[0].second->surface_get(); ID3DBaseTexture* e1 = mixRen.sky_r_textures[1].second->surface_get(); tsky0->surface_set (e0); _RELEASE(e0); tsky1->surface_set (e1); _RELEASE(e1); // ******************** Environment params (setting) #ifdef USE_DX10 // TODO: DX10: Implement environment parameters setting for DX10 (if necessary) #else // USE_DX10 #if RENDER==R_R1 Fvector3 fog_color = env.CurrentEnv->fog_color; fog_color.mul(ps_r1_fog_luminance); #else // RENDER==R_R1 Fvector3 &fog_color = env.CurrentEnv->fog_color; #endif // RENDER==R_R1 CHK_DX(HW.pDevice->SetRenderState( D3DRS_FOGCOLOR, color_rgba_f(fog_color.x,fog_color.y,fog_color.z,0) )); CHK_DX(HW.pDevice->SetRenderState( D3DRS_FOGSTART, *(u32 *)(&env.CurrentEnv->fog_near) )); CHK_DX(HW.pDevice->SetRenderState( D3DRS_FOGEND, *(u32 *)(&env.CurrentEnv->fog_far) )); #endif // USE_DX10 }
void dxRenderDeviceRender::Begin() { #ifndef USE_DX10 CHK_DX (HW.pDevice->BeginScene()); #endif // USE_DX10 RCache.OnFrameBegin (); RCache.set_CullMode (CULL_CW); RCache.set_CullMode (CULL_CCW); if (HW.Caps.SceneMode) overdrawBegin (); }
void R_constants::flush_cache() { if (a_pixel.b_dirty) { // fp R_constant_array::t_f& F = a_pixel.c_f; { if (F.r_lo() <= 32) //. hack { u32 count = F.r_hi()-F.r_lo(); if (count) { count = (count>31)?31:count; PGO (Msg("PGO:P_CONST:%d",count)); CHK_DX (HW.pDevice->SetPixelShaderConstantF (F.r_lo(), (float*)F.access(F.r_lo()),count)); F.flush (); } } } a_pixel.b_dirty = false; } if (a_vertex.b_dirty) { // fp R_constant_array::t_f& F = a_vertex.c_f; { u32 count = F.r_hi()-F.r_lo(); if (count) { #ifdef DEBUG if (F.r_hi() > HW.Caps.geometry.dwRegisters) { Debug.fatal(DEBUG_INFO,"Internal error setting VS-constants: overflow\nregs[%d],hi[%d]", HW.Caps.geometry.dwRegisters,F.r_hi() ); } PGO (Msg("PGO:V_CONST:%d",count)); #endif & CHK_DX (HW.pDevice->SetVertexShaderConstantF (F.r_lo(), (float*)F.access(F.r_lo()),count)); F.flush (); } } a_vertex.b_dirty = false; } }
void apply () { if (0==HW.pDevice) return ; #if defined(USE_DX10) || defined(USE_DX11) // TODO: DX10: Implement mip bias control //VERIFY(!"apply not implmemented."); #else // USE_DX10 for (u32 i=0; i<HW.Caps.raster.dwStages; i++) CHK_DX(HW.pDevice->SetSamplerState( i, D3DSAMP_MIPMAPLODBIAS, *((LPDWORD) value))); #endif // USE_DX10 }
void dx10StateCache<ID3D10DepthStencilState, D3D10_DEPTH_STENCIL_DESC> ::CreateState( D3D10_DEPTH_STENCIL_DESC desc, ID3D10DepthStencilState** ppIState ) { CHK_DX(HW.pDevice->CreateDepthStencilState( &desc, ppIState)); // TODO: DX10: Remove this. #ifdef DEBUG Msg("ID3D10DepthStencilState #%d created.", m_StateArray.size()); #endif // DEBUG }
void dx10StateCache<ID3D10BlendState, D3D10_BLEND_DESC> ::CreateState( D3D10_BLEND_DESC desc, ID3D10BlendState** ppIState ) { CHK_DX(HW.pDevice->CreateBlendState( &desc, ppIState)); // TODO: DX10: Remove this. #ifdef DEBUG Msg("ID3D10BlendState #%d created.", m_StateArray.size()); #endif // DEBUG }
//--------------------------------------------------------------------------- void CEditorRenderDevice::End() { VERIFY(HW.pDevice); VERIFY(b_is_Ready); seqRender.Process (rp_Render); Statistic->Show(pSystemFont); EDevice.SetRS (D3DRS_FILLMODE,D3DFILL_SOLID); pSystemFont->OnRender(); EDevice.SetRS (D3DRS_FILLMODE,EDevice.dwFillMode); g_bRendering = FALSE; // end scene RCache.OnFrameEnd(); CHK_DX(HW.pDevice->EndScene()); CHK_DX(HW.pDevice->Present( NULL, NULL, NULL, NULL )); }
void apply () { if (0==HW.pDevice) return ; int val = *value; clamp(val,1,16); #if defined(USE_DX10) || defined(USE_DX11) SSManager.SetMaxAnisotropy(val); #else // USE_DX10 for (u32 i=0; i<HW.Caps.raster.dwStages; i++) CHK_DX(HW.pDevice->SetSamplerState( i, D3DSAMP_MAXANISOTROPY, val )); #endif // USE_DX10 }
void dx103DFluidRenderer::CreateJitterTexture() { BYTE data[256 * 256]; for (int i = 0; i < 256 * 256; i++) { data[i] = (unsigned char) (rand()/float(RAND_MAX)*256); } D3D10_TEXTURE2D_DESC desc; desc.Width = 256; desc.Height = 256; desc.MipLevels = 1; desc.ArraySize = 1; //desc.Format = DXGI_FORMAT_R8_TYPELESS; desc.Format = DXGI_FORMAT_R8_UNORM; desc.SampleDesc.Count = 1; desc.SampleDesc.Quality = 0; //desc.Usage = D3D10_USAGE_IMMUTABLE; desc.Usage = D3D10_USAGE_DEFAULT; desc.BindFlags = D3D10_BIND_SHADER_RESOURCE; desc.CPUAccessFlags = 0; desc.MiscFlags = 0; D3D10_SUBRESOURCE_DATA dataDesc; dataDesc.pSysMem = data; dataDesc.SysMemPitch = 256; ID3D10Texture2D* NoiseTexture = NULL; //ID3D10ShaderResourceView* JitterTextureSRV = NULL; CHK_DX( HW.pDevice->CreateTexture2D(&desc, &dataDesc, &NoiseTexture)); //( m_pD3DDevice->CreateTexture2D(&desc, &dataDesc, &NoiseTexture) ); // Create the shader resource view for jittering //D3D10_SHADER_RESOURCE_VIEW_DESC descSRV; //ZeroMemory( &descSRV, sizeof(descSRV) ); //descSRV.Format = DXGI_FORMAT_R8_UNORM; //descSRV.ViewDimension = D3D10_SRV_DIMENSION_TEXTURE2D; //descSRV.Texture2D.MipLevels = 1; //descSRV.Texture2D.MostDetailedMip = 0; //V( m_pD3DDevice->CreateShaderResourceView( NoiseTexture, &descSRV, &JitterTextureSRV ) ); //pEffect->GetVariableByName("jitterTex")->AsShaderResource() -> SetResource (JitterTextureSRV); m_JitterTexture = dxRenderDeviceRender::Instance().Resources->_CreateTexture("$user$NVjitterTex"); m_JitterTexture->surface_set(NoiseTexture); _RELEASE(NoiseTexture); //SAFE_RELEASE(JitterTextureSRV); }
void dx10ConstantBuffer::Flush() { if (m_bChanged) { void *pData; CHK_DX(m_pBuffer->Map(D3D10_MAP_WRITE_DISCARD, 0, &pData)); VERIFY(pData); VERIFY(m_pBufferData); CopyMemory(pData, m_pBufferData, m_uiBufferSize); m_pBuffer->Unmap(); m_bChanged = false; } }
dx10ConstantBuffer::dx10ConstantBuffer(ID3D10ShaderReflectionConstantBuffer* pTable) : m_bChanged(true) { D3D10_SHADER_BUFFER_DESC Desc; CHK_DX(pTable->GetDesc(&Desc)); m_strBufferName._set(Desc.Name); m_eBufferType = Desc.Type; m_uiBufferSize = Desc.Size; // Fill member list with variable descriptions m_MembersList.resize(Desc.Variables); m_MembersNames.resize(Desc.Variables); for (u32 i=0; i<Desc.Variables; ++i) { ID3D10ShaderReflectionVariable* pVar; ID3D10ShaderReflectionType* pType; D3D10_SHADER_VARIABLE_DESC var_desc; pVar = pTable->GetVariableByIndex(i); VERIFY(pVar); pType = pVar->GetType(); VERIFY(pType); pType->GetDesc(&m_MembersList[i]); // Buffers with the same layout can contain totally different members CHK_DX(pVar->GetDesc(&var_desc)); m_MembersNames[i] = var_desc.Name; } m_uiMembersCRC = crc32( &m_MembersList[0], Desc.Variables*sizeof(m_MembersList[0])); R_CHK(dx10BufferUtils::CreateConstantBuffer(&m_pBuffer, Desc.Size)); VERIFY(m_pBuffer); m_pBufferData = xr_malloc(Desc.Size); VERIFY(m_pBufferData); }
void dxRenderDeviceRender::overdrawEnd() { #ifdef USE_DX10 // TODO: DX10: Implement overdrawEnd VERIFY(!"dxRenderDeviceRender::overdrawBegin not implemented."); #else // USE_DX10 // Set up the stencil states CHK_DX (HW.pDevice->SetRenderState( D3DRS_STENCILZFAIL, D3DSTENCILOP_KEEP )); CHK_DX (HW.pDevice->SetRenderState( D3DRS_STENCILFAIL, D3DSTENCILOP_KEEP )); CHK_DX (HW.pDevice->SetRenderState( D3DRS_STENCILPASS, D3DSTENCILOP_KEEP )); CHK_DX (HW.pDevice->SetRenderState( D3DRS_STENCILFUNC, D3DCMP_EQUAL )); CHK_DX (HW.pDevice->SetRenderState( D3DRS_STENCILMASK, 0xff )); // Set the background to black CHK_DX (HW.pDevice->Clear(0,0,D3DCLEAR_TARGET,D3DCOLOR_XRGB(255,0,0),0,0)); // Draw a rectangle wherever the count equal I RCache.OnFrameEnd (); CHK_DX (HW.pDevice->SetFVF( FVF::F_TL )); // Render gradients for (int I=0; I<12; I++ ) { u32 _c = I*256/13; u32 c = D3DCOLOR_XRGB(_c,_c,_c); FVF::TL pv[4]; pv[0].set(float(0), float(Device.dwHeight), c,0,0); pv[1].set(float(0), float(0), c,0,0); pv[2].set(float(Device.dwWidth), float(Device.dwHeight), c,0,0); pv[3].set(float(Device.dwWidth), float(0), c,0,0); CHK_DX(HW.pDevice->SetRenderState ( D3DRS_STENCILREF, I )); CHK_DX(HW.pDevice->DrawPrimitiveUP ( D3DPT_TRIANGLESTRIP, 2, pv, sizeof(FVF::TL) )); } CHK_DX(HW.pDevice->SetRenderState( D3DRS_STENCILENABLE, FALSE )); #endif // USE_DX10 }
void CTexture::apply_seq (u32 dwStage) { // SEQ u32 frame = Device.dwTimeContinual/seqMSPF; //Device.dwTimeGlobal u32 frame_data = seqDATA.size(); if (flags.seqCycles) { u32 frame_id = frame%(frame_data*2); if (frame_id>=frame_data) frame_id = (frame_data-1) - (frame_id%frame_data); pSurface = seqDATA[frame_id]; } else { u32 frame_id = frame%frame_data; pSurface = seqDATA[frame_id]; } CHK_DX(HW.pDevice->SetTexture(dwStage,pSurface)); };
//-------------------------------------------------------------------------------------------------- void CSoundStream::LoadADPCM( ) { char buf [255]; int pos; sxr_riff riff; sxr_hdr hdr; string256 fn; strconcat (fn,fName,".ogg"); DataPos = NULL; hf = FS.r_open("$game_sounds$",fn); R_ASSERT (hf>=0); ZeroMemory (&riff, sizeof(riff)); XRead (riff); CopyMemory (buf,riff.id,4); buf[4]=0; CopyMemory (buf,riff.wave_id,4); buf[4]=0; while (!hf->eof()) { XRead (hdr); CopyMemory (buf,hdr.id,4); buf[4]=0; pos = hf->tell(); if (stricmp(buf, "fmt ")==0) { dwFMT_Size = hdr.len; psrc = (LPWAVEFORMATEX)xr_malloc(dwFMT_Size); pwfx = (LPWAVEFORMATEX)xr_malloc(dwFMT_Size); hf->r (psrc, dwFMT_Size); CopyMemory (pwfx,psrc, dwFMT_Size); pwfx->wFormatTag = WAVE_FORMAT_PCM; } else { if (stricmp(buf,"data")==0) { DataPos=hf->tell(); dwTotalSize=hdr.len; } } hf->seek(hdr.len+pos); } VERIFY (DataPos); // dest format CHK_DX (acmFormatSuggest(NULL,psrc,pwfx,dwFMT_Size,ACM_FORMATSUGGESTF_WFORMATTAG)); // dest buffer (const size) WaveDest = (unsigned char *)xr_malloc(dwDestBufSize); // wave source -- alloc on Play // DSound---------------------------------------------------------------- ADPCMCreateSoundBuffer (SoundRender.pDevice, &pBuffer, pwfx); }
void CRenderTarget::phase_smap_direct (light* L, u32 sub_phase) { // Targets if (RImplementation.o.HW_smap) u_setrt (rt_smap_surf, NULL, NULL, rt_smap_depth->pRT); else u_setrt (rt_smap_surf, NULL, NULL, rt_smap_ZB); // Clear if (SE_SUN_NEAR==sub_phase) { // optimized clear D3DRECT R; R.x1 = L->X.D.minX; R.x2 = L->X.D.maxX; R.y1 = L->X.D.minY; R.y2 = L->X.D.maxY; CHK_DX (HW.pDevice->Clear( 1L, &R, D3DCLEAR_ZBUFFER, 0xFFFFFFFF, 1.0f, 0L)); } else { // full-clear CHK_DX (HW.pDevice->Clear( 0L, NULL, D3DCLEAR_ZBUFFER, 0xFFFFFFFF, 1.0f, 0L)); } // Stencil - disable RCache.set_Stencil ( FALSE ); // Misc - draw only front/back-faces /* if (SE_SUN_NEAR==sub_phase) RCache.set_CullMode ( CULL_CCW ); // near else { if (RImplementation.o.HW_smap) RCache.set_CullMode ( CULL_CW ); // far, reversed else RCache.set_CullMode ( CULL_CCW ); // far, front-faces } */ // Cull always CCW. If you want to revert to previouse solution, please, revert bias setup/ RCache.set_CullMode ( CULL_CCW ); // near if (RImplementation.o.HW_smap) RCache.set_ColorWriteEnable ( FALSE ); else RCache.set_ColorWriteEnable ( ); }
void CUIStaticItem::Render(float angle) { VERIFY (g_bRendering); // установить обязательно перед вызовом CustomItem::Render() !!! VERIFY (hShader); RCache.set_Shader (hShader); if(alpha_ref!=-1) CHK_DX(HW.pDevice->SetRenderState(D3DRS_ALPHAREF,alpha_ref)); // convert&set pos Fvector2 bp_ns; bp_ns.set (iPos); // actual rendering u32 vOffset; FVF::TL* start_pv = (FVF::TL*)RCache.Vertex.Lock (32,hGeom_fan.stride(),vOffset); FVF::TL* pv = start_pv; inherited::Render (pv,bp_ns,dwColor,angle); // unlock VB and Render it as triangle LIST std::ptrdiff_t p_cnt = pv-start_pv; RCache.Vertex.Unlock (u32(p_cnt),hGeom_fan.stride()); RCache.set_Geometry (hGeom_fan); if (p_cnt>2) RCache.Render (D3DPT_TRIANGLEFAN,vOffset,u32(p_cnt-2)); if(alpha_ref!=-1) CHK_DX(HW.pDevice->SetRenderState(D3DRS_ALPHAREF,0)); }
void CGammaControl::Update() { if (HW.pDevice) { DXGI_GAMMA_CONTROL_CAPABILITIES GC; DXGI_GAMMA_CONTROL G; IDXGIOutput *pOutput; CHK_DX (HW.m_pSwapChain->GetContainingOutput(&pOutput)); HRESULT hr = pOutput->GetGammaControlCapabilities(&GC); if (SUCCEEDED(hr)) { GenLUT( GC, G ); pOutput->SetGammaControl(&G); } } }