void OpenGLEngine::Draw (int x, int y, glm::vec4 const& color, std::string const& message) { if (message.length () > 0) { int vx, vy, vw, vh; GetViewport (vx, vy, vw, vh); m_ActiveFont->SetStringData (vw, vh, x, y, color, message); Update (m_ActiveFont->GetTextEffect () ->GetTranslate ()); Update (m_ActiveFont->GetTextEffect () ->GetColor ()); Update (m_ActiveFont->GetVertexBuffer ()); std::shared_ptr<BlendState> blendState = GetBlendState (); std::shared_ptr<DepthStencilState> depthState = GetDepthStencilState (); std::shared_ptr<RasterizerState> rasterizerState = GetRasterizerState (); SetDefaultBlendState (); SetDefaultDepthStencilState (); SetDefaultRasterizerState (); Draw (m_ActiveFont->GetVertexBuffer (), m_ActiveFont->GetIndexBuffer (), m_ActiveFont->GetTextEffect ()); SetBlendState (blendState); SetDepthStencilState (depthState); SetRasterizerState (rasterizerState); } }
//---------------------------------------------------------------------------- // Set the culling mode depending on whether it's a mirror or not //---------------------------------------------------------------------------- void CommitRasterizerState( int cullType, bool polyOffset, bool outline ) { polyOffset |= g_RunState.polyOffsetEnabled; outline |= g_RunState.lineMode; int maskBits = ( ( outline & 1 ) << 5 ) | ( ( polyOffset & 1 ) << 4 ) | ( cullType & 3 ); if ( g_RunState.cullMode == maskBits ) { return; } g_RunState.cullMode = maskBits; // Resolve which direction we're culling in D3D11_CULL_MODE cullMode = D3D11_CULL_NONE; if ( cullType != CT_TWO_SIDED ) { if ( cullType == CT_BACK_SIDED ) { cullMode = D3D11_CULL_BACK; } else { cullMode = D3D11_CULL_FRONT; } } int rasterFlags = 0; if ( polyOffset ) { rasterFlags |= RASTERIZERSTATE_FLAG_POLY_OFFSET; } if ( outline ) { rasterFlags |= RASTERIZERSTATE_FLAG_POLY_OUTLINE; } g_pImmediateContext->RSSetState( GetRasterizerState( cullMode, rasterFlags ) ); }