mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/PCK-Studio.git
synced 2026-05-25 13:56:49 +00:00
Texture.cs - Add PixelFormat and InternalPixelFormat field
This commit is contained in:
@@ -518,14 +518,16 @@ namespace PckStudio.Rendering
|
||||
? Image.FromFile(customSkyboxFilepath)
|
||||
: Resources.DefaultSkyTexture;
|
||||
|
||||
_skyboxTexture = new CubeTexture(skyboxImage, 1);
|
||||
_skyboxTexture = new CubeTexture(1);
|
||||
_skyboxTexture.InternalPixelFormat = PixelInternalFormat.Rgb8;
|
||||
_skyboxTexture.PixelFormat = OpenTK.Graphics.OpenGL.PixelFormat.Bgra;
|
||||
_skyboxTexture.MinFilter = TextureMinFilter.Linear;
|
||||
_skyboxTexture.MagFilter = TextureMagFilter.Linear;
|
||||
|
||||
_skyboxTexture.WrapS = TextureWrapMode.ClampToEdge;
|
||||
_skyboxTexture.WrapT = TextureWrapMode.ClampToEdge;
|
||||
_skyboxTexture.WrapR = TextureWrapMode.ClampToEdge;
|
||||
|
||||
_skyboxTexture.SetTexture(skyboxImage);
|
||||
GLErrorCheck();
|
||||
}
|
||||
|
||||
|
||||
@@ -12,14 +12,12 @@ namespace PckStudio.Rendering.Texture
|
||||
{
|
||||
internal class CubeTexture : Texture
|
||||
{
|
||||
public CubeTexture(Image cubeTexture, int slot)
|
||||
: base(TextureTarget.TextureCubeMap)
|
||||
public CubeTexture(int slot) : base(TextureTarget.TextureCubeMap)
|
||||
{
|
||||
Slot = slot;
|
||||
LoadImageData(cubeTexture);
|
||||
}
|
||||
|
||||
public void LoadImageData(Image image)
|
||||
public void SetTexture(Image image)
|
||||
{
|
||||
Bind();
|
||||
|
||||
@@ -52,7 +50,7 @@ namespace PckStudio.Rendering.Texture
|
||||
{
|
||||
var texture = new Bitmap(faces[i]);
|
||||
BitmapData data = texture.LockBits(new Rectangle(Point.Empty, texture.Size), ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
|
||||
GL.TexImage2D(TextureTarget.TextureCubeMapPositiveX + i, 0, PixelInternalFormat.Rgb8, widthPerFace, heightPerFace, 0, OpenTK.Graphics.OpenGL.PixelFormat.Bgra, PixelType.UnsignedByte, data.Scan0);
|
||||
GL.TexImage2D(TextureTarget.TextureCubeMapPositiveX + i, 0, InternalPixelFormat, widthPerFace, heightPerFace, 0, PixelFormat, PixelType.UnsignedByte, data.Scan0);
|
||||
}
|
||||
Unbind();
|
||||
}
|
||||
|
||||
@@ -11,6 +11,9 @@ namespace PckStudio.Rendering.Texture
|
||||
|
||||
protected readonly TextureTarget Target;
|
||||
|
||||
public PixelFormat PixelFormat { get; set; }
|
||||
public PixelInternalFormat InternalPixelFormat { get; set; }
|
||||
|
||||
public TextureMinFilter MinFilter
|
||||
{
|
||||
get => minFilter;
|
||||
|
||||
@@ -9,17 +9,10 @@ namespace PckStudio.Rendering.Texture
|
||||
{
|
||||
internal class Texture2D : Texture
|
||||
{
|
||||
public OpenTK.Graphics.OpenGL.PixelFormat PixelFormat { get; set; }
|
||||
public PixelInternalFormat InternalPixelFormat { get; set; }
|
||||
|
||||
public Texture2D(int slot) : this()
|
||||
public Texture2D(int slot) : base(TextureTarget.Texture2D)
|
||||
{
|
||||
Slot = slot;
|
||||
}
|
||||
|
||||
private Texture2D() : base(TextureTarget.Texture2D)
|
||||
{
|
||||
}
|
||||
|
||||
public void SetSize(Size size)
|
||||
{
|
||||
@@ -37,13 +30,13 @@ namespace PckStudio.Rendering.Texture
|
||||
bitmap.UnlockBits(data);
|
||||
Unbind();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Unbind();
|
||||
GL.DeleteTexture(_id);
|
||||
}
|
||||
|
||||
|
||||
public void AttachToFramebuffer(FrameBuffer frameBuffer, FramebufferAttachment attachment)
|
||||
{
|
||||
frameBuffer.Bind();
|
||||
|
||||
Reference in New Issue
Block a user