Example #1
0
bool Rasterizer::VInit(DXDriver* _driver)
{
    if (m_pVertexShaderStage || m_pPixelShaderStage || m_pGeometryShaderStage)
    {
        PrintError(AT, "shader stages already created");
        return false;
    }

    m_pVertexShaderStage	= VNEW VertexShader();
    m_pGeometryShaderStage	= VNEW GeometryShader();
    m_pPixelShaderStage		= VNEW PixelShader();

    if (!m_pVertexShaderStage->Init(L"Assets/Shaders/RasterNodeVS.hlsl", _driver->GetDevice()))
        //if (!m_pVertexShaderStage->Init(L"Assets/Shaders/vtest.hlsl", _driver->GetDevice()))
    {
        PrintError(AT, "failed to create vertex shader stage");
        return false;
    }

    if (!m_pGeometryShaderStage->Init(L"Assets/Shaders/RasterNodeGS.hlsl", _driver->GetDevice()))
        //if (!m_pGeometryShaderStage->Init(L"Assets/Shaders/gtest.hlsl", _driver->GetDevice()))
    {
        PrintError(AT, "failed to create geometry shader stage");
        return false;
    }

    if (!m_pPixelShaderStage->Init(L"Assets/Shaders/RasterNodePS.hlsl", _driver->GetDevice()))
        //if (!m_pPixelShaderStage->Init(L"Assets/Shaders/ptest.hlsl", _driver->GetDevice()))
    {
        PrintError(AT, "failed to create pixel shader stage");
        return false;
    }

    RenderTarget* renderTarget = nullptr;
    for (unsigned int i = RT_COLOR; i < RENDERTARGET_COUNT; ++i)
    {
        _driver->GetRenderTarget(i, renderTarget);
        if (!renderTarget)
            return false;

        renderTarget->GetView(m_pDeferredRenderTargets[i]);

        if (!m_pDeferredRenderTargets[i])
            return false;
    }

    return true;
}