예제 #1
0
        public IBuffer GetVertexBuffer(VertexFormat vertexFormat, BufferUsageHint bufferUsageHint)
        {
            if (Configuration.useGl1 || Configuration.useOpenRL)
            {
                //  \todo Do index remapping due to lack on DrawElementsBaseVertex()
                return(BufferFactory.Create(vertexFormat, bufferUsageHint));
            }
            //return BufferFactory.Create(vertexFormat, bufferUsageHint);
#if true
            lock (this)
            {
                var kvp = new KeyValuePair <VertexFormat, BufferUsageHint>(vertexFormat, bufferUsageHint);
                if (vertexBuffers.ContainsKey(kvp))
                {
                    //Console.WriteLine("Returning old vertex buffer, vertex format = " + vertexFormat.ToString());
                    if (vertexFormat.Stride != vertexBuffers[kvp].VertexFormat.Stride)
                    {
                        throw new Exception("");
                    }
                    return(vertexBuffers[kvp]);
                }
                //Console.WriteLine("Creating new vertex buffer, vertex format = " + vertexFormat.ToString());
                var buffer = BufferFactory.Create(vertexFormat, bufferUsageHint);
                vertexBuffers[kvp] = buffer;
                return(buffer);
            }
#endif
        }
예제 #2
0
        public IBuffer GetIndexBuffer(DrawElementsType indexType, BufferUsageHint bufferUsageHint)
        {
            if (RenderStack.Graphics.Configuration.useGl1 || Configuration.useOpenRL)
            {
                //  \todo Do index remapping due to lack on DrawElementsBaseVertex()
                return(BufferFactory.Create(indexType, bufferUsageHint));
            }
//            return new Buffer(indexType, bufferUsageHint);
#if true
            lock (this)
            {
                var kvp = new KeyValuePair <DrawElementsType, BufferUsageHint>(indexType, bufferUsageHint);
                if (indexBuffers.ContainsKey(kvp))
                {
                    //Debug.WriteLine("Returning old index buffer, index type = " + indexType.ToString());
                    return(indexBuffers[kvp]);
                }
                //Debug.WriteLine("Creating new index buffer, index type = " + indexType.ToString());
                var buffer = BufferFactory.Create(indexType, bufferUsageHint);
                indexBuffers[kvp] = buffer;
                return(buffer);
            }
#endif
        }