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); } }
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); } } }
public static void DeleteContext(ContextHandle context) { if (_contexts.ContainsKey(context.HDC)) { _contexts.Remove(context.HDC); } if (context != ContextHandle.Zero) { Win32Helper.DeleteContext(context.Handle); } if (_contexts.Count == 0) { GLFunc.Dispose(); } }
internal static Shader GenShader(IEnumerable <ShaderSource> source, ContextHandle context) { GL.MakeSureCurrentContext(context); var id = CreateProgram(); foreach (var file in source) { uint shader = 0; switch (file.Type) { case ShaderType.Vert: shader = CreateShader(GL_VERTEX_SHADER); break; case ShaderType.Geom: shader = CreateShader(GL_GEOMETRY_SHADER); break; case ShaderType.Frag: shader = CreateShader(GL_FRAGMENT_SHADER); break; } var code = file.Code; GLFunc.ShaderSource(shader, 1, new string[] { code }, null); CompileShader(shader); if (!CheckCompileErrors(shader, file.Type.ToString())) { return(null); } AttachShader(id, shader); DeleteShader(shader); } LinkProgram(id); if (!CheckCompileErrors(id, "PROGRAM")) { return(null); } return(new Shader(id)); }