only setup the needed one

This commit is contained in:
4sval 2022-10-19 00:12:34 +02:00
parent 41319ad2a3
commit 59973f95d6
2 changed files with 12 additions and 0 deletions

View File

@ -24,6 +24,7 @@ public class Cache : IDisposable
public bool TryGetModel(FGuid guid, out Model model) => _models.TryGetValue(guid, out model);
public bool TryGetTexture(FGuid guid, out Texture texture) => _textures.TryGetValue(guid, out texture);
public void Setup(FGuid guid) => _models[guid].Setup();
public void Setup()
{
foreach (var model in _models.Values)
@ -31,6 +32,7 @@ public class Cache : IDisposable
model.Setup();
}
}
public void Render(Shader shader)
{
foreach (var model in _models.Values)

View File

@ -20,12 +20,15 @@ public class Snooper : GameWindow
private Camera _camera;
private float _previousSpeed;
private bool _init;
public Snooper(GameWindowSettings gwSettings, NativeWindowSettings nwSettings) : base(gwSettings, nwSettings)
{
// _framebuffer = new FramebufferObject(Size);
_skybox = new Skybox();
_grid = new Grid();
_renderer = new Renderer();
_init = false;
}
public void SwapMaterial(UMaterialInstance mi) => _renderer.Swap(mi);
@ -53,6 +56,12 @@ public class Snooper : GameWindow
protected override void OnLoad()
{
if (_init)
{
_renderer.Cache.Setup(_renderer.Settings.SelectedModel);
return;
}
base.OnLoad();
GL.ClearColor(Color4.Red);
@ -66,6 +75,7 @@ public class Snooper : GameWindow
_skybox.Setup();
_grid.Setup();
_renderer.Setup();
_init = true;
}
protected override void OnRenderFrame(FrameEventArgs args)