Exemplo n.º 1
0
 public virtual void AddLines(RenderInfo info, ArrayList <VertexNormalColor> opaqueVertexData, ArrayList <VertexNormalColor> transparentVertexData)
 {
 }
Exemplo n.º 2
0
 public virtual void AddTriangles(RenderInfo info, ArrayList <VertexNormalColor> opaqueVertexData, ArrayList <VertexNormalColor> transparentVertexData, ArrayList <uint> opaqueIndexData, ArrayList <uint> transparentIndexData)
 {
 }
Exemplo n.º 3
0
        public void Render(RenderInfo info)
        {
            // Collect all triangles and lines into two separate arrays
            List <DebugRenderPrimitive> primitivesToRender = GetPrimitivesForTime(info.time);

            if (renderCacheDirty)
            {
                ArrayList <VertexNormalColor> opaqueIndexedTriangleVertexData = new ArrayList <VertexNormalColor>();
                ArrayList <uint> opaqueIndexedTriangleIndexData        = new ArrayList <uint>();
                ArrayList <VertexNormalColor> opaqueTriangleVertexData = new ArrayList <VertexNormalColor>();
                ArrayList <VertexNormalColor> opaqueLineVertexData     = new ArrayList <VertexNormalColor>();

                ArrayList <VertexNormalColor> transparentIndexedTriangleVertexData = new ArrayList <VertexNormalColor>();
                ArrayList <uint> transparentIndexedTriangleIndexData        = new ArrayList <uint>();
                ArrayList <VertexNormalColor> transparentTriangleVertexData = new ArrayList <VertexNormalColor>();
                ArrayList <VertexNormalColor> transParentLineVertexData     = new ArrayList <VertexNormalColor>();

                foreach (DebugRenderPrimitive primitive in primitivesToRender)
                {
                    primitive.AddTriangles(info, opaqueIndexedTriangleVertexData, transparentIndexedTriangleVertexData, opaqueIndexedTriangleIndexData, transparentIndexedTriangleIndexData);
                    primitive.AddTriangles(info, opaqueTriangleVertexData, transparentTriangleVertexData);
                    primitive.AddLines(info, opaqueLineVertexData, transParentLineVertexData);
                }

                opaqueIndexedTriangleVertex.Handle      = GCHandle.Alloc(opaqueIndexedTriangleVertexData.BackingArray, GCHandleType.Pinned);
                opaqueIndexedTriangleVertex.Count       = opaqueIndexedTriangleVertexData.Count;
                transparentIndexedTriangleVertex.Handle = GCHandle.Alloc(transparentIndexedTriangleVertexData.BackingArray, GCHandleType.Pinned);
                transparentIndexedTriangleVertex.Count  = transparentIndexedTriangleVertexData.Count;

                opaqueIndexedTriangleIndex.Handle      = GCHandle.Alloc(opaqueIndexedTriangleIndexData.BackingArray, GCHandleType.Pinned);
                opaqueIndexedTriangleIndex.Count       = opaqueIndexedTriangleIndexData.Count;
                transparentIndexedTriangleIndex.Handle = GCHandle.Alloc(transparentIndexedTriangleIndexData.BackingArray, GCHandleType.Pinned);
                transparentIndexedTriangleIndex.Count  = transparentIndexedTriangleIndexData.Count;

                opaqueTriangleVertex.Handle      = GCHandle.Alloc(opaqueTriangleVertexData.BackingArray, GCHandleType.Pinned);
                opaqueTriangleVertex.Count       = opaqueTriangleVertexData.Count;
                transparentTriangleVertex.Handle = GCHandle.Alloc(transparentTriangleVertexData.BackingArray, GCHandleType.Pinned);
                transparentTriangleVertex.Count  = transparentTriangleVertexData.Count;

                opaqueLineVertex.Handle      = GCHandle.Alloc(opaqueLineVertexData.BackingArray, GCHandleType.Pinned);
                opaqueLineVertex.Count       = opaqueLineVertexData.Count;
                transparentLineVertex.Handle = GCHandle.Alloc(transParentLineVertexData.BackingArray, GCHandleType.Pinned);
                transparentLineVertex.Count  = transParentLineVertexData.Count;

                renderCacheDirty = false;

                NotifyRenderCacheUpdated();
            }

            DebugRenderControl.gl.Enable(OpenGL.GL_COLOR_MATERIAL);
            DebugRenderControl.gl.ColorMaterial(OpenGL.GL_FRONT_AND_BACK, OpenGL.GL_AMBIENT_AND_DIFFUSE);

            // Render opaque materials
            DebugRenderControl.gl.Disable(OpenGL.GL_BLEND);

            // Render triangle array(s) - Not using VBOs but should not cause major performance issue (VBOs don't help if data changes every frame)
            RenderArrays(opaqueIndexedTriangleVertex, opaqueIndexedTriangleIndex, true);

            // Render triangle array(s) - Not using VBOs but should not cause major performance issue (VBOs don't help if data changes every frame)
            RenderArrays(opaqueTriangleVertex, null, true);

            // Render line array - Not using VBOs but should not cause major performance issue (VBOs don't help if data changes every frame)
            RenderArrays(opaqueLineVertex, null, false);

            // Render transparent materials
            DebugRenderControl.gl.Enable(OpenGL.GL_BLEND);
            DebugRenderControl.gl.BlendFunc(OpenGL.GL_SRC_ALPHA, OpenGL.GL_ONE_MINUS_SRC_ALPHA);

            // Render triangle array(s) - Not using VBOs but should not cause major performance issue (VBOs don't help if data changes every frame)
            RenderArrays(transparentIndexedTriangleVertex, transparentIndexedTriangleIndex, true);

            // Render triangle array(s) - Not using VBOs but should not cause major performance issue (VBOs don't help if data changes every frame)
            RenderArrays(transparentTriangleVertex, null, true);

            // Render line array - Not using VBOs but should not cause major performance issue (VBOs don't help if data changes every frame)
            RenderArrays(transparentLineVertex, null, false);
        }