Exemple #1
0
        protected internal virtual void OnRender(Shader shader)
        {
            if (!_isVisible)
            {
                return;
            }

            shader.SetBool("dashed", HasDash);

            if (HasDash)
            {
                shader.SetFloat("dashedFactor", _dashes.Length * 2);
                TexImage1D(GL_TEXTURE_1D, 0, GL_RED, _dashes.Length, 0, GL_RED, GL_UNSIGNED_BYTE, _dashes);
            }

            GLFunc.PointSize(_pointSize);
            GLFunc.LineWidth(_lineWidth);

            _SetMaterialData(shader);
            BindVertexArray(_vao[0]);
            var hasPoints  = _points != null;
            var hasIndices = _indices != null;
            var mode       = (uint)_mode;

            if (hasIndices)
            {
                DrawElements(mode, hasPoints ? _indices.Count : 0, GL_UNSIGNED_INT, 0);
            }
            else
            {
                DrawArrays(mode, 0, hasPoints ? _points.Count : 0);
            }
        }
Exemple #2
0
        internal override void OnRender(Shader shader)
        {
            shader.SetBool("dashed", HasDash);
            if (HasDash)
            {
                shader.SetFloat("dashedFactor", _dashes.Length * 2);
                TexImage1D(GL_TEXTURE_1D, 0, GL_RED, _dashes.Length, 0, GL_RED, GL_UNSIGNED_BYTE, _dashes);
            }

            GLFunc.PointSize(_pointSize);
            GLFunc.LineWidth(_lineWidth);

            _SetMaterialData(shader);

            var hasPoints  = _points != null;
            var hasIndices = _indices != null;
            var mode       = (uint)_mode;

            if (hasIndices)
            {
                BufferData(GL_ELEMENT_ARRAY_BUFFER, _indices.Count * sizeof(uint), _indices.Select(index => index + (uint)_dataIndex).ToArray(), GL_DYNAMIC_DRAW);
                DrawElements(mode, hasPoints ? _indices.Count : 0, GL_UNSIGNED_INT, 0);
            }
            else
            {
                if (_pairs == null)
                {
                    DrawArrays(mode, _dataIndex, hasPoints ? _points.Count : 0);
                }
                else
                {
                    MultiDrawArrays(mode, _pairs.Select(pair => pair.Start + _dataIndex).ToArray(), _pairs.Select(pair => pair.Count).ToArray(), _pairs.Count);
                }
            }
        }