2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-12-09 18:27:42 +00:00

D3D11/12 support

This commit is contained in:
Jack Andersen
2015-11-27 12:20:22 -10:00
parent ecbed6e82c
commit a800ff73ee
6 changed files with 181 additions and 6 deletions

View File

@@ -42,6 +42,54 @@ void View::System::init(boo::GLDataFactory* factory)
false, false, false);
}
void View::System::init(boo::ID3DDataFactory* factory)
{
static const char* VS =
"struct VertData\n"
"{\n"
" float3 posIn : POSITION;\n"
" float4 colorIn : COLOR;\n"
"};\n"
SPECTER_VIEW_VERT_BLOCK_HLSL
"struct VertToFrag\n"
"{\n"
" float4 position : SV_Position;\n"
" float4 color : COLOR;\n"
"};\n"
"VertToFrag main(in VertData v)\n"
"{\n"
" VertToFrag vtf;\n"
" vtf.color = v.colorIn;\n"
" vtf.position = mul(mv, float4(v.posIn, 1.0));\n"
" return vtf;\n"
"}\n";
static const char* FS =
"struct VertToFrag\n"
"{\n"
" float4 position : SV_Position;\n"
" float4 color : COLOR;\n"
"};\n"
"float4 main(in VertToFrag vtf) : SV_Target0\n"
"{\n"
" return vtf.color;\n"
"}\n";
boo::VertexElementDescriptor vdescs[] =
{
{nullptr, nullptr, boo::VertexSemantic::Position4},
{nullptr, nullptr, boo::VertexSemantic::Color | boo::VertexSemantic::Instanced}
};
m_vtxFmt = factory->newVertexFormat(2, vdescs);
ComPtr<ID3DBlob> vertBlob;
ComPtr<ID3DBlob> fragBlob;
ComPtr<ID3DBlob> pipeBlob;
m_solidShader = factory->newShaderPipeline(VS, FS, vertBlob, fragBlob, pipeBlob, m_vtxFmt,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
false, false, false);
}
View::View(ViewSystem& system)
{
m_bgVertBuf =
@@ -60,7 +108,7 @@ View::View(ViewSystem& system)
{
boo::VertexElementDescriptor vdescs[] =
{
{m_bgVertBuf, nullptr, boo::VertexSemantic::Position4, 0},
{m_bgVertBuf, nullptr, boo::VertexSemantic::Position4},
{m_bgInstBuf, nullptr, boo::VertexSemantic::Color | boo::VertexSemantic::Instanced}
};
m_bgVtxFmt = system.m_factory->newVertexFormat(2, vdescs);
@@ -70,6 +118,14 @@ View::View(ViewSystem& system)
(boo::IGraphicsBuffer**)&m_viewVertBlockBuf,
0, nullptr);
}
else
{
m_bgShaderBinding =
system.m_factory->newShaderDataBinding(system.m_viewSystem.m_solidShader, system.m_viewSystem.m_vtxFmt,
m_bgVertBuf, m_bgInstBuf, nullptr, 1,
(boo::IGraphicsBuffer**)&m_viewVertBlockBuf,
0, nullptr);
}
}