.
This commit is contained in:
@@ -117,7 +117,7 @@ public sealed class Engine
|
||||
|
||||
Renderer.EndFrame();
|
||||
|
||||
Presenter!.Present(Renderer.TextureInternal);
|
||||
Presenter!.Present(Renderer.RenderTexture);
|
||||
Presenter!.Render();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,8 @@ namespace Engine.Graphics;
|
||||
|
||||
public class Renderer
|
||||
{
|
||||
internal Texture.Texture TextureInternal => _framebuffer.TextureInternal!;
|
||||
internal Framebuffer.Framebuffer RenderFramebuffer => _framebuffer;
|
||||
internal Texture.Texture RenderTexture => _framebuffer.TextureInternal!;
|
||||
|
||||
public QuadRenderer QuadRenderer { get; }
|
||||
public GlobalMeshRenderer GlobalMeshRenderer { get; }
|
||||
@@ -55,12 +56,10 @@ public class Renderer
|
||||
public void EnsureRenderThread()
|
||||
{
|
||||
#if DEBUG
|
||||
if (Thread.CurrentThread == _renderThread)
|
||||
if (Thread.CurrentThread != _renderThread)
|
||||
{
|
||||
return;
|
||||
throw new InvalidOperationException("Not on render thread");
|
||||
}
|
||||
|
||||
throw new InvalidOperationException("Not on render thread");
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -58,21 +58,21 @@ public class Hierarchy<T>
|
||||
});
|
||||
}
|
||||
|
||||
public void AddChild(T parEnt, T parChild)
|
||||
public void AddChild(T parParent, T parChild)
|
||||
{
|
||||
SetParent(parChild, parEnt);
|
||||
SetParent(parChild, parParent);
|
||||
}
|
||||
|
||||
private void SetParent(T parChild, T? parEnt)
|
||||
private void SetParent(T parChild, T? parParent)
|
||||
{
|
||||
if (parChild.Equals(parEnt))
|
||||
if (parChild.Equals(parParent))
|
||||
{
|
||||
throw new InvalidOperationException("Child cannot be parent");
|
||||
}
|
||||
|
||||
_hierarchyActions.Enqueue(() =>
|
||||
{
|
||||
if (IsInHierarchy(parChild, parEnt))
|
||||
if (IsInHierarchy(parChild, parParent))
|
||||
{
|
||||
throw new InvalidOperationException("Parent is a child of child");
|
||||
}
|
||||
@@ -80,8 +80,8 @@ public class Hierarchy<T>
|
||||
var oldParent = GetParent(parChild);
|
||||
_childrenLookup[oldParent].Remove(parChild);
|
||||
|
||||
_childrenLookup[parEnt].Add(parChild);
|
||||
_parentLookup[parChild] = parEnt;
|
||||
_childrenLookup[parParent].Add(parChild);
|
||||
_parentLookup[parChild] = parParent;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -87,6 +87,12 @@ public class Scene : IUpdate, IRender
|
||||
});
|
||||
}
|
||||
|
||||
public void AddChild(GameObject parParent, GameObject parGameObject)
|
||||
{
|
||||
Add(parGameObject);
|
||||
Hierarchy.AddChild(parParent, parGameObject);
|
||||
}
|
||||
|
||||
public void Remove(GameObject parGameObject)
|
||||
{
|
||||
Hierarchy.Remove(parGameObject);
|
||||
|
||||
@@ -63,13 +63,12 @@ public class Window : IPresenter
|
||||
return;
|
||||
}
|
||||
|
||||
GL.ClearColor(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
|
||||
|
||||
var texture = (Texture)parTexture;
|
||||
_engine.Renderer.QuadRenderer.Commit(Matrix4.CreateScale(2f), Vector4.One, texture);
|
||||
_engine.Renderer.QuadRenderer.Render(Matrix4.Identity, Matrix4.Identity);
|
||||
_engine.Renderer.QuadRenderer.Reset();
|
||||
GL.BlitNamedFramebuffer(_engine.Renderer.RenderFramebuffer.Handle, 0,
|
||||
0, parTexture.Height, parTexture.Width, 0,
|
||||
0, 0, Width, Height,
|
||||
ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit,
|
||||
BlitFramebufferFilter.Nearest
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user