Content browser

This commit is contained in:
Simon Lübeß
2022-07-25 17:03:28 +02:00
parent 0339ae4422
commit bff4418b84
21 changed files with 481 additions and 44 deletions
+22
View File
@@ -45,4 +45,26 @@ namespace GlitchyEngine.Collections
return null;
}
}
static
{
public static mixin DeleteTreeAndChildren<T>(TreeNode<T> tree) where T : class, delete
{
InternalDeleteTreeAndChildren(tree);
}
private static void InternalDeleteTreeAndChildren<T>(TreeNode<T> tree) where T : class, delete
{
for (var child in tree.Children)
{
InternalDeleteTreeAndChildren(child);
}
delete tree.Value;
tree.Children.Clear();
delete tree;
}
}
}
+23
View File
@@ -1,6 +1,7 @@
using GlitchyEngine.Math;
using GlitchyEngine.Renderer;
using System;
using GlitchyEngine;
namespace ImGui
{
@@ -34,6 +35,16 @@ namespace ImGui
Image(texture.GetViewBinding(), size, uv0, uv1, tint_col, border_col);
}
public static void Image(SubTexture2D subTexture, Vec2 size, Vec2 uv0 = Vec2.Zero, Vec2 uv1 = Vec2.Ones, Vec4 tint_col = Vec4.Ones, Vec4 border_col = Vec4.Zero)
{
if (uv0 != .Zero || uv1 != .Ones)
Runtime.NotImplemented();
Vector2 v = (.)subTexture.TexCoords.XY + subTexture.TexCoords.ZW;
Image(subTexture.Texture.GetViewBinding(), size, (.)subTexture.TexCoords.XY, (.)v, tint_col, border_col);
}
public static void Image(RenderTarget2D texture, Vec2 size, Vec2 uv0 = Vec2.Zero, Vec2 uv1 = Vec2.Ones, Vec4 tint_col = Vec4.Ones, Vec4 border_col = Vec4.Zero)
{
Image(texture.GetViewBinding(), size, uv0, uv1, tint_col, border_col);
@@ -41,6 +52,18 @@ namespace ImGui
public static extern void Image(TextureViewBinding textureViewBinding, Vec2 size, Vec2 uv0 = Vec2.Zero, Vec2 uv1 = Vec2.Ones, Vec4 tint_col = Vec4.Ones, Vec4 border_col = Vec4.Zero);
public static bool ImageButton(SubTexture2D subTexture, Vec2 size, Vec2 uv0 = Vec2.Zero, Vec2 uv1 = Vec2.Ones, int32 frame_padding = -1, Vec4 bg_col = Vec4.Zero, Vec4 tint_col = Vec4.Ones)
{
if (uv0 != .Zero || uv1 != .Ones)
Runtime.NotImplemented();
Vector2 v = (.)subTexture.TexCoords.XY + subTexture.TexCoords.ZW;
return ImageButton(subTexture.Texture.GetViewBinding(), size, (.)subTexture.TexCoords.XY, (.)v, frame_padding, bg_col, tint_col);
}
public static extern bool ImageButton(TextureViewBinding textureViewBinding, Vec2 size, Vec2 uv0 = Vec2.Zero, Vec2 uv1 = Vec2.Ones, int32 frame_padding = -1, Vec4 bg_col = Vec4.Zero, Vec4 tint_col = Vec4.Ones);
public static void TextUnformatted(StringView text) => TextUnformattedImpl(text.Ptr, text.Ptr + text.Length);
public static void PushID(StringView id) => PushID(id.Ptr, id.Ptr + id.Length);
+1 -1
View File
@@ -4,7 +4,7 @@ using System;
namespace GlitchyEngine.Math
{
[BonTarget]
[SwizzleVector(2, "Vector")]
[SwizzleVector(2, "GlitchyEngine.Math.Vector")]
public struct Vector2
{
public const Vector2 Zero = .(0f, 0f);
+1 -1
View File
@@ -4,7 +4,7 @@ using System;
namespace GlitchyEngine.Math
{
[BonTarget]
[SwizzleVector(3, "Vector")]
[SwizzleVector(3, "GlitchyEngine.Math.Vector")]
public struct Vector3
{
public const Vector3 Zero = .(0f, 0f, 0f);
+1 -1
View File
@@ -4,7 +4,7 @@ using System;
namespace GlitchyEngine.Math
{
[BonTarget]
[SwizzleVector(4, "Vector")]
[SwizzleVector(4, "GlitchyEngine.Math.Vector")]
public struct Vector4
{
public const Vector4 Zero = .(0f, 0f, 0f, 0f);
+13 -1
View File
@@ -19,7 +19,19 @@ namespace ImGui
ImGui.Image(view, size, uv0, uv1, tint_col, border_col);
textureViewBinding.ReleaseRef();
textureViewBinding.Release();
}
public static override bool ImageButton(TextureViewBinding textureViewBinding, Vec2 size, Vec2 uv0 = Vec2.Zero, Vec2 uv1 = Vec2.Ones, int32 frame_padding = -1, Vec4 bg_col = Vec4.Zero, Vec4 tint_col = Vec4.Ones)
{
var view = textureViewBinding._nativeShaderResourceView..AddRef();
_resourceViews.Add(view);
bool pressed = ImGui.ImageButton(view, size, uv0, uv1, frame_padding, bg_col, tint_col);
textureViewBinding.Release();
return pressed;
}
protected internal static override void CleanupFrame()
@@ -146,7 +146,7 @@ namespace GlitchyEngine.Renderer
}
// TODO: Update Texture Arrays!
protected override System.Result<void> PlatformSetData(void* data, uint32 elementSize, uint32 destX,
protected override Result<void> PlatformSetData(void* data, uint32 elementSize, uint32 destX,
uint32 destY, uint32 destWidth, uint32 destHeight, uint32 arraySlice, uint32 mipLevel, GlitchyEngine.Renderer.MapType mapType)
{
Debug.Profiler.ProfileResourceFunction!();
@@ -259,7 +259,7 @@ namespace GlitchyEngine.Renderer
protected override TextureViewBinding PlatformGetViewBinding()
{
return .(_nativeResourceView, _samplerState.nativeSamplerState);
return .(_nativeResourceView, _samplerState?.nativeSamplerState);
}
}
@@ -24,7 +24,7 @@ namespace GlitchyEngine.Renderer
_nativeSamplerState?.AddRef();
}
public override void ReleaseRef()
public override void Release()
{
_nativeShaderResourceView?.Release();
_nativeSamplerState?.Release();
+18 -11
View File
@@ -63,13 +63,20 @@ namespace GlitchyEngine.Renderer
name = scope:: String();
Path.GetFileNameWithoutExtension(filepath, name);
}
Log.EngineLogger.AssertDebug(!Exists(name), "Can't add two effects with the same name to library.");
Effect effect = new Effect(filepath, name);
Add(effect);
if (Exists(name))
{
return Get(name);
}
else
{
Log.EngineLogger.AssertDebug(!Exists(name), "Can't add two effects with the same name to library.");
return effect;
Effect effect = new Effect(filepath, name);
Add(effect);
return effect;
}
}
/**
@@ -182,7 +189,7 @@ namespace GlitchyEngine.Renderer
for(let entry in _textures)
{
entry.value.BoundTexture.ReleaseRef();
entry.value.BoundTexture.Release();
}
}
@@ -192,7 +199,7 @@ namespace GlitchyEngine.Renderer
ref TextureEntry entry = ref _textures[name];
entry.BoundTexture.ReleaseRef();
entry.BoundTexture.Release();
entry.BoundTexture = texture.GetViewBinding();
}
@@ -205,7 +212,7 @@ namespace GlitchyEngine.Renderer
ref TextureEntry entry = ref _textures[name];
entry.BoundTexture.ReleaseRef();
entry.BoundTexture.Release();
//entry.BoundTexture = .RenderTargetGroup(renderTargetGroup..AddRef(), firstTarget, targetCount);
entry.BoundTexture = renderTargetGroup.GetViewBinding(firstTarget);
}
@@ -216,7 +223,7 @@ namespace GlitchyEngine.Renderer
ref TextureEntry entry = ref _textures[name];
entry.BoundTexture.ReleaseRef();
entry.BoundTexture.Release();
entry.BoundTexture = textureViewBinding..AddRef();
}
@@ -226,11 +233,11 @@ namespace GlitchyEngine.Renderer
for(let (name, entry) in _textures)
{
entry.VsSlot?.BoundTexture.ReleaseRef();
entry.VsSlot?.BoundTexture.Release();
entry.VsSlot?.BoundTexture = entry.BoundTexture;
entry.VsSlot?.BoundTexture.AddRef();
entry.PsSlot?.BoundTexture.ReleaseRef();
entry.PsSlot?.BoundTexture.Release();
entry.PsSlot?.BoundTexture = entry.BoundTexture;
entry.PsSlot?.BoundTexture.AddRef();
}
+2 -2
View File
@@ -40,7 +40,7 @@ namespace GlitchyEngine.Renderer
{
for(let (name, texture) in _textures)
{
texture.ReleaseRef();
texture.Release();
}
delete _textures;
@@ -90,7 +90,7 @@ namespace GlitchyEngine.Renderer
{
if(_textures.TryGetValue(name, var entry))
{
entry.ReleaseRef();
entry.Release();
_textures[name] = texture.GetViewBinding();
//texture?.AddRef();
}
+3 -1
View File
@@ -34,7 +34,9 @@ namespace GlitchyEngine.Renderer
_rendererAPI.Init();
}
[Inline]
// REPORT!!!!!!!!!
// Inline doesn't compile
//[Inline]
public static void Clear(RenderTarget2D renderTarget, ColorRGBA color)
{
_rendererAPI.Clear(renderTarget, color);
@@ -31,7 +31,7 @@ namespace GlitchyEngine.Renderer
for(let entry in entries)
{
delete entry.Name;
entry.BoundTexture.ReleaseRef();
entry.BoundTexture.Release();
}
delete entries;
@@ -9,8 +9,8 @@ namespace GlitchyEngine.Renderer
public extern bool IsEmpty { get; }
public extern void AddRef();
public extern void ReleaseRef();
public extern void Release();
public void Dispose() => ReleaseRef();
public void Dispose() => Release();
}
}
+2 -2
View File
@@ -33,13 +33,13 @@ namespace GlitchyEngine.World
public this()
{
Entity entity = CreateEntity("Green Quad");
/*Entity entity = CreateEntity("Green Quad");
entity.AddComponent<SpriterRendererComponent>(.(ColorRGBA.SRgbToLinear(.(0.2f, 0.9f, 0.15f))));
Entity entity2 = CreateEntity("Red Square");
var v = entity2.AddComponent<SpriterRendererComponent>(.(ColorRGBA.SRgbToLinear(.(0.95f, 0.1f, 0.3f))));
v.Sprite = new Texture2D("Textures/rocket.dds");
v.Sprite.SamplerState = SamplerStateManager.PointClamp;
v.Sprite.SamplerState = SamplerStateManager.PointClamp;*/
_onComponentAddedHandlers.Add(typeof(CameraComponent), (e, t, c) => {
CameraComponent* cameraComponent = (.)c;