MeshBatch now renders with or without textures.
General structure clean up as well.
This commit is contained in:
parent
6a19d1f5c7
commit
e781aea776
@ -7,7 +7,6 @@ using Serilog.Core;
|
||||
using SlatedGameToolkit.Framework.Exceptions;
|
||||
using SlatedGameToolkit.Framework.Graphics.Textures;
|
||||
using SlatedGameToolkit.Framework.Graphics.Window;
|
||||
using SlatedGameToolkit.Framework.Input;
|
||||
using SlatedGameToolkit.Framework.Input.Devices;
|
||||
using SlatedGameToolkit.Framework.StateSystem;
|
||||
using SlatedGameToolkit.Framework.StateSystem.States;
|
||||
@ -19,7 +18,6 @@ namespace SlatedGameToolkit.Framework {
|
||||
/// </summary>
|
||||
public static class GameEngine {
|
||||
private const int GL_MAJOR_VER = 3, GL_MINOR_VER = 3;
|
||||
public static TextureData FillerTextureData {get; private set;}
|
||||
public static bool Debugging { get; set; }
|
||||
public static Logger Logger { get; private set; }
|
||||
private static readonly object ignitionLock = new object();
|
||||
@ -33,8 +31,8 @@ namespace SlatedGameToolkit.Framework {
|
||||
/// The amount of updates per second.
|
||||
///
|
||||
/// If greater than 0, game loop updates will be fixed (time steps).
|
||||
/// More specifically, it will figure out how many updates to perform per frame to allow for physics steps
|
||||
/// to be calculated based on a constant time step.
|
||||
/// More specifically, the amount of updates performed per frame to allow for physics calculations
|
||||
/// to be calculated based on a constant time step will be calculated automatically.
|
||||
///
|
||||
/// If set to 0 or less, updates will be as fast as possible.
|
||||
/// </summary>
|
||||
@ -164,7 +162,7 @@ namespace SlatedGameToolkit.Framework {
|
||||
timePassedFromLastUpdate += difference;
|
||||
while (timePassedFromLastUpdate > updateDeltaTime) {
|
||||
//Updates.
|
||||
manager.update(updateDeltaTime.TotalMilliseconds <= 0 ? timePassedFromLastUpdate.TotalSeconds : updateDeltaTime.TotalSeconds);
|
||||
manager.update(updateDeltaTime.TotalSeconds <= 0 ? timePassedFromLastUpdate.TotalSeconds : updateDeltaTime.TotalSeconds);
|
||||
timePassedFromLastUpdate -= updateDeltaTime;
|
||||
if (updateDeltaTime.TotalSeconds <= 0) break;
|
||||
}
|
||||
@ -172,7 +170,7 @@ namespace SlatedGameToolkit.Framework {
|
||||
timePassedFromLastRender += difference;
|
||||
if (timePassedFromLastRender > frameDeltaTime) {
|
||||
//Draw calls.
|
||||
manager.render(timePassedFromLastUpdate.TotalSeconds);
|
||||
manager.render(updateDeltaTime.TotalSeconds <= 0 ? updateDeltaTime.TotalSeconds : (timePassedFromLastUpdate / updateDeltaTime));
|
||||
timePassedFromLastRender = TimeSpan.Zero;
|
||||
}
|
||||
}
|
||||
@ -242,8 +240,6 @@ namespace SlatedGameToolkit.Framework {
|
||||
SDL.SDL_GL_SetAttribute(SDL.SDL_GLattr.SDL_GL_CONTEXT_PROFILE_MASK, SDL.SDL_GLprofile.SDL_GL_CONTEXT_PROFILE_CORE) < 0)
|
||||
throw new FrameworkSDLException(string.Format("Unable to load correct OpenGL version {0}.{1}.0 Core.", GL_MINOR_VER, GL_MAJOR_VER));
|
||||
|
||||
LoadEngineAssets();
|
||||
|
||||
thread = new Thread(Loop);
|
||||
thread.Name = "SGTK-Engine";
|
||||
thread.Priority = ThreadPriority.AboveNormal;
|
||||
@ -252,30 +248,6 @@ namespace SlatedGameToolkit.Framework {
|
||||
}
|
||||
}
|
||||
|
||||
private unsafe static void LoadEngineAssets() {
|
||||
byte[] buffer = EmbeddedResourceUtils.ReadEmbeddedResourceData("filler.png");
|
||||
fixed (void* ptr = &buffer[0]) {
|
||||
IntPtr rwOps = SDL.SDL_RWFromConstMem(new IntPtr(ptr), buffer.Length * sizeof(byte));
|
||||
IntPtr surfacePtr = SDL_image.IMG_Load_RW(rwOps, 1);
|
||||
SDL.SDL_Surface surface = Marshal.PtrToStructure<SDL.SDL_Surface>(surfacePtr);
|
||||
|
||||
SDL.SDL_PixelFormat pixelFormat = Marshal.PtrToStructure<SDL.SDL_PixelFormat>(surface.format);
|
||||
if (pixelFormat.format != SDL.SDL_PIXELFORMAT_RGBA8888) {
|
||||
IntPtr convertedPtr = SDL.SDL_ConvertSurfaceFormat(surfacePtr, SDL.SDL_PIXELFORMAT_RGBA8888, 0);
|
||||
if (convertedPtr == null) throw new OptionalSDLException();
|
||||
SDL.SDL_FreeSurface(surfacePtr);
|
||||
surfacePtr = convertedPtr;
|
||||
surface = Marshal.PtrToStructure<SDL.SDL_Surface>(surfacePtr);
|
||||
}
|
||||
byte[] data = new byte[surface.pitch * surface.h];
|
||||
|
||||
Marshal.Copy(surface.pixels, data, 0, data.Length);
|
||||
FillerTextureData = new TextureData(surface.w, surface.h, data);
|
||||
|
||||
SDL.SDL_FreeSurface(surfacePtr);
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsRunning() {
|
||||
return !stopped;
|
||||
}
|
||||
|
@ -12,6 +12,9 @@ namespace SlatedGameToolkit.Framework.Graphics.Render
|
||||
private float width, height;
|
||||
private Matrix4x4 lookAtMatrix = Matrix4x4.Identity;
|
||||
private Matrix4x4 view = Matrix4x4.Identity, projection;
|
||||
|
||||
public event EventHandler projectionUpdateEvent;
|
||||
|
||||
public bool Orthographic {
|
||||
get {
|
||||
return orthographic;
|
||||
@ -125,5 +128,9 @@ namespace SlatedGameToolkit.Framework.Graphics.Render
|
||||
this.Position = new Vector3(0, 0, 3);
|
||||
this.CameraFront = -Vector3.UnitZ;
|
||||
}
|
||||
|
||||
private void OnProjectionUpdated() {
|
||||
projectionUpdateEvent?.Invoke(this, new EventArgs());
|
||||
}
|
||||
}
|
||||
}
|
@ -4,9 +4,9 @@ using System.Drawing;
|
||||
using System.Numerics;
|
||||
using SlatedGameToolkit.Framework.Graphics.Textures;
|
||||
|
||||
namespace SlatedGameToolkit.Framework.Graphics.Meshes
|
||||
namespace SlatedGameToolkit.Framework.Graphics.Render
|
||||
{
|
||||
public interface IMeshable
|
||||
public interface IMesh
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
@ -25,7 +25,7 @@ namespace SlatedGameToolkit.Framework.Graphics.Meshes
|
||||
/// The texture for this mesh.
|
||||
/// </summary>
|
||||
/// <value>Texture for this mesh.</value>
|
||||
Texture Texture { get; }
|
||||
ITexture Texture { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The blended color of this mesh.
|
@ -0,0 +1,8 @@
|
||||
namespace SlatedGameToolkit.Framework.Graphics.Render
|
||||
{
|
||||
public interface ITexture
|
||||
{
|
||||
uint Handle {get;}
|
||||
void Use();
|
||||
}
|
||||
}
|
@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Numerics;
|
||||
using SlatedGameToolkit.Framework.Graphics.Meshes;
|
||||
using SlatedGameToolkit.Framework.Graphics.OpenGL;
|
||||
using SlatedGameToolkit.Framework.Graphics.Render.Programs;
|
||||
using SlatedGameToolkit.Framework.Graphics.Render.Shaders;
|
||||
@ -14,11 +13,10 @@ namespace SlatedGameToolkit.Framework.Graphics.Render
|
||||
public class MeshBatch : IDisposable {
|
||||
public GLContext GLContext {get; private set; }
|
||||
private const int VERTEX_LENGTH = 9;
|
||||
private int projLoc, viewLoc, modelLoc;
|
||||
private int projALoc, viewALoc, modelALoc, texturedALoc;
|
||||
private Camera camera;
|
||||
private RenderProgram renderProgram;
|
||||
private Texture texture;
|
||||
private Texture fillerTexture;
|
||||
private ITexture texture;
|
||||
private bool disposed;
|
||||
private VertexArrayBuffers vertexBuffers;
|
||||
public bool Batching { get; private set; }
|
||||
@ -39,7 +37,7 @@ namespace SlatedGameToolkit.Framework.Graphics.Render
|
||||
}
|
||||
this.renderProgram = renderProgram;
|
||||
this.GLContext = renderProgram.GLContext;
|
||||
this.camera = camera;
|
||||
this.camera = camera ?? throw new ArgumentNullException("camera");
|
||||
indices = new uint[BatchVertexSize];
|
||||
lengths = new int[BatchVertexSize];
|
||||
indiceOffsets = new int[BatchVertexSize];
|
||||
@ -51,12 +49,14 @@ namespace SlatedGameToolkit.Framework.Graphics.Render
|
||||
definitions[1] = new VertexAttributeDefinition((uint)GLContext.GetAttribLocation(renderProgram.Handle, "aColor"), 4);
|
||||
definitions[2] = new VertexAttributeDefinition((uint)GLContext.GetAttribLocation(renderProgram.Handle, "aTexCoord"), 2);
|
||||
renderProgram.Use();
|
||||
modelLoc = GLContext.GetUniformLocation(renderProgram.Handle, "models");
|
||||
viewLoc = GLContext.GetUniformLocation(renderProgram.Handle, "view");
|
||||
projLoc = GLContext.GetUniformLocation(renderProgram.Handle, "projection");
|
||||
modelALoc = GLContext.GetUniformLocation(renderProgram.Handle, "models");
|
||||
viewALoc = GLContext.GetUniformLocation(renderProgram.Handle, "view");
|
||||
projALoc = GLContext.GetUniformLocation(renderProgram.Handle, "projection");
|
||||
texturedALoc = GLContext.GetUniformLocation(renderProgram.Handle, "textured");
|
||||
vertexBuffers.defineVertexAttributes(definitions: definitions);
|
||||
|
||||
fillerTexture = new Texture(GameEngine.FillerTextureData);
|
||||
camera.projectionUpdateEvent += ProjectionMatrixChanged;
|
||||
GLContext.UniformMatrix4fv(projALoc, 1, false, camera.ProjectionMatrix.ToColumnMajorArray());
|
||||
}
|
||||
|
||||
public virtual void Begin(Matrix4x4 modelsMatrix) {
|
||||
@ -65,15 +65,18 @@ namespace SlatedGameToolkit.Framework.Graphics.Render
|
||||
this.modelsMatrix = modelsMatrix;
|
||||
}
|
||||
|
||||
public virtual void Draw(IMeshable meshable) {
|
||||
if (meshable.Texture != this.texture) {
|
||||
if (this.texture != null) {
|
||||
Flush();
|
||||
}
|
||||
this.texture = meshable.Texture ?? fillerTexture;
|
||||
/// <summary>
|
||||
/// Draws the given mesh.
|
||||
/// </summary>
|
||||
/// <param name="mesh">Draws the given mesh.</param>
|
||||
public virtual void Draw(IMesh mesh) {
|
||||
if (mesh.Texture?.Handle != this.texture?.Handle) {
|
||||
Flush();
|
||||
this.texture = mesh.Texture;
|
||||
GLContext.Uniform1i(texturedALoc, texture == null ? 0 : 1);
|
||||
}
|
||||
ValueTuple<Vector3, Vector2>[] vertices = meshable.Vertices;
|
||||
uint[] indices = meshable.Elements;
|
||||
ValueTuple<Vector3, Vector2>[] vertices = mesh.Vertices;
|
||||
uint[] indices = mesh.Elements;
|
||||
if (vertices.Length * VERTEX_LENGTH + dataIndex >= data.Length || indices.Length + indicesIndex >= this.indices.Length)
|
||||
Flush();
|
||||
for (int i = 0; i < vertices.Length; i++) {
|
||||
@ -84,13 +87,13 @@ namespace SlatedGameToolkit.Framework.Graphics.Render
|
||||
data[dataIndex] = vertices[i].Item1.Z;
|
||||
dataIndex++;
|
||||
|
||||
data[dataIndex] = meshable.Color.RedAsFloat();
|
||||
data[dataIndex] = mesh.Color.RedAsFloat();
|
||||
dataIndex++;
|
||||
data[dataIndex] = meshable.Color.GreenAsFloat();
|
||||
data[dataIndex] = mesh.Color.GreenAsFloat();
|
||||
dataIndex++;
|
||||
data[dataIndex] = meshable.Color.BlueAsFloat();
|
||||
data[dataIndex] = mesh.Color.BlueAsFloat();
|
||||
dataIndex++;
|
||||
data[dataIndex] = meshable.Color.AlphaAsFloat();
|
||||
data[dataIndex] = mesh.Color.AlphaAsFloat();
|
||||
dataIndex++;
|
||||
|
||||
data[dataIndex] = vertices[i].Item2.X;
|
||||
@ -116,22 +119,22 @@ namespace SlatedGameToolkit.Framework.Graphics.Render
|
||||
}
|
||||
|
||||
protected virtual void Flush() {
|
||||
texture.Use();
|
||||
texture?.Use();
|
||||
renderProgram.Use();
|
||||
vertexBuffers.BufferVertices(data, true);
|
||||
vertexBuffers.BufferIndices(indices, true);
|
||||
GLContext.UniformMatrix4fv(modelLoc, 1, false, modelsMatrix.ToColumnMajorArray());
|
||||
GLContext.UniformMatrix4fv(viewLoc, 1, false, camera.ViewMatrix.ToColumnMajorArray());
|
||||
GLContext.UniformMatrix4fv(projLoc, 1, false, camera.ProjectionMatrix.ToColumnMajorArray());
|
||||
// GLContext.UniformMatrix4fv(modelLoc, 1, false, Matrix4x4.Identity.ToColumnMajorArray());
|
||||
// GLContext.UniformMatrix4fv(viewLoc, 1, false, Matrix4x4.Identity.ToColumnMajorArray());
|
||||
// GLContext.UniformMatrix4fv(projLoc, 1, false, Matrix4x4.Identity.ToColumnMajorArray());
|
||||
GLContext.UniformMatrix4fv(modelALoc, 1, false, modelsMatrix.ToColumnMajorArray());
|
||||
GLContext.UniformMatrix4fv(viewALoc, 1, false, camera.ViewMatrix.ToColumnMajorArray());
|
||||
GLContext.MultiDrawElementsBaseVertex(PrimitiveType.Triangles, lengths, DrawElementsType.UnsignedInt, indiceOffsets, offsetIndex, verticeOffsets);
|
||||
dataIndex = 0;
|
||||
indicesIndex = 0;
|
||||
offsetIndex = 0;
|
||||
}
|
||||
|
||||
private void ProjectionMatrixChanged(object sender, EventArgs args) {
|
||||
GLContext.UniformMatrix4fv(projALoc, 1, false, camera.ProjectionMatrix.ToColumnMajorArray());
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (!disposed)
|
||||
@ -144,22 +147,22 @@ namespace SlatedGameToolkit.Framework.Graphics.Render
|
||||
disposed = true;
|
||||
vertexBuffers.Dispose();
|
||||
renderProgram.Dispose();
|
||||
fillerTexture.Dispose();
|
||||
data = null;
|
||||
indices = null;
|
||||
lengths = null;
|
||||
verticeOffsets = null;
|
||||
camera.projectionUpdateEvent -= ProjectionMatrixChanged;
|
||||
}
|
||||
}
|
||||
|
||||
~MeshBatch()
|
||||
{
|
||||
Dispose(disposing: false);
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(disposing: true);
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
}
|
||||
|
@ -3,9 +3,9 @@ using System.Drawing;
|
||||
using System.Numerics;
|
||||
using SlatedGameToolkit.Framework.Graphics.Textures;
|
||||
|
||||
namespace SlatedGameToolkit.Framework.Graphics.Meshes
|
||||
namespace SlatedGameToolkit.Framework.Graphics.Render
|
||||
{
|
||||
public class RectangleMesh : IMeshable
|
||||
public class RectangleMesh : IMesh
|
||||
{
|
||||
private Matrix4x4 matRot = Matrix4x4.Identity;
|
||||
private bool changed;
|
||||
@ -95,10 +95,29 @@ namespace SlatedGameToolkit.Framework.Graphics.Meshes
|
||||
}
|
||||
}
|
||||
|
||||
public Texture Texture { get; set; }
|
||||
public ITexture Texture { get; set; }
|
||||
|
||||
public Color Color { get; set; }
|
||||
|
||||
public RectangleMesh(ITexture texture, Color color)
|
||||
{
|
||||
this.Texture = texture;
|
||||
this.Color = color;
|
||||
|
||||
this.textureCoords[0].X = 0;
|
||||
this.textureCoords[0].Y = 1;
|
||||
|
||||
this.textureCoords[1].X = 1;
|
||||
this.textureCoords[1].Y = 1;
|
||||
|
||||
this.textureCoords[2].X = 1;
|
||||
this.textureCoords[2].Y = 0;
|
||||
|
||||
this.textureCoords[3].X = 0;
|
||||
this.textureCoords[3].Y = 0;
|
||||
}
|
||||
|
||||
|
||||
private void CalculateVertices() {
|
||||
if (!changed) return;
|
||||
Vector3[] baseVerts = new Vector3[4];
|
||||
@ -109,7 +128,7 @@ namespace SlatedGameToolkit.Framework.Graphics.Meshes
|
||||
|
||||
for (int i = 0; i < vertices.Length; i++)
|
||||
{
|
||||
vertices[i] = new ValueTuple<Vector3, Vector2>(Vector3.Transform(baseVerts[i], matRot), textureCoords[i]);
|
||||
vertices[i] = (Vector3.Transform(baseVerts[i], matRot), textureCoords[i]);
|
||||
}
|
||||
changed = false;
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
using System.Drawing;
|
||||
using SlatedGameToolkit.Framework.Graphics.Meshes;
|
||||
using SlatedGameToolkit.Framework.Graphics.Textures;
|
||||
|
||||
namespace SlatedGameToolkit.Framework.Graphics.Render
|
||||
{
|
||||
public class Sprite2D : RectangleMesh
|
||||
{
|
||||
public Sprite2D(Texture texture, Color color) {
|
||||
this.Texture = texture;
|
||||
this.textureCoords[0].X = 0;
|
||||
this.textureCoords[0].Y = 1;
|
||||
|
||||
this.textureCoords[1].X = 1;
|
||||
this.textureCoords[1].Y = 1;
|
||||
|
||||
this.textureCoords[2].X = 1;
|
||||
this.textureCoords[2].Y = 0;
|
||||
|
||||
this.textureCoords[3].X = 0;
|
||||
this.textureCoords[3].Y = 0;
|
||||
|
||||
this.Color = color;
|
||||
this.Width = 1f;
|
||||
this.Height = 1f;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,16 +1,19 @@
|
||||
using System;
|
||||
using SlatedGameToolkit.Framework.Graphics.OpenGL;
|
||||
using SlatedGameToolkit.Framework.Graphics.Render;
|
||||
using SlatedGameToolkit.Framework.Graphics.Window;
|
||||
using SlatedGameToolkit.Framework.Loader;
|
||||
|
||||
namespace SlatedGameToolkit.Framework.Graphics.Textures
|
||||
{
|
||||
public class Texture : IAssetUseable {
|
||||
public class Texture : IAssetUseable, ITexture {
|
||||
public readonly int width, height;
|
||||
private bool disposed;
|
||||
private GLContext glContext;
|
||||
private uint handle;
|
||||
|
||||
public uint Handle {get { return handle; }}
|
||||
|
||||
/// <summary>
|
||||
/// Creates an OpenGL Texture2D in the given GL Context.
|
||||
/// </summary>
|
||||
|
@ -18,7 +18,7 @@ namespace SlatedGameToolkit.Framework.Loader {
|
||||
/// A delegate that performs the loading of the specific asset.
|
||||
/// </summary>
|
||||
/// <param name="path">The path of the asset.</param>
|
||||
/// <param name="glContext">The context to be used. May be null if called by user.</param>
|
||||
/// <param name="glContext">The context to be used.</param>
|
||||
/// <typeparam name="T">The type of the resulting asset.</typeparam>
|
||||
/// <returns>A loaded, useable asset.</returns>
|
||||
public delegate T LoadAsset<T>(string path, GLContext glContext) where T : IAssetUseable;
|
||||
|
@ -16,7 +16,7 @@ namespace SlatedGameToolkit.Framework.Loader
|
||||
/// Therefore, technically, this function should be able to laod any format SDL2 Image can load.
|
||||
/// </summary>
|
||||
/// <param name="path">The path of the texture to load.</param>
|
||||
/// <param name="glContext">The OpenGL context the texture is to be associated with. </param>
|
||||
/// <param name="glContext">The OpenGL context the texture is to be associated with. May be null.</param>
|
||||
/// <returns>An OpenGL Texture associated with the given context.</returns>
|
||||
public static Texture LoadTexture(string path, GLContext glContext)
|
||||
{
|
||||
|
@ -3,9 +3,15 @@ out vec4 outputColor;
|
||||
|
||||
in vec2 texCoord;
|
||||
in vec4 color;
|
||||
|
||||
uniform bool textured;
|
||||
uniform sampler2D texture0;
|
||||
|
||||
void main()
|
||||
{
|
||||
outputColor = texture(texture0, texCoord) * color;
|
||||
if (textured) {
|
||||
outputColor = texture(texture0, texCoord) * color;
|
||||
} else {
|
||||
outputColor = color;
|
||||
}
|
||||
}
|
@ -46,7 +46,7 @@ namespace SlatedGameToolkit.Framework.StateSystem
|
||||
}
|
||||
currentState.Update(delta);
|
||||
}
|
||||
|
||||
|
||||
internal void render(double delta) {
|
||||
WindowContext windowContext = WindowContextsManager.CurrentWindowContext;
|
||||
windowContext.Context.ClearColor(backgroundColour.RedAsFloat(), backgroundColour.GreenAsFloat(), backgroundColour.BlueAsFloat(), 1f);
|
||||
|
@ -36,7 +36,7 @@ namespace SlatedGameToolkit.Framework.StateSystem.States
|
||||
/// Called in intervals dependent on game loop chose for every render cycle.
|
||||
/// Only called on if this state is the active state, indicated on the last status method called on this implementation (acitvate, and deactivate).
|
||||
/// </summary>
|
||||
/// <param name="delta">The time in seconds that has passed since the last update cycle.</param>
|
||||
/// <param name="delta">If in time-step mode, normalized value representing the time until the next update. Otherwise, the time passed since the last update.</param>
|
||||
void Render(double delta);
|
||||
|
||||
/// <summary>
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user