public static void Draw(GL_ControlModern control, Pass pass, Vector4 boxColor, Vector4 outlineColor, Vector4 pickingColor) { if (pass == Pass.OPAQUE) { control.CurrentShader = DefaultShaderProgram; GL.ActiveTexture(TextureUnit.Texture0); GL.BindTexture(TextureTarget.Texture2D, Framework.TextureSheet); DefaultShaderProgram.SetVector4("color", boxColor); blockVao.Use(control); GL.DrawArrays(PrimitiveType.Quads, 0, 24); #region outlines GL.LineWidth(1); control.CurrentShader = SolidColorShaderProgram; SolidColorShaderProgram.SetVector4("color", outlineColor); linesVao.Use(control); GL.DrawArrays(PrimitiveType.Lines, 0, 24); GL.LineWidth(2); #endregion } else { control.CurrentShader = SolidColorShaderProgram; SolidColorShaderProgram.SetVector4("color", pickingColor); blockVao.Use(control); GL.DrawArrays(PrimitiveType.Quads, 0, 24); } }
public static void Draw(GL_ControlModern control, Pass pass, Vector4 sphereColor, Vector4 outlineColor, bool xray = false) { if (DefaultShaderProgram == null) { return; } Initialize(control); sphereVao.Enable(control); if (pass == Pass.PICKING) { control.CurrentShader = SolidColorShaderProgram; control.CurrentShader.SetVector4("color", control.NextPickingColor()); sphereVao.Use(control); GL.DrawArrays(PrimitiveType.TriangleStrip, 0, Vertices.Length); return; } if (pass == Pass.OPAQUE && outlineColor.W != 0) { GL.Enable(EnableCap.StencilTest); GL.Clear(ClearBufferMask.StencilBufferBit); GL.ClearStencil(0); GL.StencilFunc(StencilFunction.Always, 0x1, 0x1); GL.StencilOp(StencilOp.Keep, StencilOp.Replace, StencilOp.Replace); } if (pass == Pass.OPAQUE && !xray || pass == Pass.TRANSPARENT && xray) { control.CurrentShader = DefaultShaderProgram; DefaultShaderProgram.SetVector4("color", sphereColor); sphereVao.Use(control); GL.DrawArrays(PrimitiveType.TriangleStrip, 0, Vertices.Length); } if (pass == Pass.OPAQUE && outlineColor.W != 0) { GL.ColorMask(false, false, false, false); GL.DepthMask(false); sphereVao.Use(control); GL.DrawArrays(PrimitiveType.TriangleStrip, 0, Vertices.Length); GL.ColorMask(true, true, true, true); GL.DepthMask(true); } GL.Disable(EnableCap.Blend); if (pass == Pass.OPAQUE && outlineColor.W != 0) { control.CurrentShader = SolidColorShaderProgram; control.CurrentShader.SetVector4("color", new Vector4(outlineColor.Xyz, 1)); GL.LineWidth(3.0f); GL.StencilFunc(StencilFunction.Equal, 0x0, 0x1); GL.StencilOp(StencilOp.Keep, StencilOp.Keep, StencilOp.Replace); //GL.DepthFunc(DepthFunction.Always); GL.PolygonMode(MaterialFace.Front, PolygonMode.Line); sphereVao.Use(control); GL.DrawArrays(PrimitiveType.TriangleStrip, 0, Vertices.Length); GL.PolygonMode(MaterialFace.Front, PolygonMode.Fill); //GL.DepthFunc(DepthFunction.Lequal); GL.Disable(EnableCap.StencilTest); GL.LineWidth(2); } }
public void Draw(GL_ControlModern control, Pass pass, Vector4 sphereColor, Vector4 outlineColor) { Initialize(control, Scale); if (pass == Pass.TRANSPARENT) { GL.BlendFunc(BlendingFactor.SrcAlpha, BlendingFactor.OneMinusSrcAlpha); GL.Enable(EnableCap.Blend); } sphereVao.Enable(control); if (pass == Pass.PICKING) { control.CurrentShader = SolidColorShaderProgram; control.CurrentShader.SetVector4("color", control.NextPickingColor()); sphereVao.Use(control); GL.DrawArrays(PrimitiveType.Quads, 0, Vertices.Length); return; } else { } if (pass == Pass.OPAQUE && outlineColor.W != 0) { GL.Enable(EnableCap.StencilTest); GL.Clear(ClearBufferMask.StencilBufferBit); GL.ClearStencil(0); GL.StencilFunc(StencilFunction.Always, 0x1, 0x1); GL.StencilOp(StencilOp.Keep, StencilOp.Replace, StencilOp.Replace); } if (pass == PlanePass) { control.CurrentShader = DefaultShaderProgram; DefaultShaderProgram.SetVector4("highlight_color", sphereColor); if (Texture != null) { GL.ActiveTexture(TextureUnit.Texture0 + 1); DefaultShaderProgram.SetInt("texture0", 1); if (Texture.RenderableTex == null || !Texture.RenderableTex.GLInitialized) { Texture.LoadOpenGLTexture(); } GL.BindTexture(TextureTarget.Texture2D, Texture.RenderableTex.TexID); } sphereVao.Use(control); GL.DrawArrays(PrimitiveType.Quads, 0, Vertices.Length); } if (pass == Pass.OPAQUE && outlineColor.W != 0) { GL.ColorMask(false, false, false, false); GL.DepthMask(false); sphereVao.Use(control); GL.DrawArrays(PrimitiveType.Quads, 0, Vertices.Length); GL.ColorMask(true, true, true, true); GL.DepthMask(true); } GL.Disable(EnableCap.Blend); if (pass == Pass.OPAQUE && outlineColor.W != 0) { control.CurrentShader = SolidColorShaderProgram; control.CurrentShader.SetVector4("color", new Vector4(outlineColor.Xyz, 1)); GL.LineWidth(3.0f); GL.StencilFunc(StencilFunction.Equal, 0x0, 0x1); GL.StencilOp(StencilOp.Keep, StencilOp.Keep, StencilOp.Replace); //GL.DepthFunc(DepthFunction.Always); GL.PolygonMode(MaterialFace.Front, PolygonMode.Line); sphereVao.Use(control); GL.DrawArrays(PrimitiveType.Quads, 0, Vertices.Length); GL.PolygonMode(MaterialFace.Front, PolygonMode.Fill); //GL.DepthFunc(DepthFunction.Lequal); GL.Disable(EnableCap.StencilTest); GL.LineWidth(2); } }