本文整理汇总了C++中RenderTargetPtr类的典型用法代码示例。如果您正苦于以下问题:C++ RenderTargetPtr类的具体用法?C++ RenderTargetPtr怎么用?C++ RenderTargetPtr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了RenderTargetPtr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Render
void PostEffect_SSAO::Render(RenderSystemPtr pRenderer, RenderTargetPtr pInput, RenderTargetPtr pOutput)
{
pRenderer->SetRenderTarget(m_pGBlurTarget);
pRenderer->ClearRenderTarget(m_pGBlurTarget, 0, math::Color4(0, 0, 0,0));
m_pMaterial->SetGBuffer(pRenderer->GetGBuffer());
m_pMaterial->SetVectorByName("g_screen_size", math::Vector2(pRenderer->GetFrameBufferWidth(), pRenderer->GetFrameBufferHeight()));
m_pMaterial->SetFloatByName("g_scale", m_scale);
m_pMaterial->SetFloatByName("g_random_size", m_randomTexSize);
m_pMaterial->SetFloatByName("g_sample_rad", m_sampleRad);
m_pMaterial->SetFloatByName("g_bias", m_bias);
m_pMaterial->SetFloatByName("g_intensity", m_intensity);
pRenderer->DrawFullScreenQuad(m_pMaterial);
pRenderer->SetRenderTarget(pOutput);
pRenderer->ClearRenderTarget(pOutput, 0, math::Color4(0, 0, 0,0));
m_pGBlurMaterial->SetGBuffer(pRenderer->GetGBuffer());
m_pGBlurMaterial->SetTextureByName("tex_ao", m_pGBlurTarget->AsTexture(0));
m_pGBlurMaterial->SetVectorByName("g_input_size", math::Vector2(pRenderer->GetFrameBufferWidth(), pRenderer->GetFrameBufferHeight()));
m_pGBlurMaterial->SetTextureByName("tex_input", pInput->AsTexture(0));
pRenderer->DrawFullScreenQuad(m_pGBlurMaterial);
}
示例2:
void D3D11EffectMaterial::SetABuffer(RenderTargetPtr pABuffer)
{
if(m_semantics.m_pABuffer == nullptr)
{
return;
}
D3D11Texture* pTex1 = (D3D11Texture*)(pABuffer->AsTexture(0).get());
m_semantics.m_pABuffer->SetResource(pTex1->GetShaderResourceView());
}
示例3: Render
void PostEffect_GaussianBlur::Render(RenderSystemPtr pRenderer, RenderTargetPtr pInput, RenderTargetPtr pOutput)
{
pRenderer->SetRenderTarget(pOutput);
pRenderer->ClearRenderTarget(pOutput, 0, math::Color4(0, 0, 0,0));
m_pMaterial->SetTextureByName("tex_input", pInput->AsTexture(0));
m_pMaterial->SetVectorByName("g_input_size", math::Vector2(pRenderer->GetFrameBufferWidth(), pRenderer->GetFrameBufferHeight()));
pRenderer->DrawFullScreenQuad(m_pMaterial);
}
示例4: ClearRenderTarget
void GraphicsDriver::ClearRenderTarget(RenderTargetPtr inRenderTarget, const Vector3& inColor, float inAlpha)
{
float color[4];
color[0] = inColor.x;
color[1] = inColor.y;
color[2] = inColor.z;
color[3] = inAlpha;
// Clear the back buffer
g_pImmediateContext->ClearRenderTargetView( inRenderTarget.get(), color );
}
示例5: render
void TargetRenderer::render() {
for (RenderJobMap::iterator it = m_targets.begin(); it != m_targets.end(); ++it) {
if (it->second.ndraws != -1) {
if (it->second.ndraws == it->second.lasttime_draw) {
RenderTargetPtr rt = it->second.target;
m_renderbackend->attachRenderTarget(rt->m_target, it->second.discard);
rt->render();
m_renderbackend->detachRenderTarget();
if(it->second.ndraws == 0) {
it->second.ndraws = -1;
} else {
it->second.lasttime_draw = 0;
}
} else {
++it->second.lasttime_draw;
}
}
}
}
示例6: createRenderable
TexturePtr LinearGradient::createAsTexture(int width, int height)
{
const float w = static_cast<float>(width);
const float h = static_cast<float>(height);
const float sa = std::abs(std::sin(-angle_ / 180.0f * static_cast<float>(M_PI)));
const float ca = std::abs(std::cos(-angle_ / 180.0f * static_cast<float>(M_PI)));
//const float length = std::min(ca < FLT_EPSILON ? FLT_MAX : width / ca, sa < FLT_EPSILON ? FLT_MAX : height / sa);
//const float length = std::min(ca < FLT_EPSILON ? w : 2.0f * ca * w, sa < FLT_EPSILON ? h : 2.0f * sa * h);
WindowPtr wnd = WindowManager::getMainWindow();
CameraPtr cam = std::make_shared<Camera>("ortho_lg", 0, width, 0, height);
auto grad = createRenderable();
grad->setCamera(cam);
grad->setScale(ca < FLT_EPSILON ? w : 2.0f * w / ca, sa < FLT_EPSILON ? h : 2.0f * h / sa);
grad->setPosition(w/2.0f, h/2.0f);
RenderTargetPtr rt = RenderTarget::create(width, height);
rt->getTexture()->setFiltering(-1, Texture::Filtering::LINEAR, Texture::Filtering::LINEAR, Texture::Filtering::POINT);
rt->getTexture()->setAddressModes(-1, Texture::AddressMode::CLAMP, Texture::AddressMode::CLAMP);
rt->setCentre(Blittable::Centre::TOP_LEFT);
rt->setClearColor(Color(0,0,0,0));
{
RenderTarget::RenderScope rs(rt, rect(0, 0, width, height));
grad->preRender(wnd);
wnd->render(grad.get());
}
return rt->getTexture();
}
示例7: CreateRenderTargets
///Создание целей рендеринга
void CreateRenderTargets ()
{
try
{
if (!swap_chain)
throw xtl::format_operation_exception ("", "Null swap chain");
log.Printf ("Initialize render targets for swap chain");
LowLevelTexturePtr color_texture (device_manager->Device ().CreateRenderTargetTexture (swap_chain.get (), swap_chain_desc.buffers_count - 1), false),
depth_stencil_texture (device_manager->Device ().CreateDepthStencilTexture (swap_chain.get ()), false);
if (!color_buffer)
{
RenderTargetPtr new_color_buffer (new RenderTargetImpl (device_manager, color_texture.get ()), false),
new_depth_stencil_buffer (new RenderTargetImpl (device_manager, depth_stencil_texture.get ()), false);
color_buffer = new_color_buffer;
depth_stencil_buffer = new_depth_stencil_buffer;
}
else
{
try
{
color_buffer->SetTarget (color_texture.get ());
depth_stencil_buffer->SetTarget (depth_stencil_texture.get ());
}
catch (...)
{
color_buffer->SetTarget (0);
depth_stencil_buffer->SetTarget (0);
throw;
}
}
color_buffer->Resize (width, height);
depth_stencil_buffer->Resize (width, height);
log.Printf ("...render targets for swap chain created");
}
catch (xtl::exception& e)
{
e.touch ("render::manager::WindowImpl::Impl::CreateRenderTargets");
throw;
}
}
示例8: SetRenderTarget
void UGraphicsDevice::SetRenderTarget(RenderTargetPtr inRenderTarget, DepthStencilViewPtr inDepthStencil)
{
auto renderTarget = inRenderTarget.get();
mD3dDeviceCtx->OMSetRenderTargets(1, &renderTarget, inDepthStencil.get());
}
示例9: ClearRenderTarget
void GraphicsDriver::ClearRenderTarget( RenderTargetPtr inRenderTarget, const XMVECTORF32& inColor )
{
// Clear the back buffer
g_pImmediateContext->ClearRenderTargetView( inRenderTarget.get(), inColor );
}
示例10: ClearRenderTarget
void UGraphicsDevice::ClearRenderTarget(RenderTargetPtr inRenderTarget, const float inClearColor[4])
{
mD3dDeviceCtx->ClearRenderTargetView(inRenderTarget.get(), inClearColor);
}
示例11: main
//.........这里部分代码省略.........
wd_mapping["u_anura_sprite_area"] = offsetof(water_distort_uniforms, sprite_area);
wd_mapping["u_anura_draw_area"] = offsetof(water_distort_uniforms, draw_area);
wd_mapping["u_intensity"] = offsetof(water_distort_uniforms, intensity);
wd_mapping["u_water_area"] = offsetof(water_distort_uniforms, water_area);
water_uniforms.setMapping(&wd_mapping);
auto water_tex = SimpleTextureHolder("checkerboard1.png");
water_tex.setPosition(neww/2, newh/2);
water_tex.setShader(water_shader);
water_tex.addUniformBuffer(std::move(water_uniforms));
*/
variant_builder tmxvar;
tmxvar.add("tmx", "data/isometric_grass_and_water.tmx");
auto tiled_map = scene->createNode("tiled_map", tmxvar.build());
tiled_map->setPosition(main_wnd->width() / 2, 0);
//tiled::TmxReader tmx_reader(std::dynamic_pointer_cast<tiled::Map>(tiled_map));
//tmx_reader.parseFile("data/isometric_grass_and_water.tmx");
//tmx_reader.parseFile("data/hex-mini.tmx");
//tmx_reader.parseFile("data/sewer_tileset.tmx");
//tmx_reader.parseFile("data/small_isometric_staggered_grass_and_water.tmx");
//root->attachNode(tiled_map);
//auto blue_box = std::make_shared<BlurredBlittable>("blue_box3.png");
//const int bbox_w = blue_box->getTexture()->width();
//const int bbox_h = blue_box->getTexture()->height();
//blue_box->setCentre(Blittable::Centre::TOP_LEFT);
//blue_box->setPosition(0, 0);
//blue_box->setCamera(std::make_shared<Camera>("ortho999", 0, bbox_w, 0, bbox_h));
const int bbox_w = 512;
const int bbox_h = 256;
auto sr = std::make_shared<SimpleRenderable>(rect(24, 24, bbox_w-48, bbox_h-48), Color(0, 0, 0, 255));
CameraPtr box_cam = std::make_shared<Camera>("ortho999", 0, bbox_w, 0, bbox_h);
sr->setCamera(box_cam);
RenderTargetPtr rt = RenderTarget::create(bbox_w, bbox_h);
rt->getTexture()->setFiltering(-1, Texture::Filtering::LINEAR, Texture::Filtering::LINEAR, Texture::Filtering::POINT);
rt->getTexture()->setAddressModes(-1, Texture::AddressMode::CLAMP, Texture::AddressMode::CLAMP);
rt->setCentre(Blittable::Centre::TOP_LEFT);
rt->setClearColor(Color(128,128,128,0));
rt->apply(rect(0, 0, bbox_w, bbox_h));
rt->clear();
//blue_box->preRender(main_wnd);
//main_wnd->render(blue_box.get());
sr->preRender(main_wnd);
main_wnd->render(sr.get());
rt->unapply();
//root->attachObject(rt);
auto shader_blur = ShaderProgram::getProgram("blur2");
rt->setShader(shader_blur);
const int blur_two = shader_blur->getUniform("texel_width_offset");
const int blur_tho = shader_blur->getUniform("texel_height_offset");
const int u_gaussian = shader_blur->getUniform("gaussian");
std::vector<float> gaussian = generate_gaussian(20.0f, 7);//{ 0.05f, 0.09f, 0.12f, 0.15f, 0.16f, 0.15f, 0.12f, 0.09f, 0.05f };
shader_blur->setUniformDrawFunction([blur_two, blur_tho, bbox_h, gaussian, u_gaussian](ShaderProgramPtr shader){
shader->setUniformValue(u_gaussian, &gaussian[0]);
shader->setUniformValue(blur_two, 0.0f);
shader->setUniformValue(blur_tho, 1.0f / (bbox_h - 1.0f));
});
//rt->setOrder(1);
RenderTargetPtr rt2 = RenderTarget::create(bbox_w, bbox_h);
rt2->setCentre(Blittable::Centre::TOP_LEFT);
rt2->setClearColor(Color(0,0,0,0));
{
rt->setCamera(box_cam);
RenderTarget::RenderScope rs(rt2, rect(0, 0, bbox_w, bbox_h));
rt->preRender(main_wnd);
main_wnd->render(rt.get());
示例12: OnSizeChanged
///Обработка события изменения размеров окна
void OnSizeChanged (unsigned int width, unsigned int height)
{
try
{
UpdateSizes (width, height);
if (signals [WindowEvent_OnResize].empty ())
return;
if (color_buffer)
{
color_buffer->Resize (width, height);
depth_stencil_buffer->Resize (width, height);
}
Window window = Wrappers::Wrap<Window> (owner);
signals [WindowEvent_OnResize] (window);
}
catch (std::exception& e)
{
log.Printf ("%s\n at render::manager::WindowImpl::Impl::OnResize", e.what ());
}
catch (...)
{
log.Printf ("unknown exception\n at render::manager::WindowImpl::Impl::OnResize");
}
}
示例13: OnViewportChanged
///Обработчик события изменения области вывода
void OnViewportChanged (const Rect& viewport)
{
try
{
log.Printf ("Window viewport changed: x=%d, y=%d, width=%u, height=%u", viewport.x, viewport.y, viewport.width, viewport.height);
if (color_buffer)
{
color_buffer->Resize (viewport.width, viewport.height);
color_buffer->SetViewportOffset (math::vec2ui (viewport.x, viewport.y));
}
if (depth_stencil_buffer)
{
depth_stencil_buffer->Resize (viewport.width, viewport.height);
depth_stencil_buffer->SetViewportOffset (math::vec2ui (viewport.x, viewport.y));
}
}
catch (std::exception& e)
{
log.Printf ("%s\n at render::manager::WindowImpl::Impl::OnChangeViewport", e.what ());
}
catch (...)
{
log.Printf ("unknown exception\n at render::manager::WindowImpl::Impl::OnChangeViewport");
}
}
示例14: CreateSharedEnvRT
//---------------------------------------------------------------------------
void SkySphere::CreateSharedEnvRT(){
if (!sRT)
{
RenderTargetParam param;
param.mEveryFrame = false;
param.mSize = Vec2I(ENV_SIZE, ENV_SIZE);
param.mPixelFormat = PIXEL_FORMAT_R8G8B8A8_UNORM;
param.mShaderResourceView = true;
param.mMipmap = true;
param.mCubemap = true;
param.mWillCreateDepth = false;
param.mUsePool = true;
auto& renderer = Renderer::GetInstance();
sRT = renderer.CreateRenderTarget(param);
sScene = Scene::Create("SkySphereScene");
sRT->RegisterScene(sScene);
sRenderStrategy = RenderStrategyMinimum::Create();
sRT->SetRenderStrategy(sRenderStrategy);
}
}
示例15: OnHandleChanged
///Обработка события смены оконного дескриптора
void OnHandleChanged (void* handle)
{
try
{
log.Printf ("Swap chain handle changed (handle=%p)", handle);
swap_chain = 0;
if (!handle)
return;
CreateSwapChain (handle);
try
{
CreateRenderTargets ();
}
catch (...)
{
swap_chain = 0;
if (color_buffer) color_buffer->SetTarget (0);
if (depth_stencil_buffer) depth_stencil_buffer->SetTarget (0);
throw;
}
}
catch (std::exception& e)
{
log.Printf ("%s\n at render::manager::WindowImpl::Impl::OnChangeHandle", e.what ());
}
catch (...)
{
log.Printf ("unknown exception\n at render::manager::WindowImpl::Impl::OnChangeHandle");
}
}