本文整理汇总了C++中D3D11GraphicsEngine类的典型用法代码示例。如果您正苦于以下问题:C++ D3D11GraphicsEngine类的具体用法?C++ D3D11GraphicsEngine怎么用?C++ D3D11GraphicsEngine使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了D3D11GraphicsEngine类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
/** Renders all cubemap faces at once, using the geometry shader */
void D3D11PointLight::RenderFullCubemap()
{
D3D11GraphicsEngineBase* engineBase = (D3D11GraphicsEngineBase *)Engine::GraphicsEngine;
D3D11GraphicsEngine* engine = (D3D11GraphicsEngine *) engineBase; // TODO: Remove and use newer system!
// Disable shadows for NPCs
// TODO: Only for the player himself, because his shadows look ugly when using a torch
bool oldDrawSkel = Engine::GAPI->GetRendererState()->RendererSettings.DrawSkeletalMeshes;
//Engine::GAPI->GetRendererState()->RendererSettings.DrawSkeletalMeshes = false;
float range = LightInfo->Vob->GetLightRange() * 1.1f;
// Draw no npcs if this is a static light. This is archived by simply not drawing them in the first update
bool noNPCs = !DrawnOnce;//!LightInfo->Vob->IsStatic();
// Draw cubemap
std::map<MeshKey, WorldMeshInfo*, cmpMeshKey>* wc = &WorldMeshCache;
// Don't use the cache if we have moved
if(WorldCacheInvalid)
wc = NULL;
engine->RenderShadowCube(LightInfo->Vob->GetPositionWorld(), range, DepthCubemap, NULL, NULL, false, LightInfo->IsIndoorVob, noNPCs, &VobCache, &SkeletalVobCache, wc);
//Engine::GAPI->GetRendererState()->RendererSettings.DrawSkeletalMeshes = oldDrawSkel;
}
示例2:
/** Renders the SMAA-Effect */
XRESULT D3D11PfxRenderer::RenderSMAA()
{
D3D11GraphicsEngine* engine = (D3D11GraphicsEngine*)Engine::GraphicsEngine;
FX_SMAA->RenderPostFX(engine->GetHDRBackBuffer()->GetShaderResView());
return XR_SUCCESS;
}
示例3:
/** Unmaps the buffer */
XRESULT D3D11VertexBuffer::Unmap()
{
D3D11GraphicsEngine* engine = (D3D11GraphicsEngine *)Engine::GraphicsEngine;
engine->GetContext()->Unmap(VertexBuffer, 0);
return XR_SUCCESS;
}
示例4:
/** Applys the shaders */
XRESULT D3D11VShader::Apply()
{
D3D11GraphicsEngine* engine = (D3D11GraphicsEngine *)Engine::GraphicsEngine;
engine->GetContext()->IASetInputLayout(InputLayout);
engine->GetContext()->VSSetShader(VertexShader, NULL, 0);
return XR_SUCCESS;
}
示例5: ZeroMemory
/** Unbinds texturesamplers from the pixel-shader */
XRESULT D3D11PfxRenderer::UnbindPSResources(int num)
{
ID3D11ShaderResourceView** srv = new ID3D11ShaderResourceView*[num];
ZeroMemory(srv, sizeof(ID3D11ShaderResourceView*) * num);
D3D11GraphicsEngine* engine = (D3D11GraphicsEngine *)Engine::GraphicsEngine;
engine->GetContext()->PSSetShaderResources(0, num, srv);
delete[] srv;
return XR_SUCCESS;
}
示例6: Draw
/** Draws the ocean */
void GOcean::Draw()
{
if(Patches.empty())
return;
D3D11GraphicsEngine* engine = (D3D11GraphicsEngine *)Engine::GraphicsEngine;
engine->SetDefaultStates();
FFTOceanSimulator->updateDisplacementMap(Engine::GAPI->GetTimeSeconds());
engine->DrawOcean(this);
}
示例7: D3D11PFX_Effect
D3D11PFX_HDR::D3D11PFX_HDR(D3D11PfxRenderer* rnd) : D3D11PFX_Effect(rnd)
{
D3D11GraphicsEngine* engine = (D3D11GraphicsEngine *)Engine::GraphicsEngine;
// Create lum-buffer
LumBuffer1 = new RenderToTextureBuffer(engine->GetDevice(), LUM_SIZE, LUM_SIZE, DXGI_FORMAT_R16_FLOAT, NULL, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, (int)(log(LUM_SIZE) / log(2)));
LumBuffer2 = new RenderToTextureBuffer(engine->GetDevice(), LUM_SIZE, LUM_SIZE, DXGI_FORMAT_R16_FLOAT, NULL, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, (int)(log(LUM_SIZE) / log(2)));
LumBuffer3 = new RenderToTextureBuffer(engine->GetDevice(), LUM_SIZE, LUM_SIZE, DXGI_FORMAT_R16_FLOAT, NULL, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, (int)(log(LUM_SIZE) / log(2)));
engine->GetContext()->ClearRenderTargetView(LumBuffer1->GetRenderTargetView(), (float *)&D3DXVECTOR4(0,0,0,0));
engine->GetContext()->ClearRenderTargetView(LumBuffer2->GetRenderTargetView(), (float *)&D3DXVECTOR4(0,0,0,0));
engine->GetContext()->ClearRenderTargetView(LumBuffer3->GetRenderTargetView(), (float *)&D3DXVECTOR4(0,0,0,0));
ActiveLumBuffer = 0;
}
示例8: if
/** Debug-draws the cubemap to the screen */
void D3D11PointLight::DebugDrawCubeMap()
{
if(!InitDone)
return;
D3D11GraphicsEngineBase* engineBase = (D3D11GraphicsEngineBase *)Engine::GraphicsEngine;
D3D11GraphicsEngine* engine = (D3D11GraphicsEngine *) engineBase; // TODO: Remove and use newer system!
const int previewSize = POINTLIGHT_SHADOWMAP_SIZE;
const int previewDownscale = 4;
for(int i=0;i<6;i++)
{
INT2 pPosition;
int stride = (previewSize / previewDownscale);
if(i==1) // x-
{
pPosition.x = 0;
pPosition.y = stride;
}else if(i==3) // y-
{
pPosition.x = stride;
pPosition.y = stride;
}else if(i==0) // x+
{
pPosition.x = stride * 2;
pPosition.y = stride;
}else if(i==2) // y+
{
pPosition.x = stride * 3;
pPosition.y = stride;
}else if(i==5) // z-
{
pPosition.x = stride;
pPosition.y = 0;
}else if(i==4) // z+
{
pPosition.x = stride;
pPosition.y = stride * 2;
}
INT2 pSize = INT2(previewSize / previewDownscale,previewSize / previewDownscale);
ID3D11ShaderResourceView* srv = engine->GetDummyCubeRT()->GetSRVCubemapFace(i);
engine->GetContext()->PSSetShaderResources(0,1, &srv);
Engine::GraphicsEngine->DrawQuad(pPosition, pSize);
}
}
示例9: CalcLuminance
/** Draws this effect to the given buffer */
XRESULT D3D11PFX_HDR::Render(RenderToTextureBuffer* fxbuffer)
{
D3D11GraphicsEngine* engine = (D3D11GraphicsEngine *)Engine::GraphicsEngine;
Engine::GAPI->GetRendererState()->BlendState.BlendEnabled = false;
Engine::GAPI->GetRendererState()->BlendState.SetDirty();
// Save old rendertargets
ID3D11RenderTargetView* oldRTV = NULL;
ID3D11DepthStencilView* oldDSV = NULL;
engine->GetContext()->OMGetRenderTargets(1, &oldRTV, &oldDSV);
RenderToTextureBuffer* lum = CalcLuminance();
CreateBloom(lum);
// Copy the original image to our temp-buffer
FxRenderer->CopyTextureToRTV(engine->GetHDRBackBuffer()->GetShaderResView(), FxRenderer->GetTempBuffer()->GetRenderTargetView(), engine->GetResolution());
// Bind scene and luminance
FxRenderer->GetTempBuffer()->BindToPixelShader(engine->GetContext(), 0);
lum->BindToPixelShader(engine->GetContext(), 1);
// Bind bloom
FxRenderer->GetTempBufferDS4_1()->BindToPixelShader(engine->GetContext(), 2);
// Draw the HDR-Shader
D3D11PShader* hps = engine->GetShaderManager()->GetPShader("PS_PFX_HDR");
hps->Apply();
HDRSettingsConstantBuffer hcb;
hcb.HDR_LumWhite = Engine::GAPI->GetRendererState()->RendererSettings.HDRLumWhite;
hcb.HDR_MiddleGray = Engine::GAPI->GetRendererState()->RendererSettings.HDRMiddleGray;
hcb.HDR_Threshold = Engine::GAPI->GetRendererState()->RendererSettings.BloomThreshold;
hcb.HDR_BloomStrength = Engine::GAPI->GetRendererState()->RendererSettings.BloomStrength;
hps->GetConstantBuffer()[0]->UpdateBuffer(&hcb);
hps->GetConstantBuffer()[0]->BindToPixelShader(0);
FxRenderer->CopyTextureToRTV(FxRenderer->GetTempBuffer()->GetShaderResView(), oldRTV, engine->GetResolution(), true);
// Show lumBuffer
//FxRenderer->CopyTextureToRTV(currentLum->GetShaderResView(), oldRTV, INT2(LUM_SIZE,LUM_SIZE), false);
// Restore rendertargets
ID3D11ShaderResourceView* srv = NULL;
engine->GetContext()->PSSetShaderResources(1,1,&srv);
engine->GetContext()->OMSetRenderTargets(1, &oldRTV, oldDSV);
if(oldRTV)oldRTV->Release();
if(oldDSV)oldDSV->Release();
return XR_SUCCESS;
}
示例10: InitOcean
/** Initializes the ocean */
XRESULT GOcean::InitOcean()
{
D3D11GraphicsEngine* engine = (D3D11GraphicsEngine *)Engine::GraphicsEngine;
PlaneMesh = new GMesh;
if(XR_SUCCESS != PlaneMesh->LoadMesh("system\\GD3D11\\Meshes\\PlaneSubdiv.3ds"))
{
delete PlaneMesh;
PlaneMesh = NULL;
return XR_FAILED;
}
// Create ocean simulating object
// Ocean object
OceanParameter ocean_param;
// The size of displacement map. In this sample, it's fixed to 512.
ocean_param.dmap_dim = 512;
// The side length (world space) of square patch
ocean_param.patch_length = 2000.0f;
// Adjust this parameter to control the simulation speed
ocean_param.time_scale = 0.8f;
// A scale to control the amplitude. Not the world space height
ocean_param.wave_amplitude = 0.35f;
// 2D wind direction. No need to be normalized
ocean_param.wind_dir = D3DXVECTOR2(0.8f, 0.6f);
// The bigger the wind speed, the larger scale of wave crest.
// But the wave scale can be no larger than patch_length
ocean_param.wind_speed = 600.0f;
// Damp out the components opposite to wind direction.
// The smaller the value, the higher wind dependency
ocean_param.wind_dependency = 0.07f;
// Control the scale of horizontal movement. Higher value creates
// pointy crests.
ocean_param.choppy_scale = 1.3f;
FFTOceanSimulator = new OceanSimulator(ocean_param, engine->GetDevice());
// Update the simulation for the first time.
FFTOceanSimulator->updateDisplacementMap(0);
// Create fresnel map
CreateFresnelMap(engine->GetDevice());
return XR_SUCCESS;
}
示例11: RenderToTextureBuffer
/** Called on resize */
XRESULT D3D11PfxRenderer::OnResize(const INT2& newResolution)
{
D3D11GraphicsEngine* engine = (D3D11GraphicsEngine *)Engine::GraphicsEngine;
// Create temp-buffer
delete TempBuffer;
TempBuffer = new RenderToTextureBuffer(engine->GetDevice(), newResolution.x, newResolution.y, DXGI_FORMAT_R16G16B16A16_FLOAT, NULL);
delete TempBufferDS4_1;
TempBufferDS4_1 = new RenderToTextureBuffer(engine->GetDevice(), newResolution.x / 4, newResolution.y / 4, DXGI_FORMAT_R16G16B16A16_FLOAT, NULL);
delete TempBufferDS4_2;
TempBufferDS4_2 = new RenderToTextureBuffer(engine->GetDevice(), newResolution.x / 4, newResolution.y / 4, DXGI_FORMAT_R16G16B16A16_FLOAT, NULL);
FX_SMAA->OnResize(newResolution);
return XR_SUCCESS;
}
示例12: sizeof
/** Draws a fullscreenquad */
XRESULT D3D11PfxRenderer::DrawFullScreenQuad()
{
D3D11GraphicsEngine* engine = (D3D11GraphicsEngine *)Engine::GraphicsEngine;
engine->UpdateRenderStates();
engine->GetContext()->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
UINT offset = 0;
UINT uStride = sizeof(SimpleVertexStruct);
ID3D11Buffer* buffers = ScreenQuad->GetBuffer();
engine->GetContext()->IASetVertexBuffers( 0, 1, &buffers, &uStride, &offset );
//ID3D11Buffer* cb = NULL;
//engine->GetContext()->VSSetConstantBuffers(0, 1, &cb);
//Draw the mesh
engine->GetContext()->Draw(6, 0 );
return XR_SUCCESS;
}
示例13: SetRect
/** Sets the position and size of this sub-view */
void SV_GMeshInfoView::SetRect(const D2D1_RECT_F& rect)
{
D3D11GraphicsEngine* g = (D3D11GraphicsEngine *)Engine::GraphicsEngine;
D2DSubView::SetRect(rect);
Panel->SetRect(D2D1::RectF(0, 0, GetSize().width, GetSize().height));
// Create new RT
delete RT;
RT = new RenderToTextureBuffer(g->GetDevice(),
(UINT)std::max(8.0f, GetSize().width),
(UINT)std::max(8.0f, GetSize().height),
DXGI_FORMAT_R8G8B8A8_UNORM);
delete DS;
DS = new RenderToDepthStencilBuffer(g->GetDevice(),
(UINT)std::max(8.0f, GetSize().width),
(UINT)std::max(8.0f, GetSize().height),
DXGI_FORMAT_R32_TYPELESS, NULL, DXGI_FORMAT_D32_FLOAT, DXGI_FORMAT_R32_FLOAT);
}
示例14:
/** Blurs the backbuffer and puts the result into TempBufferDS4_2*/
void D3D11PFX_HDR::CreateBloom(RenderToTextureBuffer* lum)
{
D3D11GraphicsEngine* engine = (D3D11GraphicsEngine *)Engine::GraphicsEngine;
INT2 dsRes = INT2(Engine::GraphicsEngine->GetResolution().x / 4, Engine::GraphicsEngine->GetResolution().y / 4);
engine->GetShaderManager()->GetVShader("VS_PFX")->Apply();
D3D11PShader* tonemapPS = engine->GetShaderManager()->GetPShader("PS_PFX_Tonemap");
tonemapPS->Apply();
HDRSettingsConstantBuffer hcb;
hcb.HDR_LumWhite = Engine::GAPI->GetRendererState()->RendererSettings.HDRLumWhite;
hcb.HDR_MiddleGray = Engine::GAPI->GetRendererState()->RendererSettings.HDRMiddleGray;
hcb.HDR_Threshold = Engine::GAPI->GetRendererState()->RendererSettings.BloomThreshold;
tonemapPS->GetConstantBuffer()[0]->UpdateBuffer(&hcb);
tonemapPS->GetConstantBuffer()[0]->BindToPixelShader(0);
lum->BindToPixelShader(engine->GetContext(), 1);
FxRenderer->CopyTextureToRTV(engine->GetHDRBackBuffer()->GetShaderResView(), FxRenderer->GetTempBufferDS4_1()->GetRenderTargetView(), dsRes, true);
D3D11PShader* gaussPS = engine->GetShaderManager()->GetPShader("PS_PFX_GaussBlur");
/** Pass 1: Blur-H */
// Apply PFX-VS
D3D11PShader* simplePS = engine->GetShaderManager()->GetPShader("PS_PFX_Simple");
// Apply blur-H shader
gaussPS->Apply();
// Update settings
BlurConstantBuffer bcb;
bcb.B_BlurSize = 1.0f;
bcb.B_PixelSize = float2(1.0f / FxRenderer->GetTempBufferDS4_1()->GetSizeX(), 0.0f);
gaussPS->GetConstantBuffer()[0]->UpdateBuffer(&bcb);
gaussPS->GetConstantBuffer()[0]->BindToPixelShader(0);
// Copy
FxRenderer->CopyTextureToRTV(FxRenderer->GetTempBufferDS4_1()->GetShaderResView(), FxRenderer->GetTempBufferDS4_2()->GetRenderTargetView(), dsRes, true);
/** Pass 2: Blur V */
// Update settings
bcb.B_BlurSize = 1.0f;
bcb.B_PixelSize = float2(0.0f, 1.0f / FxRenderer->GetTempBufferDS4_1()->GetSizeY());
bcb.B_Threshold = 0.0f;
gaussPS->GetConstantBuffer()[0]->UpdateBuffer(&bcb);
gaussPS->GetConstantBuffer()[0]->BindToPixelShader(0);
// Copy
FxRenderer->CopyTextureToRTV(FxRenderer->GetTempBufferDS4_2()->GetShaderResView(), FxRenderer->GetTempBufferDS4_1()->GetRenderTargetView(), dsRes, true);
}
示例15:
/** Draws this effect to the given buffer */
XRESULT D3D11PFX_GodRays::Render(RenderToTextureBuffer* fxbuffer)
{
D3D11GraphicsEngine* engine = (D3D11GraphicsEngine *)Engine::GraphicsEngine;
D3DXVECTOR3 sunPosition = *Engine::GAPI->GetSky()->GetAtmosphereCB().AC_LightPos.toD3DXVECTOR3();
sunPosition *= Engine::GAPI->GetSky()->GetAtmosphereCB().AC_OuterRadius;
sunPosition += Engine::GAPI->GetCameraPosition(); // Maybe use cameraposition from sky?
D3DXMATRIX& view = Engine::GAPI->GetRendererState()->TransformState.TransformView;
D3DXMATRIX& proj = Engine::GAPI->GetProjectionMatrix();
D3DXMATRIX viewProj = proj * view;
D3DXMatrixTranspose(&viewProj, &viewProj);
D3DXMatrixTranspose(&view, &view);
D3DXVECTOR3 sunViewPosition;
D3DXVec3TransformCoord(&sunViewPosition, &sunPosition, &view); // This is for checking if the light is behind the camera
D3DXVec3TransformCoord(&sunPosition, &sunPosition, &viewProj);
if(sunViewPosition.z < 0.0f)
return XR_SUCCESS; // Don't render the godrays when the sun is behind the camera
GodRayZoomConstantBuffer gcb;
gcb.GR_Weight = 1.0f;
gcb.GR_Decay = Engine::GAPI->GetRendererState()->RendererSettings.GodRayDecay;
gcb.GR_Weight = Engine::GAPI->GetRendererState()->RendererSettings.GodRayWeight;
gcb.GR_Density = Engine::GAPI->GetRendererState()->RendererSettings.GodRayDensity;
gcb.GR_Center.x = sunPosition.x/2.0f +0.5f;
gcb.GR_Center.y = sunPosition.y/-2.0f +0.5f;
gcb.GR_ColorMod = Engine::GAPI->GetRendererState()->RendererSettings.GodRayColorMod;
if(abs(gcb.GR_Center.x - 0.5f) > 0.5f)
gcb.GR_Weight *= std::max(0.0f, 1.0f - (abs(gcb.GR_Center.x - 0.5f) - 0.5f) / 0.5f);
if(abs(gcb.GR_Center.y - 0.5f) > 0.5f)
gcb.GR_Weight *= std::max(0.0f, 1.0f - (abs(gcb.GR_Center.y - 0.5f) - 0.5f) / 0.5f);
ID3D11RenderTargetView* oldRTV=NULL;
ID3D11DepthStencilView* oldDSV=NULL;
engine->GetContext()->OMGetRenderTargets(1, &oldRTV, &oldDSV);
D3D11VShader* vs = engine->GetShaderManager()->GetVShader("VS_PFX");
D3D11PShader* maskPS = engine->GetShaderManager()->GetPShader("PS_PFX_GodRayMask");
D3D11PShader* zoomPS = engine->GetShaderManager()->GetPShader("PS_PFX_GodRayZoom");
maskPS->Apply();
vs->Apply();
// Draw downscaled mask
engine->GetContext()->OMSetRenderTargets(1, FxRenderer->GetTempBufferDS4_1()->GetRenderTargetViewPtr(), NULL);
engine->GetHDRBackBuffer()->BindToPixelShader(engine->GetContext(), 0);
engine->GetGBuffer1()->BindToPixelShader(engine->GetContext(), 1);
D3D11_VIEWPORT vp;
vp.TopLeftX = 0.0f;
vp.TopLeftY = 0.0f;
vp.MinDepth = 0.0f;
vp.MaxDepth = 1.0f;
vp.Width = (float)FxRenderer->GetTempBufferDS4_1()->GetSizeX();
vp.Height = (float)FxRenderer->GetTempBufferDS4_1()->GetSizeY();
engine->GetContext()->RSSetViewports(1, &vp);
FxRenderer->DrawFullScreenQuad();
// Zoom
zoomPS->Apply();
zoomPS->GetConstantBuffer()[0]->UpdateBuffer(&gcb);
zoomPS->GetConstantBuffer()[0]->BindToPixelShader(0);
FxRenderer->CopyTextureToRTV(FxRenderer->GetTempBufferDS4_1()->GetShaderResView(), FxRenderer->GetTempBufferDS4_2()->GetRenderTargetView(), INT2(0,0), true);
// Upscale and blend
Engine::GAPI->GetRendererState()->BlendState.SetAdditiveBlending();
Engine::GAPI->GetRendererState()->BlendState.SetDirty();
FxRenderer->CopyTextureToRTV(FxRenderer->GetTempBufferDS4_2()->GetShaderResView(), oldRTV, INT2(engine->GetResolution().x, engine->GetResolution().y));
vp.Width = (float)engine->GetResolution().x;
vp.Height = (float)engine->GetResolution().y;
engine->GetContext()->RSSetViewports(1, &vp);
engine->GetContext()->OMSetRenderTargets(1, &oldRTV, oldDSV);
if(oldRTV)oldRTV->Release();
if(oldDSV)oldDSV->Release();
return XR_SUCCESS;
}