Exemple #1
0
        /// <summary>
        /// Binds vertex buffer format
        /// </summary>
        public void BindVertexFormat(VertexBufferFormat format)
        {
            if (_boundVertexFormat == format)
            {
                return;
            }

            format.Bind(_boundVertexFormat);
            _boundVertexFormat = format;
        }
Exemple #2
0
 /// <summary>
 /// Creates a new graphics pipeline
 /// </summary>
 /// <param name="device">Glob device</param>
 /// <param name="vertex">Vertex shader</param>
 /// <param name="tesselationControl">Tesselation control shader - can be null</param>
 /// <param name="tesselationEvaluation">Tesselation evaluation shader - can be null</param>
 /// <param name="geometry">Geometry shader - can be null</param>
 /// <param name="fragment">Fragment shader</param>
 /// <param name="vertexFormat">Vertex buffer format - can be null</param>
 /// <param name="rasterizerState">Rasterization state - cull face and polygon mode</param>
 /// <param name="depthState">Depth state - depth test func and depth mask</param>
 /// <param name="blendState">Blend state - color/alpha blending mode - can be null</param>
 public GraphicsPipeline(Device device, Shader vertex, Shader fragment, Shader tesselationControl, Shader tesselationEvaluation, Shader geometry, VertexBufferFormat vertexFormat, RasterizerState rasterizerState, DepthState depthState, BlendState blendState = null)
 {
     _device          = device;
     _shaderPipeline  = _device.ShaderRepository.GetShaderPipeline(vertex, tesselationControl, tesselationEvaluation, geometry, fragment, null);
     _vertexFormat    = vertexFormat;
     _rasterizerState = rasterizerState;
     _depthState      = depthState;
     _blendState      = blendState;
     if (_blendState == null)
     {
         _blendState = new BlendState();
     }
 }
Exemple #3
0
 /// <summary>
 /// Changes all current states to null, so any future bind or state change will effectively skip redundant state change checks and should execute its OpenGL calls.
 /// </summary>
 public void Invalidate()
 {
     ShaderPipeline = null;
     _textureUnit.Invalidate();
     _currentRasterizerState = null;
     _currentDepthState      = null;
     _currentBlendState      = null;
     _boundReadFramebuffer   = -1;
     _boundDrawFramebuffer   = -1;
     _boundBothFramebuffer   = -1;
     _boundVertexFormat      = null;
     _boundVertexSource      = null;
     _bufferBindingManager.Invalidate();
 }
Exemple #4
0
        internal void Bind(VertexBufferFormat old)
        {
            if (old != null)
            {
                int disable = old._enabledAttributesMask & (~_enabledAttributesMask);
                int enable  = (~old._enabledAttributesMask) & _enabledAttributesMask;

                for (int i = 0; i < MaxAttributes; i++)
                {
                    if (((disable >> i) & 1) > 0)
                    {
                        GL.DisableVertexAttribArray(i);
                    }
                    if (((enable >> i) & 1) > 0)
                    {
                        GL.EnableVertexAttribArray(i);
                    }
                }
            }
            else
            {
                foreach (var attribute in _attributes)
                {
                    GL.EnableVertexAttribArray(attribute.AttribIndex);
                }
            }

            foreach (var attribute in _attributes)
            {
                GL.EnableVertexAttribArray(attribute.AttribIndex);
            }


            foreach (var attribute in _attributes)
            {
                attribute.Bind();
            }
        }
Exemple #5
0
 /// <summary>
 /// Creates a new graphics pipeline
 /// </summary>
 /// <param name="device">Glob device</param>
 /// <param name="vertex">Vertex shader</param>
 /// <param name="fragment">Fragment shader</param>
 /// <param name="vertexFormat">Vertex buffer format - can be null</param>
 /// <param name="rasterizerState">Rasterization state - cull face and polygon mode</param>
 /// <param name="depthState">Depth state - depth test func and depth mask</param>
 /// <param name="blendState">Blend state - color/alpha blending mode - can be null</param>
 public GraphicsPipeline(Device device, Shader vertex, Shader fragment, VertexBufferFormat vertexFormat, RasterizerState rasterizerState, DepthState depthState, BlendState blendState = null)
     : this(device, vertex, fragment, null, null, null, vertexFormat, rasterizerState, depthState, blendState)
 {
 }