mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/PCK-Studio.git
synced 2026-05-24 20:44:33 +00:00
SceneViewport - Add proper class disposal
This commit is contained in:
@@ -226,6 +226,7 @@ namespace PckStudio.Forms.Editor
|
||||
|
||||
private void CustomSkinEditor_FormClosing(object sender, FormClosingEventArgs e)
|
||||
{
|
||||
renderer3D1.Dispose();
|
||||
}
|
||||
|
||||
private void outlineColorButton_Click(object sender, EventArgs e)
|
||||
|
||||
@@ -58,10 +58,9 @@ namespace PckStudio.Rendering
|
||||
private int refreshRate = 60;
|
||||
private Timer timer;
|
||||
|
||||
private VertexArray VAO;
|
||||
private VertexBuffer VBO;
|
||||
private IndexBuffer IBO;
|
||||
private ShaderProgram colorShader;
|
||||
private VertexArray VAO;
|
||||
private IndexBuffer IBO;
|
||||
private bool isInitialized;
|
||||
|
||||
protected void Init()
|
||||
@@ -71,9 +70,9 @@ namespace PckStudio.Rendering
|
||||
Debug.Fail("Already Initializted.");
|
||||
return;
|
||||
}
|
||||
MakeCurrent();
|
||||
colorShader = ShaderProgram.Create(Resources.plainColorVertexShader, Resources.plainColorFragmentShader);
|
||||
VAO = new VertexArray();
|
||||
VBO = new VertexBuffer();
|
||||
IBO = IndexBuffer.Create(
|
||||
0, 1,
|
||||
1, 2,
|
||||
@@ -92,7 +91,7 @@ namespace PckStudio.Rendering
|
||||
VertexBufferLayout layout = new VertexBufferLayout();
|
||||
layout.Add(ShaderDataType.Float3);
|
||||
layout.Add(ShaderDataType.Float4);
|
||||
VAO.AddBuffer(VBO, layout);
|
||||
VAO.AddNewBuffer(layout);
|
||||
isInitialized = true;
|
||||
}
|
||||
|
||||
@@ -108,6 +107,20 @@ namespace PckStudio.Rendering
|
||||
isInitialized = false;
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
timer.Stop();
|
||||
timer.Dispose();
|
||||
}
|
||||
MakeCurrent();
|
||||
VAO.Dispose();
|
||||
IBO.Dispose();
|
||||
colorShader.Dispose();
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
|
||||
protected void DrawBoundingBox(Matrix4 transform, BoundingBox boundingBox, Color color)
|
||||
{
|
||||
@@ -139,7 +152,7 @@ namespace PckStudio.Rendering
|
||||
];
|
||||
|
||||
VAO.Bind();
|
||||
VBO.SetData(vertices);
|
||||
VAO.GetBuffer(0).SetData(vertices);
|
||||
IBO.Bind();
|
||||
GL.DrawElements(PrimitiveType.Lines, IBO.GetCount(), DrawElementsType.UnsignedInt, 0);
|
||||
GL.DepthFunc(DepthFunction.Less);
|
||||
|
||||
Reference in New Issue
Block a user