Exemplo n.º 1
0
 public void Dispose()
 {
     (_shader as IDisposable)?.Dispose();
     _shader = null;
     _vertexArray?.Dispose();
     _vertexArray = null;
 }
Exemplo n.º 2
0
 public UvAnimation(IVertexArrayHandle vertexArrayHandle, ITexture texture, IEnumerable <Box2> uvCoords,
                    int frameTime, UvOffsets offsets)
 {
     _vertexArrayHandle = vertexArrayHandle;
     _texture           = texture;
     _uvCoords          = uvCoords.ToArray();
     _frameTime         = frameTime;
     _offsets           = offsets;
     _frameCount        = _uvCoords.Length;
 }
Exemplo n.º 3
0
 /// <summary>
 /// 创建元素堆
 /// </summary>
 /// <param name="vertexArray">顶点堆</param>
 /// <param name="elements">元素堆</param>
 public ElementArray(IVertexArrayHandle vertexArray, IEnumerable <uint> elements)
 {
     _elements          = elements.ToArray();
     _count             = _elements.Length;
     _vertexArrayHandle = vertexArray;
     _vertexArrayHandle.Bind();
     _elementBufferObject = GL.GenBuffer();
     GL.BindBuffer(BufferTarget.ElementArrayBuffer, _elementBufferObject);
     GL.BufferData(BufferTarget.ElementArrayBuffer, _elements.Length * sizeof(uint), _elements,
                   BufferUsageHint.StaticDraw);
     //_logger.Info($"Create an element array:{_elementBufferObject}");
 }
Exemplo n.º 4
0
 public void Initialize()
 {
     _shader      = new AxisShader();
     _vertexArray = new AxisVertexProvider().ToVertexArray().GetHandle();
 }
Exemplo n.º 5
0
 public static IVertexArrayHandle BindVertexBufferObject(this IVertexArrayHandle handle)
 {
     GL.BindBuffer(BufferTarget.ArrayBuffer, handle.VertexBufferObjectHandle);
     return(handle);
 }
Exemplo n.º 6
0
 /// <summary>
 /// 修改顶点数据
 /// </summary>
 /// <param name="handle">顶点Handle</param>
 /// <param name="offset">字节偏移量</param>
 /// <param name="size">字节数量</param>
 /// <param name="data">字节数据</param>
 /// <remarks>请确保VertexBufferObjectHandle被绑定</remarks>
 /// <returns></returns>
 public static IVertexArrayHandle VertexSubData <T>(this IVertexArrayHandle handle, int offset, int size,
                                                    T[] data) where T : struct
 {
     GL.BufferSubData(BufferTarget.ArrayBuffer, (IntPtr)offset, size, data);
     return(handle);
 }