Ejemplo n.º 1
0
 public static TextureHandle CreateTexture2D(int width, int height, int bytes_per_pixel, bool has_mips, int num_layers, TextureFormat tex_format, TextureFlags flags, IntPtr pixel_data)
 {
     unsafe
     {
         Memory *      data = AllocGraphicsMemoryBuffer(pixel_data, width * height * bytes_per_pixel);
         TextureHandle tex  = Bgfx.create_texture_2d((ushort)width, (ushort)height, has_mips, (ushort)num_layers, tex_format, (ulong)flags, data);
         return(tex);
     }
 }
Ejemplo n.º 2
0
        public unsafe static Memory *load_mem(FileStream reader)
        {
            var         size = reader.Length;
            Memory *    mem  = alloc((uint)size);
            Span <byte> span = new Span <byte>(mem->data, (int)mem->size);

            reader.Read(span);
            mem->data[mem->size - 1] = (byte)'\0';
            return(mem);
        }
Ejemplo n.º 3
0
 public static TextureHandle CreateDynamicTexture2D(int width, int height, bool has_mips, int num_layers, TextureFormat tex_format, TextureFlags flags, byte[] pixel_data)
 {
     unsafe
     {
         Memory *      data = AllocGraphicsMemoryBuffer(pixel_data);
         TextureHandle tex  = Bgfx.create_texture_2d((ushort)width, (ushort)height, has_mips, (ushort)num_layers, tex_format, (ulong)flags, null);
         Bgfx.update_texture_2d(tex, 0, 0, 0, 0, (ushort)width, (ushort)height, data, ushort.MaxValue);
         return(tex);
     }
 }