public static void SetupLineStyle(ILLineProperties wireprops) { if (wireprops.Style == LineStyle.Solid) { GL.Disable(EnableCap.LineStipple); } else { int stipFactr = 1; short stipple; if (wireprops.Style != LineStyle.UserPattern) { stipple = ILPanel.StippleFromLineStyle( wireprops.Style, ref stipFactr); } else { stipple = wireprops.Pattern; stipFactr = (int)wireprops.PatternScale; } GL.Enable(EnableCap.LineStipple); GL.LineStipple(stipFactr, stipple); } if (wireprops.Antialiasing && wireprops.Width > 1) { GL.Enable(EnableCap.LineSmooth); } else { GL.Disable(EnableCap.LineSmooth); } GL.LineWidth(wireprops.Width); GL.Color3(wireprops.Color); }
protected void ConfigureOGLLineProperties(LineStyle style, int width) { int stipFact = 0; short stipple = ILPanel.StippleFromLineStyle(style, ref stipFact); GL.LineWidth(width); if (style == LineStyle.Solid || style == LineStyle.None) { GL.Disable(EnableCap.LineStipple); } else { GL.Enable(EnableCap.LineStipple); GL.LineStipple(stipFact, stipple); } }
/// <summary> /// Draws the graph into existing context /// </summary> public override void Draw(ILRenderProperties p) { if (m_panel.Camera.Rho > Math.PI / 2) { return; } if (!m_isReady) { Configure(); } float zPos = m_zPosition; if (zPos == float.PositiveInfinity) { zPos = m_panel.Limits.ZMax; } else if (zPos == float.NegativeInfinity) { zPos = m_panel.Limits.ZMin; } GL.Translate(0.0f, 0.0f, zPos); GL.Enable(EnableCap.Blend); GL.Disable(EnableCap.DepthTest); GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha); GL.ShadeModel(ShadingModel.Flat); unsafe { fixed(VERTEXTYPEDEF *pVertices = m_vertices) { GL.InterleavedArrays( InterleavedArrayFormat.C4ubV2f, 0, (IntPtr)pVertices); if (m_filled) { fixed(UInt32 *pIndices = m_indices) { for (int i = 0; i < m_stripesCount; i++) { GL.DrawElements(BeginMode.Triangles, m_stripesLen, DrawElementsType.UnsignedInt, (IntPtr)(pIndices + i * m_stripesLen)); } GL.Finish(); } } #region draw grid if (m_wireLines.Visible) { if (m_wireLines.Style == LineStyle.Solid) { GL.Disable(EnableCap.LineStipple); } else { int stipFactr = 1; short stipple; if (m_wireLines.Style != LineStyle.UserPattern) { stipple = ILPanel.StippleFromLineStyle( m_wireLines.Style, ref stipFactr); } else { stipple = m_wireLines.Pattern; } GL.Enable(EnableCap.LineStipple); GL.LineStipple((int)m_wireLines.PatternScale, stipple); } if (m_wireLines.Antialiasing) { GL.Enable(EnableCap.LineSmooth); } else { GL.Disable(EnableCap.LineSmooth); } GL.Disable(EnableCap.Blend); GL.LineWidth(m_wireLines.Width); if (m_wireLines.Color != System.Drawing.Color.Empty) { GL.DisableClientState(EnableCap.ColorArray); GL.Color3(m_wireLines.Color); } fixed(UInt32 *pIndices = m_gridIndices) { GL.DrawElements(BeginMode.Lines, m_gridIndicesCount, DrawElementsType.UnsignedInt, (IntPtr)pIndices); GL.Finish(); } } #endregion } } GL.Translate(0.0f, 0.0f, -zPos); }