本文整理汇总了C++中CreateRenderTarget函数的典型用法代码示例。如果您正苦于以下问题:C++ CreateRenderTarget函数的具体用法?C++ CreateRenderTarget怎么用?C++ CreateRenderTarget使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CreateRenderTarget函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: assert
//--------------------------------------------------------------------------------------
// Name: Downsample4x4Texture()
// Desc: Scale down pSrcTexture by 1/4 x 1/4 and place the result in pDstTexture
//--------------------------------------------------------------------------------------
VOID PostProcess::Downsample4x4Texture( LPDIRECT3DTEXTURE9 pSrcTexture,
LPDIRECT3DTEXTURE9 pDstTexture )
{
// Make sure that the required shaders and objects exist
assert( m_pDownScale4x4PS );
assert( pSrcTexture && pDstTexture );
XGTEXTURE_DESC SrcDesc;
XGGetTextureDesc( pSrcTexture, 0, &SrcDesc );
// Create and set a render target
PushRenderTarget( 0L, CreateRenderTarget( pDstTexture ) );
// Get the sample offsets used within the pixel shader
XMVECTOR avSampleOffsets[MAX_SAMPLES];
GetSampleOffsets_DownScale4x4( SrcDesc.Width, SrcDesc.Height, avSampleOffsets );
g_pd3dDevice->SetPixelShaderConstantF( PSCONST_avSampleOffsets, ( FLOAT* )avSampleOffsets, MAX_SAMPLES );
g_pd3dDevice->SetPixelShader( m_pDownScale4x4PS );
g_pd3dDevice->SetTexture( 0, pSrcTexture );
g_pd3dDevice->SetSamplerState( 0, D3DSAMP_MINFILTER, D3DTEXF_POINT );
g_pd3dDevice->SetSamplerState( 0, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP );
g_pd3dDevice->SetSamplerState( 0, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP );
// Draw a fullscreen quad
DrawFullScreenQuad();
g_pd3dDevice->Resolve( D3DRESOLVE_RENDERTARGET0, NULL, pDstTexture, NULL,
0, 0, NULL, 1.0f, 0L, NULL );
// Cleanup and return
PopRenderTarget( 0L )->Release();
g_pd3dDevice->SetPixelShader( NULL );
}
示例2: CreateDeviceD3D
HRESULT CreateDeviceD3D(HWND hWnd)
{
// Setup swap chain
DXGI_SWAP_CHAIN_DESC sd;
ZeroMemory(&sd, sizeof(sd));
sd.BufferCount = 2;
sd.BufferDesc.Width = 0;
sd.BufferDesc.Height = 0;
sd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
sd.BufferDesc.RefreshRate.Numerator = 60;
sd.BufferDesc.RefreshRate.Denominator = 1;
sd.Flags = DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH;
sd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
sd.OutputWindow = hWnd;
sd.SampleDesc.Count = 1;
sd.SampleDesc.Quality = 0;
sd.Windowed = TRUE;
sd.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;
UINT createDeviceFlags = 0;
//createDeviceFlags |= D3D10_CREATE_DEVICE_DEBUG;
if (D3D10CreateDeviceAndSwapChain(NULL, D3D10_DRIVER_TYPE_HARDWARE, NULL, createDeviceFlags, D3D10_SDK_VERSION, &sd, &g_pSwapChain, &g_pd3dDevice) != S_OK)
return E_FAIL;
CreateRenderTarget();
return S_OK;
}
示例3: OnD3D10SwapChainResized
//--------------------------------------------------------------------------------------
// Create any D3D10 resources that depend on the back buffer
//--------------------------------------------------------------------------------------
HRESULT CALLBACK OnD3D10SwapChainResized( ID3D10Device* pd3dDevice, IDXGISwapChain* pSwapChain,
const DXGI_SURFACE_DESC* pBackBufferSurfaceDesc, void* pUserContext )
{
HRESULT hr = S_OK;
V_RETURN( g_DialogResourceManager.OnD3D10ResizedSwapChain( pd3dDevice, pBackBufferSurfaceDesc ) );
V_RETURN( g_D3DSettingsDlg.OnD3D10ResizedSwapChain( pd3dDevice, pBackBufferSurfaceDesc ) );
// Setup the camera's projection parameters
float fAspectRatio = pBackBufferSurfaceDesc->Width / ( FLOAT )pBackBufferSurfaceDesc->Height;
g_Camera.SetProjParams( 60.0f * ( D3DX_PI / 180.0f ), fAspectRatio, 0.1f, 100.0f );
g_Camera.SetWindow( pBackBufferSurfaceDesc->Width, pBackBufferSurfaceDesc->Height );
g_Camera.SetButtonMasks( MOUSE_LEFT_BUTTON, MOUSE_WHEEL, MOUSE_MIDDLE_BUTTON );
g_HUD.SetLocation( pBackBufferSurfaceDesc->Width - 170, 0 );
g_HUD.SetSize( 170, 170 );
g_SampleUI.SetLocation( pBackBufferSurfaceDesc->Width - 170, pBackBufferSurfaceDesc->Height - 300 );
g_SampleUI.SetSize( 170, 300 );
// Update the sample count
UpdateMSAASampleCounts( pd3dDevice, pBackBufferSurfaceDesc->Format );
// Create a render target
g_BackBufferWidth = pBackBufferSurfaceDesc->Width;
g_BackBufferHeight = pBackBufferSurfaceDesc->Height;
V_RETURN( CreateRenderTarget( pd3dDevice, g_BackBufferWidth, g_BackBufferHeight, g_MSAASampleCount, 0 ) );
return hr;
}
示例4: Texture
bool GSDevice10::CopyOffscreen(Texture& src, const GSVector4& sr, Texture& dst, int w, int h, int format)
{
dst = Texture();
if(format == 0)
{
format = DXGI_FORMAT_R8G8B8A8_UNORM;
}
if(format != DXGI_FORMAT_R8G8B8A8_UNORM && format != DXGI_FORMAT_R16_UINT)
{
ASSERT(0);
return false;
}
Texture rt;
if(CreateRenderTarget(rt, w, h, format))
{
GSVector4 dr(0, 0, w, h);
StretchRect(src, sr, rt, dr, m_convert.ps[format == DXGI_FORMAT_R16_UINT ? 1 : 0], NULL);
if(CreateOffscreen(dst, w, h, format))
{
m_dev->CopyResource(dst, rt);
}
}
Recycle(rt);
return !!dst;
}
示例5: WndProc
LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
if (ImGui_ImplWin32_WndProcHandler(hWnd, msg, wParam, lParam))
return true;
switch (msg)
{
case WM_SIZE:
if (g_pd3dDevice != NULL && wParam != SIZE_MINIMIZED)
{
ImGui_ImplDX10_InvalidateDeviceObjects();
CleanupRenderTarget();
g_pSwapChain->ResizeBuffers(0, (UINT)LOWORD(lParam), (UINT)HIWORD(lParam), DXGI_FORMAT_UNKNOWN, 0);
CreateRenderTarget();
ImGui_ImplDX10_CreateDeviceObjects();
}
return 0;
case WM_SYSCOMMAND:
if ((wParam & 0xfff0) == SC_KEYMENU) // Disable ALT application menu
return 0;
break;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
}
return DefWindowProc(hWnd, msg, wParam, lParam);
}
示例6: SAFE_RELEASE
//------------------------------------------------------------------------------------------
bool CGraphicDevice::Reset(int i_nWidth, int i_nHeight )
{
HRESULT hr;
// サーフェースの破棄
SAFE_RELEASE( m_pd3dSurface9 );
// デバイスのリセット
// Presentation Parameter の初期化
m_d3dpp.BackBufferWidth = i_nWidth;
m_d3dpp.BackBufferHeight = i_nHeight;
hr = m_pd3dDevice9->Reset( &m_d3dpp );
MY_ASSERT( SUCCEEDED(hr) );
// サーフェースを新しいサイズで再作成
bool ret = CreateRenderTarget( i_nWidth, i_nHeight );
MY_ASSERT( ret );
m_nWidth = i_nWidth;
m_nHeight = i_nHeight;
// ビューポートの設定
m_viewport.X = 0;
m_viewport.Y = 0;
m_viewport.Width = i_nWidth;
m_viewport.Height = i_nHeight;
m_viewport.MinZ = 0.0f;
m_viewport.MaxZ = 1.0f;
return ret;
}
示例7: Render
void Render()
{
if (!m_renderTarget)
{
auto d3dDevice = CreateD3D11Device();
m_renderTarget = CreateRenderTarget(m_d2dFactory, d3dDevice);
m_swapChain = CreateSwapChainForHwnd(d3dDevice, __super::m_hWnd);
CreateDeviceSwapChainBitmap(m_swapChain, m_renderTarget);
static_cast<T *>(this)->CreateDeviceResources();
static_cast<T *>(this)->CreateDeviceSizeResources();
}
m_renderTarget->BeginDraw();
// NOTE: no fallback is provided in this base class so all derived classes must implement this
static_cast<T *>(this)->Draw();
m_renderTarget->EndDraw();
auto const hr = m_swapChain->Present(1, 0);
if (S_OK != hr && DXGI_STATUS_OCCLUDED != hr)
{
ReleaseDevices();
}
}
示例8: OnGUIEvent
//--------------------------------------------------------------------------------------
// Handles the GUI events
//--------------------------------------------------------------------------------------
void CALLBACK OnGUIEvent( UINT nEvent, int nControlID, CDXUTControl* pControl, void* pUserContext )
{
switch( nControlID )
{
case IDC_TOGGLEFULLSCREEN:
DXUTToggleFullScreen(); break;
case IDC_TOGGLEREF:
DXUTToggleREF(); break;
case IDC_CHANGEDEVICE:
g_D3DSettingsDlg.SetActive( !g_D3DSettingsDlg.IsActive() ); break;
case IDC_TOGGLEWARP:
DXUTToggleWARP(); break;
case IDC_TOGGLE_BLUR:
g_bUseMotionBlur = !g_bUseMotionBlur;
break;
case IDC_RENDER_OGRE:
g_bRenderOgre = !g_bRenderOgre;
break;
case IDC_SAMPLE_COUNT:
{
CDXUTComboBox* pComboBox = ( CDXUTComboBox* )pControl;
g_MSAASampleCount = ( UINT )PtrToInt( pComboBox->GetSelectedData() );
HRESULT hr = S_OK;
ID3D10Device* pd3dDevice = DXUTGetD3D10Device();
if( pd3dDevice )
V( CreateRenderTarget( pd3dDevice, g_BackBufferWidth, g_BackBufferHeight, g_MSAASampleCount, 0 ) );
}
break;
}
}
示例9: CreateRenderTarget
void VScaleformTexture::OnLeaveBackground()
{
if (IsLoaded())
CreateRenderTarget();
if (m_spContext != NULL)
m_spContext->SetRenderTarget(0, m_spRenderTarget);
}
示例10: CreateRenderTarget
void GSDevice::Interlace(const GSVector2i& ds, int field, int mode, float yoffset)
{
if(m_weavebob == NULL || m_weavebob->GetSize() != ds)
{
delete m_weavebob;
m_weavebob = CreateRenderTarget(ds.x, ds.y, false);
}
if(mode == 0 || mode == 2) // weave or blend
{
// weave first
DoInterlace(m_merge, m_weavebob, field, false, 0);
if(mode == 2)
{
// blend
if(m_blend == NULL || m_blend->GetSize() != ds)
{
delete m_blend;
m_blend = CreateRenderTarget(ds.x, ds.y, false);
}
DoInterlace(m_weavebob, m_blend, 2, false, 0);
m_current = m_blend;
}
else
{
m_current = m_weavebob;
}
}
else if(mode == 1) // bob
{
DoInterlace(m_merge, m_weavebob, 3, true, yoffset * field);
m_current = m_weavebob;
}
else
{
m_current = m_merge;
}
}
示例11: CreateDeviceAndSwapChain
void GraphicsDevice::Initialize(void)
{
CreateDeviceAndSwapChain();
CreateRenderTarget();
SetViewPort();
m_pD3DDevice->OMSetRenderTargets(1, &m_pRenderTarget->GetRenderTargetView(), m_pRenderTarget->GetDepthStencilView() );
}
示例12:
HRESULT BaseButton::CreateD2DResources()
{
HRESULT hr=S_OK;
//const wchar_t uriOpen[]=L"D:\play4.jpg";
if(!m_pRenderTarget)
hr=CreateRenderTarget();
return hr;
}
示例13: Direct3DCreate9
//------------------------------------------------------------------------------------------
bool CGraphicDevice::Initialize(int i_nWidth, int i_nHeight)
{
HRESULT hr = S_OK;
// D3Dオブジェクトの作成
m_pd3d9 = Direct3DCreate9(D3D_SDK_VERSION);
if( !m_pd3d9 )
{
return false;
}
// ダミーウィンドウを作成
if( CreateDummyWindow() == false )
{
return false;
}
// デバイスを作成
if( CreateDevice(i_nWidth, i_nHeight) == false )
{
return false;
}
// レンダーターゲットの作成
if( CreateRenderTarget(i_nWidth, i_nHeight) == false )
{
return false;
}
/// 全てに成功 ///
m_nWidth = i_nWidth;
m_nHeight = i_nHeight;
// ビューポートの設定
m_viewport.X = 0;
m_viewport.Y = 0;
m_viewport.Width = i_nWidth;
m_viewport.Height = i_nHeight;
m_viewport.MinZ = 0.0f;
m_viewport.MaxZ = 1.0f;
// トランスフォームの初期化(単位行列化)
for(int i = 0; i < TransformType_Max; ++i)
{
D3DXMatrixIdentity( &m_mTransform[i] );
}
// シェーダ管理の初期化
shader::CShaderMan::CreateInstance();
shader::CShaderMan::GetInstance()->Initialize();
m_bValid = true;
return true;
}
示例14: CreateDeviceD3D
HRESULT CreateDeviceD3D(HWND hWnd)
{
// Setup swap chain
DXGI_SWAP_CHAIN_DESC sd;
{
ZeroMemory(&sd, sizeof(sd));
sd.BufferCount = 2;
sd.BufferDesc.Width = 0;
sd.BufferDesc.Height = 0;
sd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
sd.BufferDesc.RefreshRate.Numerator = 60;
sd.BufferDesc.RefreshRate.Denominator = 1;
sd.Flags = DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH;
sd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
sd.OutputWindow = hWnd;
sd.SampleDesc.Count = 1;
sd.SampleDesc.Quality = 0;
sd.Windowed = TRUE;
sd.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;
}
UINT createDeviceFlags = 0;
#ifdef _DEBUG
createDeviceFlags |= D3D11_CREATE_DEVICE_DEBUG;
#endif
D3D_FEATURE_LEVEL featureLevel;
const D3D_FEATURE_LEVEL featureLevelArray[1] = { D3D_FEATURE_LEVEL_11_0, };
if (D3D11CreateDeviceAndSwapChain(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, createDeviceFlags, featureLevelArray, 1, D3D11_SDK_VERSION, &sd, &g_pSwapChain, &g_pd3dDevice, &featureLevel, &g_pd3dDeviceContext) != S_OK)
return E_FAIL;
// Setup rasterizer
{
D3D11_RASTERIZER_DESC RSDesc;
memset(&RSDesc, 0, sizeof(D3D11_RASTERIZER_DESC));
RSDesc.FillMode = D3D11_FILL_SOLID;
RSDesc.CullMode = D3D11_CULL_NONE;
RSDesc.FrontCounterClockwise = FALSE;
RSDesc.DepthBias = 0;
RSDesc.SlopeScaledDepthBias = 0.0f;
RSDesc.DepthBiasClamp = 0;
RSDesc.DepthClipEnable = TRUE;
RSDesc.ScissorEnable = TRUE;
RSDesc.AntialiasedLineEnable = FALSE;
RSDesc.MultisampleEnable = (sd.SampleDesc.Count > 1) ? TRUE : FALSE;
ID3D11RasterizerState* pRState = NULL;
g_pd3dDevice->CreateRasterizerState(&RSDesc, &pRState);
g_pd3dDeviceContext->RSSetState(pRState);
pRState->Release();
}
CreateRenderTarget();
return S_OK;
}
示例15: RiftSetup
void RiftSetup()
{
ovr_Initialize();
s_hmd = ovrHmd_Create(0);
if (!s_hmd)
{
s_hmd = ovrHmd_CreateDebug(ovrHmd_DK1);
}
ovrHmd_GetDesc(s_hmd, &s_hmdDesc);
DumpHMDInfo(s_hmdDesc);
uint32_t supportedSensorCaps = ovrSensorCap_Orientation;
uint32_t requiredSensorCaps = ovrSensorCap_Orientation;
ovrBool success = ovrHmd_StartSensor(s_hmd, supportedSensorCaps, requiredSensorCaps);
if (!success) {
fprintf(stderr, "ERROR: HMD does not have required capabilities!\n");
exit(2);
}
// Figure out dimensions of render target
ovrSizei recommenedTex0Size = ovrHmd_GetFovTextureSize(s_hmd, ovrEye_Left, s_hmdDesc.DefaultEyeFov[0], 1.0f);
ovrSizei recommenedTex1Size = ovrHmd_GetFovTextureSize(s_hmd, ovrEye_Right, s_hmdDesc.DefaultEyeFov[1], 1.0f);
s_renderTargetSize.w = recommenedTex0Size.w + recommenedTex1Size.w;
s_renderTargetSize.h = std::max(recommenedTex0Size.h, recommenedTex1Size.h);
CreateRenderTarget(s_renderTargetSize.w, s_renderTargetSize.h);
s_eyeTexture[0].Header.API = ovrRenderAPI_OpenGL;
s_eyeTexture[0].Header.TextureSize = s_renderTargetSize;
s_eyeTexture[0].Header.RenderViewport.Pos = {0, 0};
s_eyeTexture[0].Header.RenderViewport.Size = {s_renderTargetSize.w / 2, s_renderTargetSize.h};
((ovrGLTexture*)(&s_eyeTexture[0]))->OGL.TexId = s_fboTex;
s_eyeTexture[1].Header.API = ovrRenderAPI_OpenGL;
s_eyeTexture[1].Header.TextureSize = s_renderTargetSize;
s_eyeTexture[1].Header.RenderViewport.Pos = {s_renderTargetSize.w / 2, 0};
s_eyeTexture[1].Header.RenderViewport.Size = {s_renderTargetSize.w / 2, s_renderTargetSize.h};
((ovrGLTexture*)(&s_eyeTexture[1]))->OGL.TexId = s_fboTex;
// Configure ovr SDK Rendering
ovrGLConfig cfg;
memset(&cfg, 0, sizeof(ovrGLConfig));
cfg.OGL.Header.API = ovrRenderAPI_OpenGL;
cfg.OGL.Header.RTSize = {s_config->width, s_config->height};
cfg.OGL.Header.Multisample = 0;
// TODO: on windows need to set HWND, on Linux need to set other parameters
if (!ovrHmd_ConfigureRendering(s_hmd, &cfg.Config, s_hmdDesc.DistortionCaps, s_hmdDesc.DefaultEyeFov, s_eyeRenderDesc))
{
fprintf(stderr, "ERROR: HMD configure rendering failed!\n");
exit(3);
}
}