本文整理汇总了C++中D3DX11CreateShaderResourceViewFromFile函数的典型用法代码示例。如果您正苦于以下问题:C++ D3DX11CreateShaderResourceViewFromFile函数的具体用法?C++ D3DX11CreateShaderResourceViewFromFile怎么用?C++ D3DX11CreateShaderResourceViewFromFile使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了D3DX11CreateShaderResourceViewFromFile函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ZeroMemory
void CloudShader::createBuffers(ID3D11Device* pd3dDevice)
{
// Create the 3 constant buffers, using the same buffer descriptor to create all three
D3D11_BUFFER_DESC Desc;
ZeroMemory(&Desc, sizeof(Desc));
Desc.Usage = D3D11_USAGE_DEFAULT;
Desc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
Desc.CPUAccessFlags = 0;
Desc.MiscFlags = 0;
Desc.ByteWidth = sizeof(CB_VS_PER_OBJECT);
pd3dDevice->CreateBuffer(&Desc, NULL, &cbVSPerObject);
DXUT_SetDebugName(cbVSPerObject, "CB_VS_PER_OBJECT_CLOUD");
Desc.ByteWidth = sizeof(CB_PS_PER_OBJECT);
pd3dDevice->CreateBuffer(&Desc, NULL, &cbPSPerObject);
DXUT_SetDebugName(cbPSPerObject, "CB_PS_PER_OBJECT_CLOUD");
// also initialize the wind textures
D3DX11CreateShaderResourceViewFromFile(pd3dDevice,
L"Media\\Grass\\Wind1.png",
NULL, NULL,
&txWind1,
NULL);
DXUT_SetDebugName(txWind1, "TEX_WIND1_CLOUD");
D3DX11CreateShaderResourceViewFromFile(pd3dDevice,
L"Media\\Grass\\Wind2.png",
NULL, NULL,
&txWind2,
NULL);
DXUT_SetDebugName(txWind2, "TEX_WIND2_CLOUD");
}
示例2: D3DX11CreateShaderResourceViewFromFile
bool TextureArrayClass::Initialize(ID3D11Device* device, WCHAR* filename1, WCHAR* filename2, WCHAR* filename3)
{
HRESULT result;
// Load the first texture in.
result = D3DX11CreateShaderResourceViewFromFile(device, filename1, NULL, NULL, &m_textures[0], NULL);
if(FAILED(result))
{
return false;
}
// Load the second texture in.
result = D3DX11CreateShaderResourceViewFromFile(device, filename2, NULL, NULL, &m_textures[1], NULL);
if(FAILED(result))
{
return false;
}
// Load the third texture in.
result = D3DX11CreateShaderResourceViewFromFile(device, filename3, NULL, NULL, &m_textures[2], NULL);
if(FAILED(result))
{
return false;
}
return true;
}
示例3: D3DX11CreateShaderResourceViewFromFile
bool TextureClass::Initialize(ID3D11Device* device, WCHAR* filename, WCHAR* filename2)
{
HRESULT result;
m_texture = new ID3D11ShaderResourceView*[2];
// Load the texture in.
result = D3DX11CreateShaderResourceViewFromFile(device, filename, NULL, NULL, &(m_texture[0]), NULL);
if(FAILED(result))
{
return false;
}
if(filename2 != NULL)
{
result = D3DX11CreateShaderResourceViewFromFile(device, filename2, NULL, NULL, &(m_texture[1]), NULL);
if(FAILED(result))
{
return false;
}
}
else
{
m_texture[1] = 0;
}
return true;
}
示例4: HR
bool LightingDemo2::init()
{
if (RenderCore::init() == false)
{
return false;
}
mWaves.Init(160, 160, 1.0f, 0.03f, 5.0f, 0.3f);
// Must init Effects first since InputLayouts depend on shader signatures.
EffectMgr::initAll(md3dDevice);
InputLayoutMgr::initAll(md3dDevice);
RenderStateMgr::initAll(md3dDevice);
HR(D3DX11CreateShaderResourceViewFromFile(md3dDevice, L"../Textures/grass.dds", 0, 0, &mGrassMapSRV, 0 ));
HR(D3DX11CreateShaderResourceViewFromFile(md3dDevice, L"../Textures/water2.dds", 0, 0, &mWavesMapSRV, 0 ));
HR(D3DX11CreateShaderResourceViewFromFile(md3dDevice, L"../Textures/WireFence.dds", 0, 0, &mBoxMapSRV, 0 ));
HR(D3DX11CreateShaderResourceViewFromFile(md3dDevice, L"../Textures/cig_texture2.dds", 0, 0, &mCigMapSRV, 0 ));
//buildSceneBuffers();
buildSkull();
buildCigar();
buildBox();
buildLand();
buildWave();
return true;
}
示例5: HR
void TreeBillboardApp::InitFX()
{
// Must init Effects first since InputLayouts depend on shader signatures.
Effects::InitAll(m_dxDevice.Get());
InputLayouts::InitAll(m_dxDevice.Get());
RenderStates::InitAll(m_dxDevice.Get());
HR(D3DX11CreateShaderResourceViewFromFile(m_dxDevice.Get(),
"Textures/grass.dds", 0, 0, m_grassMapSRV.GetAddressOf(), 0 ));
HR(D3DX11CreateShaderResourceViewFromFile(m_dxDevice.Get(),
"Textures/water2.dds", 0, 0, m_wavesMapSRV.GetAddressOf(), 0 ));
HR(D3DX11CreateShaderResourceViewFromFile(m_dxDevice.Get(),
"Textures/WireFence.dds", 0, 0, m_boxMapSRV.GetAddressOf(), 0 ));
std::vector<std::string> treeFilenames;
treeFilenames.push_back("Textures/tree0.dds");
treeFilenames.push_back("Textures/tree1.dds");
treeFilenames.push_back("Textures/tree2.dds");
treeFilenames.push_back("Textures/tree3.dds");
//Create texture array view
m_treeTextureMapArraySRV = dxHelper::CreateTexture2DArraySRV(
m_dxDevice.Get(), m_dxImmediateContext.Get(), treeFilenames, DXGI_FORMAT_R8G8B8A8_UNORM);
}
示例6: BuildShaders
bool BlendApp::Init()
{
if(!D3DApp::Init())
return false;
mWaves.Init(160, 160, 1.0f, 0.03f, 5.0f, 0.3f);
// Must init Effects first since InputLayouts depend on shader signatures.
BuildShaders();
BuildInputLayout();
RenderStates::InitAll(md3dDevice);
HR(D3DX11CreateShaderResourceViewFromFile(md3dDevice,
L"Textures/grass.dds", 0, 0, &mGrassMapSRV, 0 ));
HR(D3DX11CreateShaderResourceViewFromFile(md3dDevice,
L"Textures/water2.dds", 0, 0, &mWavesMapSRV, 0 ));
HR(D3DX11CreateShaderResourceViewFromFile(md3dDevice,
L"Textures/WireFence.dds", 0, 0, &mBoxMapSRV, 0 ));
BuildLandGeometryBuffers();
BuildWaveGeometryBuffers();
BuildCrateGeometryBuffers();
BuildConstBuffer();
return true;
}
示例7: loadTextures
//--------------------------------------------------------------------------------------
// JPE: Load Texture
//--------------------------------------------------------------------------------------
HRESULT loadTextures(ID3D11Device* d3d11Device)
{
//LPCWSTR pathTexture = L"C:\\Users\\yapjpe\\Documents\\Visual Studio 2010\\Projects\\DirectXSamples\\Textures\\images.dds";
LPCWSTR pathTexture = L"C:\\Users\\yapjpe\\Desktop\\tmp\\imagenes\\HexagonTile_DIFF.png";
LPCWSTR pathNormalMap = L"C:\\Users\\yapjpe\\Desktop\\tmp\\imagenes\\mono_norm.jpg";
LPCWSTR pathSpecularMap = NULL; // L"C:\\Users\\yapjpe\\Desktop\\tmp\\imagenes\\HexagonTile_SPEC.png";
// jpg: circulo_norm mono_norm cara_norm formas_norm ice1_n sandbag-diff sandbag-nor
// png: rabbit-june5_2006-img_0075_nm.png HexagonTile_NRM HexagonTile_DIFF HexagonTile_SPEC
HRESULT hr;
hr = D3DX11CreateShaderResourceViewFromFile(d3d11Device, pathTexture,
NULL, NULL, &m_texture, NULL);
if (FAILED(hr))
{
return hr;
}
// Create a texture sampler state description.
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;
samplerDesc.ComparisonFunc = 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.
hr = d3d11Device->CreateSamplerState(&samplerDesc, &m_sampleState);
if (FAILED(hr))
{
return hr;
}
// Carga el normal map.
hr = D3DX11CreateShaderResourceViewFromFile(d3d11Device, pathNormalMap,
NULL, NULL, &m_normalmap, NULL);
if (FAILED(hr))
{
return hr;
}
// Carga el normal map.
hr = D3DX11CreateShaderResourceViewFromFile(d3d11Device, pathSpecularMap,
NULL, NULL, &m_specularmap, NULL);
if (FAILED(hr))
{
return hr;
}
return hr;
}
示例8: BRR
// конструктор модели с костями
AnimModel::AnimModel(wchar_t* binFilePath, wchar_t* textureFilePath, bool* result) {
// инициализация переменных
position = Const::spawnPoint; // координаты модели
// загрузить модель из файла
BRR(LoadAmimModelFromFile(binFilePath));
// инициализация элементов после загрузки
std::fill(curFrame.begin(), curFrame.end(), 0);
std::fill(accumulation.begin(), accumulation.end(), 0.0f);
std::fill(blendFactors.begin(), blendFactors.end(), 0.0f);
blendFactors[0] = 1.0f;
// создать матрицу порядка умножения финальных костей
BRR(BuildOrder());
// загрузить текстуру
if (FAILED(D3DX11CreateShaderResourceViewFromFile(Mediator::pDev, textureFilePath, NULL, NULL, &pSRtexture, NULL))) {
BRR(Mediator::errors->Push(textureFilePath));
*result = false;
return;
}
*result = true;
}
示例9: XMFLOAT4
void cPillar::Init(float x,float y,float z)
{
cFBXObject::Init(L"FX/Basic.fx");
vertices = LOADMANAGER->Pillar_Resource;
mDirLights[0].Ambient = XMFLOAT4(0.3f, 0.3f, 0.3f, 1.0f);
mDirLights[0].Diffuse = XMFLOAT4(0.8f, 0.8f, 0.8f, 1.0f);
mDirLights[0].Specular = XMFLOAT4(0.6f, 0.6f, 0.6f, 16.0f);
mDirLights[0].Direction = XMFLOAT3(0.707f, -0.707f, 0.0f);
mDirLights[1].Ambient = XMFLOAT4(0.2f, 0.2f, 0.2f, 1.0f);
mDirLights[1].Diffuse = XMFLOAT4(1.4f, 1.4f, 1.4f, 1.0f);
mDirLights[1].Specular = XMFLOAT4(0.3f, 0.3f, 0.3f, 16.0f);
mDirLights[1].Direction = XMFLOAT3(-0.707f, 0.0f, 0.707f);
mDirLights[2].Ambient = XMFLOAT4(0.0f, 0.0f, 0.0f, 1.0f);
mDirLights[2].Diffuse = XMFLOAT4(0.2f, 0.2f, 0.2f, 1.0f);
mDirLights[2].Specular = XMFLOAT4(0.0f, 0.0f, 0.0f, 1.0f);
mDirLights[2].Direction = XMFLOAT3(0.0f, -0.707f, -0.707f);
mObjectMat.Ambient = XMFLOAT4(0.5f, 0.5f, 0.5f, 1.0f);
mObjectMat.Diffuse = XMFLOAT4(1.0f, 1.0f, 1.0f, 1.0f);
mObjectMat.Specular = XMFLOAT4(0.2f, 0.2f, 0.2f, 16.0f);
HR(D3DX11CreateShaderResourceViewFromFile(m_pD3dDevice,
L"Textures/pillar.bmp", 0, 0, &mDiffuseMapSRV, 0));
//D3D11_BUFFER_DESC vbd;
ZeroMemory(&vbd, sizeof(D3D11_BUFFER_DESC));
vbd.Usage = D3D11_USAGE_DEFAULT;
vbd.ByteWidth = sizeof(PNT_Vertex)* vertices.size();
//vbd.ByteWidth = sizeof(PNT_Vertex)* m_Animations[0].keyframe_vertices.size();
vbd.BindFlags = D3D11_BIND_VERTEX_BUFFER;
//vbd.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
vbd.MiscFlags = 0;
vbd.StructureByteStride = 0;
//D3D11_SUBRESOURCE_DATA vinitData;
vinitData.pSysMem = &vertices[0];
//vinitData.pSysMem = &m_Animations[0].keyframe_vertices[0];
HR(m_pD3dDevice->CreateBuffer(&vbd, &vinitData, &m_VB));
D3D11_RASTERIZER_DESC Desc;
ZeroMemory(&Desc, sizeof(D3D11_RASTERIZER_DESC));
Desc.FillMode = D3D11_FILL_SOLID;
Desc.CullMode = D3D11_CULL_BACK;
Desc.FrontCounterClockwise = true;////////////////////////////////////////////////////////////////////////////////////////////////////////
Desc.DepthClipEnable = true;
HR(m_pD3dDevice->CreateRasterizerState(&Desc, &m_RS));
m_WorldMatrix._41 = x;
m_WorldMatrix._42 = y;
m_WorldMatrix._43 = z;
}
示例10: D3DX11CreateShaderResourceViewFromFile
HRESULT GraphicsManager::CreateShaderResourceViewFromFile(ID3D11Device *device, ID3D11DeviceContext *dc, const wchar_t *filename, ID3D11ShaderResourceView **resourceView)
{
HRESULT result = E_FAIL;
#ifdef OLD_DX_SDK
//If not, then we have to load it!
D3DX11_IMAGE_LOAD_INFO imageInfo;
result = D3DX11CreateShaderResourceViewFromFile(device, filename, &imageInfo, NULL, resourceView, NULL);
#else
ID3D11Texture2D *tex;
result = CreateWICTextureFromFile(device, dc, filename, (ID3D11Resource **)&tex, resourceView);
if (FAILED(result))
{
DirectX::TexMetadata md;
DirectX::ScratchImage img;
result = LoadFromDDSFile(filename, 0, &md, img);
result = CreateShaderResourceView(device, img.GetImages(), img.GetImageCount(), md, resourceView);
}
#endif
if (FAILED(result))
{
printf("There was a problem loading \"%s\"\n", filename);
}
return result;
}
示例11: TextureFinder
//Initialise Particle System
bool CParticleSystem::Initialise(ID3D11Device* device, std::string mFileName, std::string mFileType, std::string textureLocation)
{
bool result;
//Texture Location
std::string textureRelativePath = TextureFinder(textureLocation, mFileName, mFileType);
if (FAILED(D3DX11CreateShaderResourceViewFromFile(device, textureRelativePath.c_str(), NULL, NULL, &m_Texture[0], NULL)))
{
//Output Error Message
OutputDebugString("Unable to Load Texture: ");
OutputDebugString(textureRelativePath.c_str());
OutputDebugString("\n");
return false;
}
//Initialise Particles in System
result = InitialiseParticleSystem();
if (!result)
{
return false;
}
//Initialise Buffers
result = InitialiseBuffers(device);
if (!result)
{
return false;
}
return true;
}
示例12: D3DX11CreateShaderResourceViewFromFile
bool Shader::loadTexture(const wchar_t* name, ID3D11Device* pDevice) {
HRESULT hr = D3DX11CreateShaderResourceViewFromFile(pDevice, name, NULL, NULL, &m_pTexture, NULL);
if(FAILED(hr)) {
Log::get()->err("Не удалось загрузить текстуру %ls", name);
return false;
}
D3D11_SAMPLER_DESC samplerDesc;
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;
samplerDesc.ComparisonFunc = 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;
hr = pDevice->CreateSamplerState(&samplerDesc, &m_pSampleState);
if(FAILED(hr)) {
Log::get()->err("Не удалось создать sample state");
return false;
}
return true;
}
示例13: sizeof
bool Object::InitializeBuffers(ID3D11Device* device, ID3D11DeviceContext* deviceContext, vector<Vertex>* vertices, LPCSTR textureFilename)
{
vertexCount = vertices->size();
Vertex *verts = new Vertex[vertexCount];
for (int i = 0; i < vertexCount; i++)
verts[i] = vertices->at(i);
BUFFER_INIT_DESC vertexBufferDesc;
vertexBufferDesc.ElementSize = sizeof(Vertex);
vertexBufferDesc.InitData = verts;
vertexBufferDesc.NumElements = vertices->size();
vertexBufferDesc.Type = VERTEX_BUFFER;
vertexBufferDesc.Usage = BUFFER_DEFAULT;
vertexBuffer = new ObjectBuffer();
if(FAILED(vertexBuffer->Init(device, deviceContext, vertexBufferDesc)))
::MessageBox(0, "Initializing vertex buffer failed! [ObjLoader]", "Error", MB_OK);
D3D11_INPUT_ELEMENT_DESC inputDesc[] = {
{"POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0},
{"NORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0},
{"TEXTURECOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 24, D3D11_INPUT_PER_VERTEX_DATA, 0}
};
if(D3DX11CreateShaderResourceViewFromFile(device, textureFilename, 0, 0, &mShaderResourceView, 0 ))
::MessageBox(0, "Failed to create shader resource! [Model->bthcolor]", "Error", MB_OK);
Effects::Shader_ShadowFX->SetTexture(mShaderResourceView, "shaderTexture");
return true;
}
示例14: HandleShaderFiles
void HandleShaderFiles(const char* a_szFilename)
{
const char* pEnd = strchr(a_szFilename,'\0');
while((*pEnd) != '.')
{
pEnd--;
}
char szExtension[32];
strncpy_s(szExtension,pEnd,strlen(pEnd) + 1);
if(strstr(szExtension,".hlsl"))
{
pkShader->LoadFromFile(a_szFilename);
m_pScene->UpdateProperties();
}
else if(strstr(szExtension,".jpg") || strstr(szExtension,".png") || strstr(szExtension,".bmp") || strstr(szExtension,".tif"))
{
ID3D11ShaderResourceView* NewTexture = nullptr;
D3DX11CreateShaderResourceViewFromFile(lcRenderer::GetDevice(),a_szFilename,nullptr,nullptr,&NewTexture,nullptr);
if(NewTexture)
{
CubeTexture = NewTexture;
return;
}
}
}
示例15: GetWindowRect
bool BoxApp::Init()
{
if(!D3DApp::Init())
return false;
GetWindowRect(mhMainWnd,&rc);
int midX= (rc.right+rc.left)/2;
int midY= (rc.top+rc.bottom)/2;
mLastMousePos.x = midX;
mLastMousePos.y = midY;
SetCursorPos(midX,midY);
ClipCursor(&rc);
w = new World();
w->Init(md3dDevice,this);
cam = new Camera();
cam->Init(&mView, w->playerShip);
//SetCapture(mhMainWnd);
ShowCursor(false);
BuildGeometryBuffers();
BuildFX();
BuildVertexLayout();
HR(D3DX11CreateShaderResourceViewFromFile(md3dDevice,L"Assets/skybox.dds",0,0, &mCubeMapSRV,0));
CubeMap = mFX->GetVariableByName("gCubeMap")->AsShaderResource();
CubeMap->SetResource(mCubeMapSRV);
return true;
}