#include "CLineRendererShaders.hpp" namespace urde { boo::ObjToken CLineRendererShaders::m_texAlpha; boo::ObjToken CLineRendererShaders::m_texAdditive; boo::ObjToken CLineRendererShaders::m_noTexAlpha; boo::ObjToken CLineRendererShaders::m_noTexAdditive; boo::ObjToken CLineRendererShaders::m_texAlphaZ; boo::ObjToken CLineRendererShaders::m_texAdditiveZ; boo::ObjToken CLineRendererShaders::m_noTexAlphaZ; boo::ObjToken CLineRendererShaders::m_noTexAdditiveZ; boo::ObjToken CLineRendererShaders::m_noTexAlphaZGEqual; boo::ObjToken CLineRendererShaders::m_texVtxFmt; boo::ObjToken CLineRendererShaders::m_noTexVtxFmt; std::unique_ptr CLineRendererShaders::m_bindFactory; void CLineRendererShaders::Initialize() { if (!CGraphics::g_BooFactory) return; CGraphics::CommitResources( [&](boo::IGraphicsDataFactory::Context& ctx) { switch (ctx.platform()) { #if BOO_HAS_GL case boo::IGraphicsDataFactory::Platform::OpenGL: m_bindFactory.reset(Initialize(static_cast(ctx))); break; #endif #if _WIN32 case boo::IGraphicsDataFactory::Platform::D3D11: m_bindFactory.reset(Initialize(static_cast(ctx))); break; #endif #if BOO_HAS_METAL case boo::IGraphicsDataFactory::Platform::Metal: m_bindFactory.reset(Initialize(static_cast(ctx))); break; #endif #if BOO_HAS_VULKAN case boo::IGraphicsDataFactory::Platform::Vulkan: m_bindFactory.reset(Initialize(static_cast(ctx))); break; #endif default: break; } return true; } BooTrace); } void CLineRendererShaders::Shutdown() { m_texAlpha.reset(); m_texAdditive.reset(); m_noTexAlpha.reset(); m_noTexAdditive.reset(); m_texAlphaZ.reset(); m_texAdditiveZ.reset(); m_noTexAlphaZ.reset(); m_noTexAdditiveZ.reset(); m_noTexAlphaZGEqual.reset(); m_texVtxFmt.reset(); m_noTexVtxFmt.reset(); } void CLineRendererShaders::BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, CLineRenderer& renderer, const boo::ObjToken& texture, bool additive, bool zTest, bool zGEqual) { boo::ObjToken pipeline; if (zGEqual) { pipeline = m_noTexAlphaZGEqual; } else if (zTest) { if (texture) { if (additive) pipeline = m_texAdditiveZ; else pipeline = m_texAlphaZ; } else { if (additive) pipeline = m_noTexAdditiveZ; else pipeline = m_noTexAlphaZ; } } else { if (texture) { if (additive) pipeline = m_texAdditive; else pipeline = m_texAlpha; } else { if (additive) pipeline = m_noTexAdditive; else pipeline = m_noTexAlpha; } } m_bindFactory->BuildShaderDataBinding(ctx, renderer, pipeline, texture); } }