Move Common functionality to Core project & rendering and Model support as well

This commit is contained in:
miku-666
2025-09-01 23:03:39 +02:00
parent 698056a0a0
commit 9656c8b48d
177 changed files with 5979 additions and 1279 deletions

View File

@@ -0,0 +1,39 @@
using System;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Imaging;
using OpenTK;
using OpenTK.Graphics.OpenGL;
namespace PckStudio.Rendering.Texture
{
public class Texture2D : Texture
{
public Texture2D() : base(TextureTarget.Texture2D)
{
}
public void SetSize(Size size)
{
Bind();
GL.TexImage2D(TextureTarget.Texture2D, 0, InternalPixelFormat, size.Width, size.Height, 0, PixelFormat, PixelType.UnsignedByte, IntPtr.Zero);
Unbind();
}
public override void SetTexture(Image image)
{
Bind();
var bitmap = new Bitmap(image);
BitmapData data = bitmap.LockBits(new Rectangle(0, 0, bitmap.Width, bitmap.Height), ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
GL.TexImage2D(TextureTarget.Texture2D, 0, InternalPixelFormat, bitmap.Width, bitmap.Height, 0, PixelFormat, PixelType.UnsignedByte, data.Scan0);
bitmap.UnlockBits(data);
Unbind();
}
public void AttachToFramebuffer(FrameBuffer frameBuffer, FramebufferAttachment attachment)
{
frameBuffer.Bind();
GL.FramebufferTexture2D(FramebufferTarget.Framebuffer, attachment, Target, _GL_Id, 0);
}
}
}