Skip to content
This repository has been archived by the owner on Oct 22, 2024. It is now read-only.

Commit

Permalink
Fix format issues
Browse files Browse the repository at this point in the history
    - Fix format issues in QuadBatchRenderer
  • Loading branch information
Phoenixfirewingz committed Jun 16, 2023
1 parent ae197c8 commit 987d25c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions renderer/QuadBatchRenderer.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

using Avalonia.OpenGL;
using OpenTK.Mathematics;
using SquareSmash.utils;
Expand Down Expand Up @@ -89,6 +90,8 @@ public QuadBatchRenderer(GlInterface gl, GlExtrasInterface ext)
GLE.BindVertexArray(0);
}

// pre calculate the vertex so that we don't need to spent cpu cycles at rime-time to calculate the vertex
// the can be compliantly expensive
public static Vertex[] PreMakeQuad(Vector2 position, Vector2 size, Colour3 color)
{
var quad = new Vertex[6]; // Use 6 vertices for a quad triangle strip
Expand All @@ -98,6 +101,14 @@ public static Vertex[] PreMakeQuad(Vector2 position, Vector2 size, Colour3 color
modelTransform *= Matrix4.CreateTranslation(new Vector3(position.X, position.Y, -1.0f));
modelTransform *= Matrix4.CreateScale(new Vector3(size.X, size.Y, 1.0f));

/* Idea of how vertex are laded out
* 0,0-------------------------------------0,1
* | ~ |
* | ~ |
* | ~ |
* 1,0-------------------------------------1,1
*/

Vector4 transform_0 = (new Vector4(-1.0f, -1.0f, -1.0f, 1.0f) * projectionMatrix * viewMatrix * modelTransform);
Vector3 scale_down_0 = new Vector3(transform_0.X, transform_0.Y, transform_0.Z) / transform_0.Z;
quad[0].Position = scale_down_0.Xy;
Expand Down
2 changes: 1 addition & 1 deletion renderer/Windows/DiscWindow.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public DiscWindow()
musicPlayer.Init(new Mp3FileReader(AssetUtil.OpenEmbeddedFile("assets.sounds.music.mp3")));
UpdateThread = new Thread(() => { Instance.Update(); });
UpdateThread.Start();
musicPlayer.Play();
//musicPlayer.Play();
}

private void OnKeyDown(object sender, KeyEventArgs e)
Expand Down

0 comments on commit 987d25c

Please sign in to comment.