/// <summary> /// Sets the aspect of the global render state associated with the specified bit. /// Consider using SetRenderStateByIndex if you have access to the index.</summary> /// <param name="renderStateBit">Render state bit to set</param> /// <param name="renderState">Current RenderState to commit to the graphics device driver layer</param> public void SetRenderState(int renderStateBit, RenderState renderState) { RenderStateSetHandler handler = TryGetHandler(renderStateBit); if (handler == null) { return; } handler(renderState, m_reset == false ? m_oldRenderState : null); }
/// <summary> /// Sets the aspect of the global render state associated with the specified bit. /// For performance reasons, this is better than SetRenderState().</summary> /// <param name="renderStateIndex">Zero-based render state index to set. Is equivalent /// to how many times the 1 is shifted left in the render state bit.</param> /// <param name="renderState">Current RenderState to commit to the graphics device driver layer</param> public void SetRenderStateByIndex(int renderStateIndex, RenderState renderState) { RenderStateSetHandler handler = m_renderStateSetters[renderStateIndex]; if (handler == null) { return; } handler(renderState, m_reset == false ? m_oldRenderState : null); }
/// <summary> /// Registers a platform-specific delegate RenderStateSetHandler to the specified render state bit. /// This handler is called during SetRenderState calls.</summary> /// <param name="renderStateBit">Bit key to register the handler under</param> /// <param name="handler">Handler delegate to associate with the bit</param> public void RegisterRenderStateHandler(int renderStateBit, RenderStateSetHandler handler) { if (!Sce.Atf.MathUtil.OnlyOneBitSet(renderStateBit)) throw new ArgumentException("RenderStateSetHandlers can only be set on keys with only one bit set."); if (TryGetHandler(renderStateBit) != null) throw new InvalidOperationException("Key " + renderStateBit + " is already associated with a handler."); int index = Sce.Atf.MathUtil.LogBase2(renderStateBit); m_renderStateSetters[index] = handler; }
/// <summary> /// Registers a platform-specific delegate RenderStateSetHandler to the specified render state bit. /// This handler is called during SetRenderState calls.</summary> /// <param name="renderStateBit">Bit key to register the handler under</param> /// <param name="handler">Handler delegate to associate with the bit</param> public void RegisterRenderStateHandler(int renderStateBit, RenderStateSetHandler handler) { if (!Sce.Atf.MathUtil.OnlyOneBitSet(renderStateBit)) { throw new ArgumentException("RenderStateSetHandlers can only be set on keys with only one bit set."); } if (TryGetHandler(renderStateBit) != null) { throw new InvalidOperationException("Key " + renderStateBit + " is already associated with a handler."); } int index = Sce.Atf.MathUtil.LogBase2(renderStateBit); m_renderStateSetters[index] = handler; }