public byte[] GetTextureData(TextureView view)
        {
            int size = 0;

            for (int level = 0; level < view.Info.Levels; level++)
            {
                size += view.Info.GetMipSize(level);
            }

            EnsureBuffer(size);

            GL.BindBuffer(BufferTarget.PixelPackBuffer, _copyBufferHandle);

            view.WriteToPbo(0, false);

            GL.BindBuffer(BufferTarget.PixelPackBuffer, 0);

            byte[] data = new byte[size];

            Sync();

            Marshal.Copy(_bufferMap, data, 0, size);

            return(data);
        }
Beispiel #2
0
        public unsafe ReadOnlySpan <byte> GetTextureData(TextureView view, int size)
        {
            EnsureBuffer(size);

            GL.BindBuffer(BufferTarget.PixelPackBuffer, _copyBufferHandle);

            view.WriteToPbo(0, false);

            GL.BindBuffer(BufferTarget.PixelPackBuffer, 0);

            Sync();

            return(new ReadOnlySpan <byte>(_bufferMap.ToPointer(), size));
        }