public override void Draw(ILRenderProperties props, ILShape shape) { if (shape.VertexCount == 0) { return; } GL.Enable(EnableCap.Blend); GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha); GL.Enable(EnableCap.DepthTest); //GL.Disable(EnableCap.PolygonOffsetFill); ILShape <C4fN3fV3f> cShape = (shape as ILShape <C4fN3fV3f>); fixed(C4fN3fV3f *pVertices = cShape.Vertices) { if (UseLight && (cShape is IILSupportsLight)) { setupLight(cShape as IILSupportsLight); } else { GL.Disable(EnableCap.Lighting); } GL.InterleavedArrays(InterleavedArrayFormat.C4fN3fV3f, 0, (IntPtr)pVertices); if (cShape.Shading == ShadingStyles.Interpolate) { GL.ShadeModel(ShadingModel.Smooth); } else { GL.ShadeModel(ShadingModel.Flat); GL.DisableClientState(EnableCap.ColorArray); GL.Color4(shape.FillColor); } GL.DrawArrays(m_primitiveType, 0, cShape.VertexCount); } GL.Disable(EnableCap.Lighting); ILBorderedShape <C4fN3fV3f> bShape = (shape as ILBorderedShape <C4fN3fV3f>); if (bShape != null && bShape.Border.Visible) { fixed(C4fN3fV3f *pVertices = bShape.Vertices) { ILOGLPanel.SetupLineStyle(bShape.Border); GL.InterleavedArrays(InterleavedArrayFormat.C4fN3fV3f, 0, (IntPtr)pVertices); GL.DisableClientState(EnableCap.ColorArray); GL.DrawArrays(BeginMode.LineLoop, 0, bShape.VertexCount); } } }
public override void Draw(ILRenderProperties props, ILShape shape, int[] indices) { System.Diagnostics.Debug.Assert(indices != null); GL.Enable(EnableCap.DepthTest); GL.Disable(EnableCap.Blend); ILBorderedShape <C4bV3f> bShape = (shape as ILBorderedShape <C4bV3f>); if (bShape != null && bShape.Border.Visible) { fixed(int *pIndices = indices) fixed(C4bV3f * pVertices = bShape.Vertices) { ILOGLPanel.SetupLineStyle(bShape.Border); GL.InterleavedArrays( InterleavedArrayFormat.C4ubV3f, 0, (IntPtr)pVertices); GL.DisableClientState(EnableCap.ColorArray); if (CloseLines) { GL.DrawElements(BeginMode.LineLoop, indices.Length, DrawElementsType.UnsignedInt, (IntPtr)pIndices); } else { GL.DrawElements(BeginMode.LineStrip, indices.Length, DrawElementsType.UnsignedInt, (IntPtr)pIndices); } } } GL.Enable(EnableCap.Blend); GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha); ILShape <C4bV3f> cShape = (shape as ILShape <C4bV3f>); if (cShape is ILLine) { ILOGLPanel.SetupLineStyle((cShape as ILLine).Properties); GL.Disable(EnableCap.DepthTest); } else { GL.Disable(EnableCap.LineSmooth); } fixed(int *pIndices = indices) fixed(C4bV3f * pVertices = cShape.Vertices) { GL.InterleavedArrays(InterleavedArrayFormat.C4ubV3f, 0, (IntPtr)pVertices); if (cShape.Shading == ShadingStyles.Interpolate) { GL.ShadeModel(ShadingModel.Smooth); } else { GL.ShadeModel(ShadingModel.Flat); GL.DisableClientState(EnableCap.ColorArray); GL.Color4(shape.FillColor); } GL.DrawElements(m_primitiveType, indices.Length, DrawElementsType.UnsignedInt, (IntPtr)pIndices); } }
public override void Draw(ILRenderProperties props, ILShape shape, int[] indices) { System.Diagnostics.Debug.Assert(indices != null); GL.Enable(EnableCap.DepthTest); GL.Enable(EnableCap.Blend); GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha); // draw shape ILShape <C4fN3fV3f> cShape = (shape as ILShape <C4fN3fV3f>); fixed(int *pIndices = indices) fixed(C4fN3fV3f * pVertices = cShape.Vertices) { if (UseLight && (cShape is ILLitCompositeShape <C4fN3fV3f>)) { setupLight(cShape as ILLitCompositeShape <C4fN3fV3f>); } else { GL.Disable(EnableCap.Lighting); } GL.InterleavedArrays(InterleavedArrayFormat.C4fN3fV3f, 0, (IntPtr)pVertices); if (cShape.Shading == ShadingStyles.Interpolate) { GL.ShadeModel(ShadingModel.Smooth); } else { GL.ShadeModel(ShadingModel.Flat); GL.DisableClientState(EnableCap.ColorArray); GL.Color4(shape.FillColor); } GL.DrawElements(m_primitiveType, indices.Length, DrawElementsType.UnsignedInt, (IntPtr)pIndices); //IntPtr pObj = Glu.NewQuadric(); //GL.MatrixMode(MatrixMode.Modelview); //GL.PushMatrix(); //GL.Translate(cShape.Vertices[0].Position.X, cShape.Vertices[0].Position.Y, cShape.Vertices[0].Position.Z); //Glu.QuadricDrawStyle(pObj, QuadricDrawStyle.Fill); //Glu.Sphere(pObj, 2, 20, 10); //GL.PopMatrix(); } // draw border ILBorderedShape <C4fN3fV3f> bShape = (shape as ILBorderedShape <C4fN3fV3f>); if (bShape != null && bShape.Border.Visible) { fixed(int *pIndices = indices) fixed(C4fN3fV3f * pVertices = bShape.Vertices) { ILOGLPanel.SetupLineStyle(bShape.Border); GL.InterleavedArrays( InterleavedArrayFormat.C4fN3fV3f, 0, (IntPtr)pVertices); GL.DisableClientState(EnableCap.ColorArray); GL.DrawElements(BeginMode.LineLoop, indices.Length, DrawElementsType.UnsignedInt, (IntPtr)pIndices); } } #if RENDERER_DRAW_NORMALS #region DEBUG_DRAW_NORMALS GL.Color3(0, 0, 0); GL.Begin(BeginMode.Lines); for (int i = 0; i < shape.VertexCount; i++) { GL.Vertex3(cShape.Vertices[i].XPosition, cShape.Vertices[i].YPosition, cShape.Vertices[i].ZPosition); GL.Vertex3(cShape.Vertices[i].XPosition + cShape.Vertices[i].Normal.X, cShape.Vertices[i].YPosition + cShape.Vertices[i].Normal.Y, cShape.Vertices[i].ZPosition + cShape.Vertices[i].Normal.Z); } GL.End(); #endregion #endif GL.Disable(EnableCap.Lighting); }