Skip to content

Commit

Permalink
Fixed Texture render sorting
Browse files Browse the repository at this point in the history
  • Loading branch information
MrScautHD committed Sep 8, 2024
1 parent 4213730 commit d04c41a
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
8 changes: 4 additions & 4 deletions src/Bliss.Test/Game.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ protected virtual void FixedUpdate() { }

protected virtual void Draw(GraphicsDevice graphicsDevice, CommandList commandList) {
this.CommandList.Begin();
this.CommandList.SetFramebuffer(this.GraphicsDevice.SwapchainFramebuffer);
this.CommandList.SetFramebuffer(graphicsDevice.SwapchainFramebuffer);
this.CommandList.ClearColorTarget(0, Color.DarkGray.ToRgbaFloat());

this._spriteBatch.Begin(commandList);
Expand All @@ -119,13 +119,13 @@ protected virtual void Draw(GraphicsDevice graphicsDevice, CommandList commandLi
int textSize = 36;
string text = "This is my first FONT!!!";
Vector2 measureTextSize = this._font.MeasureText(text, textSize);
this._spriteBatch.DrawText(this._font, text, new Vector2(this.Window.Width / 2.0F - (measureTextSize.X / 2.0F), this.Window.Height / 1.25F - (measureTextSize.Y / 2.0F)), textSize, rotation: 0);
this._spriteBatch.DrawText(this._font, text, new Vector2(this.Window.Width / 2.0F - (measureTextSize.X / 2.0F), this.Window.Height / 2.25F - (measureTextSize.Y / 2.0F)), textSize);

this._spriteBatch.End();

this.CommandList.End();
this.GraphicsDevice.SubmitCommands(this.CommandList);
this.GraphicsDevice.SwapBuffers();
graphicsDevice.SubmitCommands(this.CommandList);
graphicsDevice.SwapBuffers();
}

protected virtual void OnClose() { }
Expand Down
3 changes: 2 additions & 1 deletion src/Bliss/CSharp/Geometry/Vertex3D.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
using System.Numerics;
using System.Runtime.InteropServices;
using Bliss.CSharp.Colors;
using Veldrid;

namespace Bliss.CSharp.Geometry;

[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct Vertex3D {

// TODO: Add VertexLayout like Vertex2D.
Expand Down
3 changes: 2 additions & 1 deletion src/Bliss/CSharp/Graphics/Rendering/Sprites/SpriteBatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ public void End() {
}

this._begun = false;
this.Flush();
}

// TODO: Add Methods like: BeginShaderMode (Replace the Pipeline system), BeginBlendMode(), BeginScissorMode.
Expand Down Expand Up @@ -206,7 +207,7 @@ public void DrawTexture(Texture2D texture, SamplerType samplerType, Vector2 posi

Sampler sampler = GraphicsHelper.GetSampler(this.GraphicsDevice, samplerType);

if (this._currentTexture != texture || this._currentSampler != sampler) { // TODO: FIX SORTING (Without the if check it would work but check it pls!)
if (this._currentTexture != texture || this._currentSampler != sampler) {
this.Flush();
}

Expand Down
3 changes: 2 additions & 1 deletion src/Bliss/CSharp/Textures/Texture2D.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Runtime.InteropServices;
using Bliss.CSharp.Logging;
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.PixelFormats;
using Veldrid;
Expand Down Expand Up @@ -120,6 +119,8 @@ public unsafe void UpdateData<T>(ReadOnlySpan<T> data, Rectangle? rectangle = nu
/// <param name="graphicsDevice">The graphics device on which to create the texture.</param>
private unsafe Texture CreateDeviceTexture(GraphicsDevice graphicsDevice) {
// TODO: DO MSSA: this.GraphicsDevice.GetSampleCountLimit(this.Format, false);
//Texture multiSampledTexture = graphicsDevice.ResourceFactory.CreateTexture(TextureDescription.Texture2D(this.Width, Height, 1, 1, this.Format, TextureUsage.RenderTarget, TextureSampleCount.Count8));
//Framebuffer framebuffer = graphicsDevice.ResourceFactory.CreateFramebuffer(new FramebufferDescription(null, multiSampledTexture));

Texture texture = graphicsDevice.ResourceFactory.CreateTexture(TextureDescription.Texture2D(this.Width, this.Height, this.MipLevels, 1, this.Format, TextureUsage.Sampled));

Expand Down

0 comments on commit d04c41a

Please sign in to comment.