D3D11能不能mysql 创建数据库USAGE是STAGING的ID3D11Texture2D

【Visual C++】游戏开发笔记 DirectX11 2D纹理映射知识全攻略_图文_百度文库
两大类热门资源免费畅读
续费一年阅读会员,立省24元!
【Visual C++】游戏开发笔记 DirectX11 2D纹理映射知识全攻略
&&Visual C++ 游戏开发 DirectX11 2D纹理映射知识全攻略
阅读已结束,如果下载本文需要使用0下载券
想免费下载更多文档?
定制HR最喜欢的简历
下载文档到电脑,查找使用更方便
还剩32页未读,继续阅读
定制HR最喜欢的简历
你可能喜欢>> DXGIManager.cpp
DXGIManager.cpp ( 文件浏览 )
#include &stdafx.h&
#include &DXGIManager.h&
#include &gdiplus.h&
using namespace G
DXGIPointerInfo::DXGIPointerInfo(BYTE* pPointerShape, UINT uiPointerShapeBufSize, DXGI_OUTDUPL_FRAME_INFO fi, DXGI_OUTDUPL_POINTER_SHAPE_INFO psi)
: m_pPointerShape(pPointerShape),
m_uiPointerShapeBufSize(uiPointerShapeBufSize),
m_PSI(psi)
DXGIPointerInfo::~DXGIPointerInfo()
if(m_pPointerShape)
delete [] m_pPointerS
BYTE* DXGIPointerInfo::GetBuffer()
return m_pPointerS
UINT DXGIPointerInfo::GetBufferSize()
return m_uiPointerShapeBufS
DXGI_OUTDUPL_FRAME_INFO& DXGIPointerInfo::GetFrameInfo()
return m_FI;
DXGI_OUTDUPL_POINTER_SHAPE_INFO& DXGIPointerInfo::GetShapeInfo()
return m_PSI;
DXGIOutputDuplication::DXGIOutputDuplication(IDXGIAdapter1* pAdapter,
ID3D11Device* pD3DDevice,
ID3D11DeviceContext* pD3DDeviceContext,
IDXGIOutput1* pDXGIOutput1,
IDXGIOutputDuplication* pDXGIOutputDuplication)
: m_Adapter(pAdapter),
m_D3DDevice(pD3DDevice),
m_D3DDeviceContext(pD3DDeviceContext),
m_DXGIOutput1(pDXGIOutput1),
m_DXGIOutputDuplication(pDXGIOutputDuplication)
HRESULT DXGIOutputDuplication::GetDesc(DXGI_OUTPUT_DESC& desc)
m_DXGIOutput1-&GetDesc(&desc);
return S_OK;
HRESULT DXGIOutputDuplication::AcquireNextFrame(IDXGISurface1** pDXGISurface, DXGIPointerInfo*& pDXGIPointer)
DXGI_OUTDUPL_FRAME_INFO
CComPtr&IDXGIResource& spDXGIR
HRESULT hr = m_DXGIOutputDuplication-&AcquireNextFrame(20, &fi, &spDXGIResource);
if(FAILED(hr))
__L_INFO(&m_DXGIOutputDuplication-&AcquireNextFrame failed with hr=0x%08x&, hr);
CComQIPtr&ID3D11Texture2D& spTextureResource = spDXGIR
D3D11_TEXTURE2D_DESC
spTextureResource-&GetDesc(&desc);
D3D11_TEXTURE2D_DESC texD
ZeroMemory( &texDesc, sizeof(texDesc) );
texDesc.Width = desc.W
texDesc.Height = desc.H
texDesc.MipLevels = 1;
texDesc.ArraySize = 1;
texDesc.SampleDesc.Count = 1;
texDesc.SampleDesc.Quality = 0;
texDesc.Usage = D3D11_USAGE_STAGING;
texDesc.Format = desc.F
texDesc.BindFlags = 0;
texDesc.CPUAccessFlags = D3D11_CPU_ACCESS_READ;
texDesc.MiscFlags = 0;
CComPtr&ID3D11Texture2D& spD3D11Texture2D = NULL;
hr = m_D3DDevice-&CreateTexture2D(&texDesc, NULL, &spD3D11Texture2D);
if(FAILED(hr))
m_D3DDeviceContext-&CopyResource(spD3D11Texture2D, spTextureResource);
CComQIPtr&IDXGISurface1& spDXGISurface = spD3D11Texture2D;
*pDXGISurface = spDXGISurface.Detach();
// Updating mouse pointer, if visible
if(fi.PointerPosition.Visible)
BYTE* pPointerShape = new BYTE[fi.PointerShapeBufferSize];
DXGI_OUTDUPL_POINTER_SHAPE_INFO psi = {
UINT uiPointerShapeBufSize = fi.PointerShapeBufferS
hr = m_DXGIOutputDuplication-&GetFramePointerShape(uiPointerShapeBufSize, pPointerShape, &uiPointerShapeBufSize, &psi);
if(hr == DXGI_ERROR_MORE_DATA)
pPointerShape = new BYTE[uiPointerShapeBufSize];
hr = m_DXGIOutputDuplication-&GetFramePointerShape(uiPointerShapeBufSize, pPointerShape, &uiPointerShapeBufSize, &psi);
if(hr == S_OK)
__L_INFO(&PointerPosition Visible=%d x=%d y=%d w=%d h=%d type=%d\n&, fi.PointerPosition.Visible, fi.PointerPosition.Position.x, fi.PointerPosition.Position.y, psi.Width, psi.Height, psi.Type);
if((psi.Type == DXGI_OUTDUPL_POINTER_SHAPE_TYPE_MONOCHROME ||
psi.Type == DXGI_OUTDUPL_POINTER_SHAPE_TYPE_COLOR ||
psi.Type == DXGI_OUTDUPL_POINTER_SHAPE_TYPE_MASKED_COLOR) &&
psi.Width &= 128 && psi.Height &= 128)
// Here we can obtain pointer shape
if(pDXGIPointer)
delete pDXGIP
pDXGIPointer = new DXGIPointerInfo(pPointerShape, uiPointerShapeBufSize, fi, psi);
pPointerShape = NULL;
DXGI_OUTPUT_DESC outD
GetDesc(outDesc);
if(pDXGIPointer)
pDXGIPointer-&GetFrameInfo().PointerPosition.Position.x = outDesc.DesktopCoordinates.left + fi.PointerPosition.Position.x;
pDXGIPointer-&GetFrameInfo().PointerPosition.Position.y = outDesc.DesktopCoordinates.top + fi.PointerPosition.Position.y;
if(pPointerShape)
delete [] pPointerS
HRESULT DXGIOutputDuplication::ReleaseFrame()
m_DXGIOutputDuplication-&ReleaseFrame();
return S_OK;
bool DXGIOutputDuplication::IsPrimary()
DXGI_OUTPUT_DESC
m_DXGIOutput1-&GetDesc(&outdesc);
MONITORINFO
mi.cbSize = sizeof(MONITORINFO);
GetMonitorInfo(outdesc.Monitor, &mi);
if(mi.dwFlags & MONITORINFOF_PRIMARY)
DXGIManager::DXGIManager()
m_CaptureSource = CSU
SetRect(&m_rcCurrentOutput, 0, 0, 0, 0);
m_pBuf = NULL;
m_pDXGIPointer = NULL;
m_bInitialized =
DXGIManager::~DXGIManager()
GdiplusShutdown(m_gdiplusToken);
if(m_pBuf)
delete [] m_pB
m_pBuf = NULL;
if(m_pDXGIPointer)
delete m_pDXGIP
m_pDXGIPointer = NULL;
HRESULT DXGIManager::SetCaptureSource(CaptureSource cs)
m_CaptureSource =
return S_OK;
CaptureSource DXGIManager::GetCaptureSource()
return m_CaptureS
HRESULT DXGIManager::Init()
if(m_bInitialized)
return S_OK;
GdiplusStartupInput gdiplusStartupI
GdiplusStartup(&m_gdiplusToken, &gdiplusStartupInput, NULL);
HRESULT hr = CreateDXGIFactory1(__uuidof(IDXGIFactory1), (void**)(&m_spDXGIFactory1) );
if( FAILED(hr) )
__L_ERROR(&Failed to CreateDXGIFactory1 hr=%08x&, hr);
// Getting all adapters
vector&CComPtr&IDXGIAdapter1&& vA
CComPtr&IDXGIAdapter1& spA
for(int i=0; m_spDXGIFactory1-&EnumAdapters1(i, &spAdapter) != DXGI_ERROR_NOT_FOUND; i++)
vAdapters.push_back(spAdapter);
spAdapter.Release();
// Iterating over all adapters to get all outputs
for(vector&CComPtr&IDXGIAdapter1&&::iterator AdapterIter = vAdapters.begin();
AdapterIter != vAdapters.end();
AdapterIter++)
vector&CComPtr&IDXGIOutput&& vO
CComPtr&IDXGIOutput& spDXGIO
for(int i=0; (*AdapterIter)-&EnumOutputs(i, &spDXGIOutput) != DXGI_ERROR_NOT_FOUND; i++)
DXGI_OUTPUT_DESC outputD
spDXGIOutput-&GetDesc(&outputDesc);
__L_INFO(&Display output found. DeviceName=%ls
AttachedToDesktop=%d Rotation=%d DesktopCoordinates={
(%d,%d),(%d,%d)
outputDesc.DeviceName,
outputDesc.AttachedToDesktop,
outputDesc.Rotation,
outputDesc.DesktopCoordinates.left,
outputDesc.DesktopCoordinates.top,
outputDesc.DesktopCoordinates.right,
outputDesc.DesktopCoordinates.bottom);
if(outputDesc.AttachedToDesktop)
vOutputs.push_back(spDXGIOutput);
spDXGIOutput.Release();
if(vOutputs.size() == 0)
// Creating device for each adapter that has the output
CComPtr&ID3D11Device& spD3D11D
CComPtr&ID3D11DeviceContext& spD3D11DeviceC
D3D_FEATURE_LEVEL fl = D3D_FEATURE_LEVEL_9_1;
hr = D3D11CreateDevice((*AdapterIter), D3D_DRIVER_TYPE_UNKNOWN, NULL, 0, NULL, 0, D3D11_SDK_VERSION, &spD3D11Device, &fl, &spD3D11DeviceContext);
if( FAILED(hr) )
__L_ERROR(&Failed to create D3D11CreateDevice hr=%08x&, hr);
for(std::vector&CComPtr&IDXGIOutput&&::iterator OutputIter = vOutputs.begin();
OutputIter != vOutputs.end();
OutputIter++)
CComQIPtr&IDXGIOutput1& spDXGIOutput1 = *OutputI
CComQIPtr&IDXGIDevice1& spDXGIDevice = spD3D11D
if(!spDXGIOutput1 || !spDXGIDevice)
CComPtr&IDXGIOutputDuplication& spDXGIOutputD
hr = spDXGIOutput1-&DuplicateOutput(spDXGIDevice, &spDXGIOutputDuplication);
if( FAILED(hr) )
m_vOutputs.push_back(
DXGIOutputDuplication((*AdapterIter),
spD3D11Device,
spD3D11DeviceContext,
spDXGIOutput1,
spDXGIOutputDuplication));
hr = m_spWICFactory.CoCreateInstance(CLSID_WICImagingFactory);
if( FAILED(hr) )
__L_ERROR(&Failed to create WICImagingFactory hr=%08x&, hr);
m_bInitialized =
return S_OK;
HRESULT DXGIManager::GetOutputRect(RECT& rc)
// Nulling rc just in case...
SetRect(&rc, 0, 0, 0, 0);
HRESULT hr = Init();
if(hr != S_OK)
vector&DXGIOutputDuplication& vOutputs = GetOutputDuplication();
SetRect(&rcShare, 0, 0, 0, 0);
for(vector&DXGIOutputDuplication&::iterator iter = vOutputs.begin();
iter != vOutputs.end();
DXGIOutputDuplication& out = *
DXGI_OUTPUT_DESC outD
out.GetDesc(outDesc);
RECT rcOutCoords = outDesc.DesktopC
UnionRect(&rcShare, &rcShare, &rcOutCoords);
CopyRect(&rc, &rcShare);
return S_OK;
HRESULT DXGIManager::GetOutputBits(BYTE* pBits, RECT& rcDest)
HRESULT hr = S_OK;
DWORD dwDestWidth = rcDest.right - rcDest.
DWORD dwDestHeight = rcDest.bottom - rcDest.
hr = GetOutputRect(rcOutput);
if( FAILED(hr) )
DWORD dwOutputWidth = rcOutput.right - rcOutput.
DWORD dwOutputHeight = rcOutput.bottom - rcOutput.
BYTE* pBuf = NULL;
if(rcOutput.right & (LONG)dwDestWidth || rcOutput.bottom & (LONG)dwDestHeight)
// Output is larger than pBits dimensions
if(!m_pBuf || !EqualRect(&m_rcCurrentOutput, &rcOutput))
DWORD dwBufSize = dwOutputWidth*dwOutputHeight*4;
if(m_pBuf)
delete [] m_pB
m_pBuf = NULL;
m_pBuf = new BYTE[dwBufSize];
CopyRect(&m_rcCurrentOutput, &rcOutput);
pBuf = m_pB
// Output is smaller than pBits dimensions
dwOutputWidth = dwDestW
dwOutputHeight = dwDestH
vector&DXGIOutputDuplication& vOutputs = GetOutputDuplication();
for(vector&DXGIOutputDuplication&::iterator iter = vOutputs.begin();
iter != vOutputs.end();
DXGIOutputDuplication& out = *
DXGI_OUTPUT_DESC outD
out.GetDesc(outDesc);
RECT rcOutCoords = outDesc.DesktopC
CComPtr&IDXGISurface1& spDXGISurface1;
hr = out.AcquireNextFrame(&spDXGISurface1, m_pDXGIPointer);
if( FAILED(hr) )
DXGI_MAPPED_RECT
spDXGISurface1-&Map(&map, DXGI_MAP_READ);
RECT rcDesktop = outDesc.DesktopC
DWORD dwWidth = rcDesktop.right - rcDesktop.
DWORD dwHeight = rcDesktop.bottom
(文件超长,未完全显示,请下载后阅读剩余部分)
展开> <收缩
下载源码到电脑,阅读使用更方便
还剩0行未阅读,继续阅读 ▼
Sponsored links
源码文件列表
温馨提示: 点击源码文件名可预览文件内容哦 ^_^
DXGICaptureSample.sln900.00 B 17:54
DXGICaptureSample.suo9.00 kB 17:54
DXGICaptureSample.vcxproj5.43 kB 16:07
DXGICaptureSample.vcxproj.filters1.40 kB 03:12
DXGICaptureSample.vcxproj.user143.00 B 14:37
18.08 kB 03:12
2.09 kB 16:10
296.00 B 03:12
833.00 B 03:12
306.00 B 03:12
Sponsored links
评价成功,多谢!
下载DXGICaptureSample.zip
CodeForge积分(原CF币)全新升级,功能更强大,使用更便捷,不仅可以用来下载海量源代码马上还可兑换精美小礼品了
您的积分不足
支付宝优惠套餐快速获取 30 积分
10积分 / ¥100
30积分 / ¥200原价 ¥300 元
100积分 / ¥500原价 ¥1000 元
订单支付完成后,积分将自动加入到您的账号。以下是优惠期的人民币价格,优惠期过后将恢复美元价格。
支付宝支付宝付款
微信钱包微信付款
更多付款方式:、
您本次下载所消耗的积分将转交上传作者。
同一源码,30天内重复下载,只扣除一次积分。
鲁ICP备号-3 runtime:Elapsed:32.324ms 5.8
登录 CodeForge
还没有CodeForge账号?
Switch to the English version?
^_^"呃 ...
Sorry!这位大神很神秘,未开通博客呢,请浏览一下其他的吧Sort Discussions:
Page 1 of 1 (2 posts)
[DX11] Render a simple ID3D11Texture2D
Last post 4/6/ PM by . 1 replies.
[DX11] Render a simple ID3D11Texture2D
I am trying set up a deferred shading class.
But i am not able to bin the Texture2D to the shader.
First i create a Renter Target and then i render the Color.
Second i set the Backbuffer as RT and i try to render the ColorTexture to the screen.
Here is the code:
void Mesh::InitShaderResourceView()
D3D11_TEXTURE2D_DESC texD
memset(&texDesc,0,sizeof(D3D11_TEXTURE2D_DESC));
texDesc.Width
texDesc.Height
texDesc.Format
= DXGI_FORMAT_R8G8B8A8_UNORM;
texDesc.MipLevels = 1;
texDesc.ArraySize = 1;
texDesc.SampleDesc.Count = 1;
texDesc.Usage = D3D11_USAGE_IMMUTABLE;
texDesc.BindFlags
= D3D11_BIND_SHADER_RESOURCE;
D3D11_RENDER_TARGET_VIEW_DESC renderTargetViewD
renderTargetViewDesc.Format = texDesc.F
renderTargetViewDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D;
renderTargetViewDesc.Texture2D.MipSlice = 0;
RAWGraphic.GetDevice()-&CreateTexture2D( &texDesc, 0, &NormalTex ) ;
RAWLog.FunctionResult(&GetBuffer&,RAWGraphic.GetSwapChain()-&GetBuffer( 0, __uuidof( ID3D11Texture2D ), ( LPVOID* )&NormalTex ));
RAWLog.FunctionResult(&CreateRenderTargetView&,RAWGraphic-&CreateRenderTargetView( NormalTex, &renderTargetViewDesc, &pRenderTargetView));
D3D11_SHADER_RESOURCE_VIEW_DESC srv_
memset(&srv_desc,0,sizeof(D3D11_SHADER_RESOURCE_VIEW_DESC));
srv_desc.Format=texDesc.F
srv_desc.ViewDimension=D3D11_SRV_DIMENSION_TEXTURE2D;
srv_desc.Texture2D.MipLevels=texDesc.MipL
RAWGraphic.GetDevice()-&CreateShaderResourceView(NormalTex,&srv_desc,&SRV);
D3D11_SAMPLER_DESC samplerD
samplerDesc.Filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR;
samplerDesc.AddressU = D3D11_TEXTURE_ADDRESS_WRAP;
samplerDesc.AddressV = D3D11_TEXTURE_ADDRESS_WRAP;
samplerDesc.AddressW = D3D11_TEXTURE_ADDRESS_WRAP;
samplerDesc.MipLODBias = 0.0f;
samplerDesc.MaxAnisotropy = 1;
parisonFunc = D3D11_COMPARISON_ALWAYS;
samplerDesc.BorderColor[0] = 0;
samplerDesc.BorderColor[1] = 0;
samplerDesc.BorderColor[2] = 0;
samplerDesc.BorderColor[3] = 0;
samplerDesc.MinLOD = 0;
samplerDesc.MaxLOD = D3D11_FLOAT32_MAX;
// Create the texture sampler state.
RAWGraphic.GetDevice()-&CreateSamplerState(&samplerDesc, &sampler);
RAWGraphic.GetContext()-&OMSetRenderTargets( 1, &pRenderTargetView, NULL );
float col[4] = {0.0f, 1.0f, 0.0f, 1.0f};
RAWGraphic.GetContext()-&ClearRenderTargetView(pRenderTargetView, col);
RAWGraphic.GetContext()-&VSSetShader( m_sColor.VS, NULL, 0);
RAWGraphic.GetContext()-&PSSetShader( m_sColor.PS, NULL, 0);
RAWGraphic.GetContext()-&VSSetConstantBuffers( 0, 1, &MatrixBuffer);
RAWGraphic.GetContext()-&PSSetShaderResources( 0, 1,&TextureSRV);
RAWGraphic.GetContext()-&PSSetSamplers( 0, 1, &pSamplerLinear);
RenderBuffer();
void Mesh::Draw()
DeferredShading();
float col[4] = {1.0f, 1.0f, 1.0f, 1.0f};
RAWGraphic.GetContext()-&ClearRenderTargetView(RAWGraphic.GetRTV(), col);
RAWGraphic.GetContext()-&VSSetShader( m_sTexture.VS, NULL, 0);
RAWGraphic.GetContext()-&PSSetShader( m_sTexture.PS, NULL, 0);
RAWGraphic.GetContext()-&VSSetConstantBuffers( 0, 1, &MatrixBuffer);
RAWGraphic.GetContext()-&PSSetShaderResources( 0, 1,&SRV);
RAWGraphic.GetContext()-&PSSetSamplers( 0, 1, &sampler);
RenderBuffer();
Re: [DX11] Render a simple ID3D11Texture2D
I am new, is there no way to format the text.
So it looks horrible :S
Page 1 of 1 (2 posts)
All rights reserved鏌ョ湅: 2415|鍥炲?: 6
褰撳墠绂荤嚎

我要回帖

更多关于 linux 创建文件 的文章

 

随机推荐