Ejemplo n.º 1
0
        public override void BufferSubData(
            OpenGLDevice device,
            OpenGLDevice.GLenum buffer, bool discard,
            OpenGLDevice.IOpenGLBuffer handle,
            int elementSizeInBytes, int offsetInBytes,
            Array data, int startIndex, int elementCount
            )
        {
            if (discard)
            {
                device.glBufferData(
                    OpenGLDevice.GLenum.GL_ELEMENT_ARRAY_BUFFER,
                    (IntPtr)handle.BufferSize,
                    IntPtr.Zero,
                    handle.Dynamic
                    );
            }

            GCHandle dataHandle = GCHandle.Alloc(data, GCHandleType.Pinned);

            device.glBufferSubData(
                OpenGLDevice.GLenum.GL_ELEMENT_ARRAY_BUFFER,
                offsetInBytes,
                elementSizeInBytes * elementCount,
                (IntPtr)(dataHandle.AddrOfPinnedObject().ToInt64() + startIndex * elementSizeInBytes)
                );

            dataHandle.Free();
        }
Ejemplo n.º 2
0
 public abstract void BufferSubData(
     OpenGLDevice device,
     OpenGLDevice.GLenum buffer, bool discard,
     OpenGLDevice.IOpenGLBuffer bufferHandle,
     int elementSizeInBytes, int offsetInBytes,
     Array data, int startIndex, int elementCount
     );
Ejemplo n.º 3
0
        public override void BufferSubData(
            OpenGLDevice device,
            OpenGLDevice.GLenum buffer, bool discard,
            OpenGLDevice.IOpenGLBuffer handle,
            int elementSizeInBytes, int offsetInBytes,
            Array data, int startIndex, int elementCount
            )
        {
            var gl = GetWebGLContext();

            if (discard)
            {
                gl.bufferData(
                    (int)buffer,
                    handle.BufferSize,
                    (int)handle.Dynamic
                    );
            }

            var view = Verbatim.Expression("new Uint8Array($0.buffer, $1, $2)", data, offsetInBytes, elementSizeInBytes * elementCount);

            gl.bufferSubData((int)buffer, startIndex, view);
        }