don't go faster than the underlying platform can manage

This commit is contained in:
4sval 2022-09-04 11:20:42 +02:00
parent 4710d3afbc
commit 355b7f0c3d
2 changed files with 20 additions and 13 deletions

View File

@ -134,8 +134,19 @@ public class SnimGui : IDisposable
var model = models[i];
vertices += model.Vertices.Length;
indices += model.Indices.Length;
ImGui.PushID(i);
if (ImGui.Selectable(model.Name, _selectedModel == i))
_selectedModel = i;
if (ImGui.BeginPopupContextItem())
{
if (ImGui.Selectable("Delete"))
{
_selectedModel--;
models.RemoveAt(i);
}
ImGui.EndPopup();
}
ImGui.PopID();
}
ImGui.TreePop();
}
@ -163,6 +174,7 @@ public class SnimGui : IDisposable
ImGui.SetNextWindowPos(_propertiesPosition, _firstUse);
ImGui.Begin("Properties", _noResize | ImGuiWindowFlags.NoCollapse);
if (_selectedModel < 0) return;
var model = models[_selectedModel];
ImGui.Text($"Entity: {model.Name}");
ImGui.BeginDisabled(!model.HasVertexColors);
@ -253,6 +265,7 @@ public class SnimGui : IDisposable
ImGui.SetNextWindowPos(_texturePosition, _firstUse);
ImGui.Begin("Textures", _noResize | ImGuiWindowFlags.NoCollapse);
if (_selectedModel < 0) return;
var section = models[_selectedModel].Sections[_selectedSection];
ImGui.BeginGroup();
ImGui.Checkbox("Show", ref section.Show);

View File

@ -37,7 +37,6 @@ public class Snooper
private Vector2D<int> _size;
private float _previousSpeed;
private bool _close;
private bool _append;
public Snooper()
@ -85,7 +84,6 @@ public class Snooper
public void Run(UObject export)
{
_close = false;
_append = false;
switch (export)
{
@ -105,16 +103,7 @@ public class Snooper
throw new ArgumentOutOfRangeException(nameof(export));
}
_window.Initialize();
while (!_close && !_append)
{
_window.DoEvents();
_window.DoUpdate();
_window.DoRender();
}
_window.DoEvents();
if (!_append) _window.Close(); // dispose
else _window.Reset();
_window.Run();
}
private void SetupCamera(FBox box)
@ -220,13 +209,18 @@ public class Snooper
_camera.Position -= moveSpeed * _camera.Up;
if (_keyboard.IsKeyPressed(Key.H))
{
_append = true;
_window.Close();
}
if (_keyboard.IsKeyPressed(Key.Escape))
_close = true;
_window.Close();
}
private void OnClose()
{
if (_append) // don't dispose anything, especially _models
return;
_framebuffer.Dispose();
_grid.Dispose();
_skybox.Dispose();