Skip to content

Commit 02d4706

Browse files
format
1 parent 45ebee3 commit 02d4706

7 files changed

Lines changed: 44 additions & 219 deletions

File tree

Common.Dialogs/FolderItemViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public bool IsSelected
7474
/// <summary>
7575
/// Raised when a property value changes.
7676
/// </summary>
77-
public event PropertyChangedEventHandler? PropertyChanged;
77+
public new event PropertyChangedEventHandler? PropertyChanged;
7878

7979
/// <summary>
8080
/// The parent vm
0 Bytes
Loading
0 Bytes
Loading

CommonLibraryTests/IoFileHandler.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -666,11 +666,12 @@ public void CutFilesFileListNullOrEmptyThrowsFileHandlerException()
666666
/// Cuts the files file list non existent file returns false.
667667
/// </summary>
668668
[TestMethod]
669-
public async Task CutFilesFileListNonExistentFileReturnsFalseAsync()
669+
public Task CutFilesFileListNonExistentFileReturnsFalseAsync()
670670
{
671671
var fileList = new List<string> { "NonExistentFile.txt" };
672672
var result = FileHandleCut.CutFiles(fileList, TestTargetDir, true);
673673
Assert.IsFalse(result);
674+
return Task.CompletedTask;
674675
}
675676

676677
/// <summary>

RenderEngine/RenderBatch.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,7 @@ public void Clear()
296296
public void AddHostAction(Action action)
297297
{
298298
if (action == null) throw new ArgumentNullException(nameof(action));
299+
299300
HostActions.Add(action);
300301
}
301302
}

RenderEngine/Simple2DRenderer.cs

Lines changed: 26 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,11 @@
1414
* - Add text rendering
1515
*/
1616

17-
// ReSharper disable UnusedType.Global
18-
1917
using OpenTK.Graphics.OpenGL4;
2018
using System;
2119

2220
namespace RenderEngine
2321
{
24-
/// <inheritdoc />
2522
/// <summary>
2623
/// Simple GPU-accelerated 2D renderer for colored lines, solid quads, and textured quads.
2724
/// </summary>
@@ -125,24 +122,12 @@ private void EnsureInitialized()
125122
_initialized = true;
126123
}
127124

128-
/// <summary>
129-
/// Flushes the specified batch.
130-
/// </summary>
131-
/// <param name="batch">The batch.</param>
132125
public void Flush(RenderBatch batch)
133126
{
134127
EnsureInitialized();
135128
FlushBatch(batch);
136129
}
137130

138-
/// <summary>
139-
/// Draws the line.
140-
/// </summary>
141-
/// <param name="x0">The x0.</param>
142-
/// <param name="y0">The y0.</param>
143-
/// <param name="x1">The x1.</param>
144-
/// <param name="y1">The y1.</param>
145-
/// <param name="color">The color.</param>
146131
public void DrawLine(
147132
float x0, float y0,
148133
float x1, float y1,
@@ -154,14 +139,6 @@ public void DrawLine(
154139
});
155140
}
156141

157-
/// <summary>
158-
/// Draws the rect outline.
159-
/// </summary>
160-
/// <param name="x">The x.</param>
161-
/// <param name="y">The y.</param>
162-
/// <param name="w">The w.</param>
163-
/// <param name="h">The h.</param>
164-
/// <param name="color">The color.</param>
165142
public void DrawRectOutline(
166143
float x, float y,
167144
float w, float h,
@@ -173,11 +150,6 @@ public void DrawRectOutline(
173150
DrawColoredLines(data);
174151
}
175152

176-
/// <summary>
177-
/// Draws the polyline.
178-
/// </summary>
179-
/// <param name="points">The points.</param>
180-
/// <param name="color">The color.</param>
181153
public void DrawPolyline(
182154
ReadOnlySpan<(float x, float y)> points,
183155
(int r, int g, int b, int a) color)
@@ -331,14 +303,6 @@ public void DrawTexturedQuad((int x, int y) p0, (int x, int y) p1, (int x, int y
331303
GL.BindVertexArray(0);
332304
}
333305

334-
/// <summary>
335-
/// Draws the circle outline.
336-
/// </summary>
337-
/// <param name="cx">The cx.</param>
338-
/// <param name="cy">The cy.</param>
339-
/// <param name="radius">The radius.</param>
340-
/// <param name="segments">The segments.</param>
341-
/// <param name="color">The color.</param>
342306
public void DrawCircleOutline(
343307
float cx, float cy,
344308
float radius,
@@ -351,14 +315,6 @@ public void DrawCircleOutline(
351315
DrawColoredLines(data);
352316
}
353317

354-
/// <summary>
355-
/// Draws the solid circle.
356-
/// </summary>
357-
/// <param name="cx">The cx.</param>
358-
/// <param name="cy">The cy.</param>
359-
/// <param name="radius">The radius.</param>
360-
/// <param name="segments">The segments.</param>
361-
/// <param name="fill">The fill.</param>
362318
public void DrawSolidCircle(
363319
float cx, float cy,
364320
float radius,
@@ -368,14 +324,6 @@ public void DrawSolidCircle(
368324
DrawSolidEllipse(cx, cy, radius, radius, segments, fill);
369325
}
370326

371-
/// <summary>
372-
/// Draws the textured circle.
373-
/// </summary>
374-
/// <param name="cx">The cx.</param>
375-
/// <param name="cy">The cy.</param>
376-
/// <param name="radius">The radius.</param>
377-
/// <param name="segments">The segments.</param>
378-
/// <param name="textureId">The texture identifier.</param>
379327
public void DrawTexturedCircle(
380328
float cx, float cy,
381329
float radius,
@@ -385,15 +333,6 @@ public void DrawTexturedCircle(
385333
DrawTexturedEllipse(cx, cy, radius, radius, segments, textureId);
386334
}
387335

388-
/// <summary>
389-
/// Draws the solid ellipse.
390-
/// </summary>
391-
/// <param name="cx">The cx.</param>
392-
/// <param name="cy">The cy.</param>
393-
/// <param name="radiusX">The radius x.</param>
394-
/// <param name="radiusY">The radius y.</param>
395-
/// <param name="segments">The segments.</param>
396-
/// <param name="fill">The fill.</param>
397336
public void DrawSolidEllipse(
398337
float cx, float cy,
399338
float radiusX, float radiusY,
@@ -459,15 +398,6 @@ public void DrawSolidEllipse(
459398
GL.BindVertexArray(0);
460399
}
461400

462-
/// <summary>
463-
/// Draws the textured ellipse.
464-
/// </summary>
465-
/// <param name="cx">The cx.</param>
466-
/// <param name="cy">The cy.</param>
467-
/// <param name="radiusX">The radius x.</param>
468-
/// <param name="radiusY">The radius y.</param>
469-
/// <param name="segments">The segments.</param>
470-
/// <param name="textureId">The texture identifier.</param>
471401
public void DrawTexturedEllipse(
472402
float cx, float cy,
473403
float radiusX, float radiusY,
@@ -566,10 +496,6 @@ public void DrawFullscreenQuad(int idx)
566496
GL.BindVertexArray(0);
567497
}
568498

569-
/// <summary>
570-
/// Flushes the batch.
571-
/// </summary>
572-
/// <param name="batch">The batch.</param>
573499
private unsafe void FlushBatch(RenderBatch batch)
574500
{
575501
EnsureInitialized();
@@ -621,48 +547,46 @@ private unsafe void FlushBatch(RenderBatch batch)
621547
}
622548

623549
// --- Textured Vertices ---
624-
if (batch.TexturedBatches.Count <= 0)
550+
if (batch.TexturedBatches.Count > 0)
625551
{
626-
return;
627-
}
552+
BindShaderAndViewport(_ui2DTextureShader);
553+
GL.BindVertexArray(_vaoTex);
628554

629-
BindShaderAndViewport(_ui2DTextureShader);
630-
GL.BindVertexArray(_vaoTex);
555+
// Loop through each texture group
556+
foreach (var kvp in batch.TexturedBatches)
557+
{
558+
var texId = kvp.Key;
559+
var dataList = kvp.Value;
631560

632-
// Loop through each texture group
633-
foreach (var kvp in batch.TexturedBatches)
634-
{
635-
var texId = kvp.Key;
636-
var dataList = kvp.Value;
561+
if (dataList.Count == 0) continue;
637562

638-
if (dataList.Count == 0) continue;
563+
var data = dataList.ToArray();
564+
EnsureBufferCapacity(_vboTex, ref _vboTexCapacity, data.Length);
639565

640-
var data = dataList.ToArray();
641-
EnsureBufferCapacity(_vboTex, ref _vboTexCapacity, data.Length);
566+
// Bind the specific texture for this batch
567+
GL.ActiveTexture(TextureUnit.Texture0);
642568

643-
// Bind the specific texture for this batch
644-
GL.ActiveTexture(TextureUnit.Texture0);
569+
// Use checkerboard if the texture ID is invalid (< 0)
570+
GL.BindTexture(TextureTarget.Texture2D, texId < 0 ? GetOrCreateCheckerboardTexture() : texId);
571+
GL.Uniform1(GL.GetUniformLocation(_ui2DTextureShader, "uTexture"), 0);
645572

646-
// Use checkerboard if the texture ID is invalid (< 0)
647-
GL.BindTexture(TextureTarget.Texture2D, texId < 0 ? GetOrCreateCheckerboardTexture() : texId);
648-
GL.Uniform1(GL.GetUniformLocation(_ui2DTextureShader, "uTexture"), 0);
573+
// Upload and draw
574+
GL.BindBuffer(BufferTarget.ArrayBuffer, _vboTex);
575+
GL.BufferSubData(BufferTarget.ArrayBuffer, IntPtr.Zero, data.Length * sizeof(float), data);
576+
GL.DrawArrays(PrimitiveType.Triangles, 0, data.Length / 4);
577+
}
649578

650-
// Upload and draw
651-
GL.BindBuffer(BufferTarget.ArrayBuffer, _vboTex);
652-
GL.BufferSubData(BufferTarget.ArrayBuffer, IntPtr.Zero, data.Length * sizeof(float), data);
653-
GL.DrawArrays(PrimitiveType.Triangles, 0, data.Length / 4);
579+
GL.BindTexture(TextureTarget.Texture2D, 0);
580+
GL.BindVertexArray(0);
654581
}
655-
656-
GL.BindTexture(TextureTarget.Texture2D, 0);
657-
GL.BindVertexArray(0);
658582
}
659583

660584
/// <summary>
661585
/// Reads the current framebuffer into an <see cref="UnmanagedImageBuffer" />.
662586
/// This performs a GPU → CPU readback of the active framebuffer.
663587
/// Result is top-left origin (software style).
664588
/// </summary>
665-
/// <returns>An <see cref="UnmanagedImageBuffer"/> containing the captured frame.</returns>
589+
/// <returns></returns>
666590
public UnmanagedImageBuffer CaptureFrame()
667591
{
668592
EnsureInitialized();
@@ -747,12 +671,6 @@ public int UploadImage(UnmanagedImageBuffer image, bool linearFilter = false)
747671
return texId;
748672
}
749673

750-
/// <summary>
751-
/// Ensures the buffer capacity.
752-
/// </summary>
753-
/// <param name="vbo">The vbo.</param>
754-
/// <param name="currentCapacity">The current capacity.</param>
755-
/// <param name="requiredFloats">The required floats.</param>
756674
private void EnsureBufferCapacity(int vbo, ref int currentCapacity, int requiredFloats)
757675
{
758676
if (requiredFloats <= currentCapacity) return;
@@ -768,11 +686,7 @@ private void EnsureBufferCapacity(int vbo, ref int currentCapacity, int required
768686
BufferUsageHint.DynamicDraw);
769687
}
770688

771-
/// <summary>
772-
/// Gets the or create checkerboard texture.
773-
/// Create once and cache
774-
/// </summary>
775-
/// <returns></returns>
689+
// FIX 5: Create once and cache
776690
public int GetOrCreateCheckerboardTexture()
777691
{
778692
EnsureInitialized();
@@ -800,7 +714,7 @@ public int GetOrCreateCheckerboardTexture()
800714
private void BindShaderAndViewport(int shaderId)
801715
{
802716
GL.UseProgram(shaderId);
803-
GL.Uniform2(GL.GetUniformLocation(shaderId, "uViewport"), (float)Width, (float)Height);
717+
GL.Uniform2(GL.GetUniformLocation(shaderId, "uViewport"), Width, (float)Height);
804718
}
805719

806720
/// <summary>

0 commit comments

Comments
 (0)