a
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
using System.Numerics;
|
||||
using Elements.Assets;
|
||||
using Hexa.NET.ImGui;
|
||||
using Hexa.NET.OpenGL;
|
||||
using SDL3;
|
||||
@@ -55,31 +54,6 @@ public sealed unsafe class OpenGLTexture : IDisposable
|
||||
}
|
||||
}
|
||||
|
||||
public static OpenGLTexture FromBitmap2D(GL gl, Bitmap2D bmp)
|
||||
{
|
||||
if (bmp == null) throw new ArgumentNullException(nameof(bmp));
|
||||
|
||||
int width = bmp.Size.x;
|
||||
int height = bmp.Size.y;
|
||||
// Ensure we upload RGBA8 as unsigned bytes
|
||||
byte[] pixels = new byte[width * height * 4];
|
||||
for (int y = 0; y < height; ++y)
|
||||
{
|
||||
for (int x = 0; x < width; ++x)
|
||||
{
|
||||
var p = bmp.GetPixel32(x, y);
|
||||
int idx = (y * width + x) * 4;
|
||||
pixels[idx + 0] = p.r;
|
||||
pixels[idx + 1] = p.g;
|
||||
pixels[idx + 2] = p.b;
|
||||
pixels[idx + 3] = p.a;
|
||||
}
|
||||
}
|
||||
|
||||
uint tex = UploadRgba32FromPixels(gl, pixels, width, height);
|
||||
return new OpenGLTexture(gl, tex, width, height);
|
||||
}
|
||||
|
||||
public static OpenGLTexture FromSurface(GL gl, nint surface, string? path = null)
|
||||
{
|
||||
if (surface == nint.Zero)
|
||||
|
||||
Reference in New Issue
Block a user