Actual working viewports :)
This commit is contained in:
+38
-24
@@ -2,9 +2,7 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
using Hexa.NET.ImGui;
|
||||
using Hexa.NET.ImPlot;
|
||||
using Hexa.NET.ImPlot3D;
|
||||
using SDL3_TestingSuite.SDL3;
|
||||
using SDL3;
|
||||
|
||||
namespace SDL3_TestingSuite;
|
||||
|
||||
@@ -19,15 +17,13 @@ public class Program
|
||||
|
||||
public static void Main()
|
||||
{
|
||||
const SDL.WindowFlags flags = SDL.WindowFlags.Resizable | SDL.WindowFlags.HighPixelDensity | SDL.WindowFlags.Transparent;
|
||||
SDL3Window window = new SDL3Window("SDL3 Testing Suite", 100, 100, 1280, 720, flags);
|
||||
window.ClearColor.W = 0f;
|
||||
SDL3Window window = new SDL3Window("SDL3 Testing Suite", 100, 100, 1280, 720);
|
||||
window.RenderCallback = () =>
|
||||
{
|
||||
ImGuiViewportPtr viewport = ImGui.GetMainViewport();
|
||||
ImGui.SetNextWindowPos(viewport.WorkPos);
|
||||
ImGui.SetNextWindowSize(viewport.WorkSize);
|
||||
|
||||
ImGui.SetNextWindowViewport(viewport.ID);
|
||||
ImGui.Begin("MainWindow", ImGuiWindowFlags.NoBackground | ImGuiWindowFlags.MenuBar | ImGuiWindowFlags.NoDocking | ImGuiWindowFlags.NoTitleBar | ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoMove | ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoBringToFrontOnFocus);
|
||||
|
||||
if (ImGui.BeginMenuBar())
|
||||
@@ -38,7 +34,7 @@ public class Program
|
||||
{
|
||||
window.ShouldClose = true;
|
||||
}
|
||||
|
||||
|
||||
ImGui.EndMenu();
|
||||
}
|
||||
ImGui.Spacing();
|
||||
@@ -123,46 +119,47 @@ public class Program
|
||||
ImGui.End();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ImGui.Begin("Thing");
|
||||
float time = (float)ImGui.GetTime() * 5;
|
||||
if (ImPlot.BeginPlot("Moving Rainbow Sine Wave"))
|
||||
{
|
||||
int count = 200;
|
||||
|
||||
|
||||
float[] xs = new float[2];
|
||||
float[] ys = new float[2];
|
||||
|
||||
|
||||
for (int i = 0; i < count - 1; i++)
|
||||
{
|
||||
float x0 = i * 0.1f;
|
||||
float x1 = (i + 1) * 0.1f;
|
||||
|
||||
|
||||
float y0 = MathF.Sin(x0 * size + time);
|
||||
float y1 = MathF.Sin(x1 * size + time);
|
||||
|
||||
|
||||
xs[0] = x0;
|
||||
xs[1] = x1;
|
||||
|
||||
|
||||
ys[0] = y0;
|
||||
ys[1] = y1;
|
||||
|
||||
|
||||
float t = i / (float)count;
|
||||
|
||||
|
||||
float r = 0.5f + 1f * MathF.Sin(6.2831f * (t));
|
||||
float g = 0.5f + 1f * MathF.Sin(6.2831f * (t + 0.33f));
|
||||
float b = 0.5f + 1f * MathF.Sin(6.2831f * (t + 0.66f));
|
||||
|
||||
|
||||
|
||||
|
||||
ImPlot.PushStyleColor(ImPlotCol.Line, new Vector4(r, g, b, 1f));
|
||||
ImPlot.PlotLine("##seg", ref xs[0], ref ys[0], 2);
|
||||
ImPlot.PopStyleColor();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
ImPlot.EndPlot();
|
||||
}
|
||||
|
||||
ImGui.SliderFloat("Sine", ref size, 1f, 120f);
|
||||
ImGui.End();
|
||||
|
||||
if (_demoWindowVisible)
|
||||
{
|
||||
@@ -177,13 +174,30 @@ public class Program
|
||||
|
||||
public static class Logger
|
||||
{
|
||||
public static void Log(string? str, [CallerMemberName] string caller = "", [CallerLineNumber] int line = 0)
|
||||
private const int MessageWidth = 80;
|
||||
private const int CallerWidth = 35;
|
||||
|
||||
public static void Log(object? value, [CallerFilePath] string path = "", [CallerMemberName] string caller = "", [CallerLineNumber] int line = 0)
|
||||
{
|
||||
Console.WriteLine($"{caller}({line}): {str}");
|
||||
Write(value?.ToString(), path, caller, line);
|
||||
}
|
||||
public static void Log(object? str, [CallerMemberName] string caller = "", [CallerLineNumber] int line = 0)
|
||||
|
||||
public static void Log(object?[] values, [CallerFilePath] string path = "", [CallerMemberName] string caller = "", [CallerLineNumber] int line = 0)
|
||||
{
|
||||
Log(str?.ToString(), caller, line);
|
||||
if (values == null)
|
||||
{
|
||||
Write("null", path, caller, line);
|
||||
return;
|
||||
}
|
||||
Write(string.Join(" ", values), path, caller, line);
|
||||
}
|
||||
|
||||
private static void Write(string? str, string path, string caller, int line)
|
||||
{
|
||||
string message = (str ?? string.Empty).PadRight(MessageWidth);
|
||||
string method = caller.PadRight(CallerWidth);
|
||||
|
||||
Console.WriteLine($"{message} | {method} | {path}:{line}");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user