MeshBatch now renders with or without textures.

General structure clean up as well.
This commit is contained in:
2020-06-23 23:53:24 -05:00
parent 6a19d1f5c7
commit e781aea776
14 changed files with 122 additions and 112 deletions

View File

@@ -2,6 +2,7 @@ using System;
using System.Drawing;
using System.Numerics;
using SDL2;
using SlatedGameToolkit.Framework;
using SlatedGameToolkit.Framework.Graphics.Render;
using SlatedGameToolkit.Framework.Graphics.Render.Programs;
using SlatedGameToolkit.Framework.Graphics.Textures;
@@ -19,8 +20,8 @@ namespace SlatedGameToolkit.Tools.Utilities.Playground
private WindowContext window;
private Camera2D camera;
private MeshBatch renderer;
private Texture texture;
private Sprite2D sprite;
private Texture logoTexture, fillerTexture;
private RectangleMesh logo, textureTester, untextured;
public WindowContext CurrentWindow { get { return window;}}
@@ -36,7 +37,8 @@ namespace SlatedGameToolkit.Tools.Utilities.Playground
public void Deinitialize()
{
texture.Dispose();
logoTexture.Dispose();
fillerTexture.Dispose();
renderer.Dispose();
window.Dispose();
}
@@ -51,16 +53,34 @@ namespace SlatedGameToolkit.Tools.Utilities.Playground
window = new WindowContext("SlatedGameToolkit Playground");
camera = new Camera2D(2, 2);
renderer = new MeshBatch(camera);
texture = CommonLoaders.LoadTexture("Resources/Playground/yhdnbgnc.png", null);
sprite = new Sprite2D(texture, Color.White);
sprite.X = -0.5f;
sprite.Y = -0.5f;
logoTexture = CommonLoaders.LoadTexture("Resources/Playground/yhdnbgnc.png", null);
logo = new RectangleMesh(logoTexture, Color.White);
logo.Width = 0.5f;
logo.Height = 0.5f;
logo.X = -0.25f;
logo.Y = -0.25f;
fillerTexture = CommonLoaders.LoadTexture("Resources/Playground/filler.png", null);
textureTester = new RectangleMesh(fillerTexture, Color.White);
textureTester.Width = 0.15f;
textureTester.Height = 0.15f;
textureTester.X = 0.25f;
untextured = new RectangleMesh(null, Color.Red);
untextured.Width = 0.15f;
untextured.Height = 0.1f;
untextured.X = 0.25f;
untextured.Y = - 0.15f;
}
public void Render(double delta)
{
renderer.Begin(Matrix4x4.Identity);
renderer.Draw(sprite);
renderer.Draw(logo);
renderer.Draw(textureTester);
renderer.Draw(untextured);
renderer.End();
}