Skip to content

Commit 8555a3a

Browse files
[Rendering] Cleanup and fixes for ImGUI;
1 parent 549a89d commit 8555a3a

File tree

6 files changed

+9
-86
lines changed

6 files changed

+9
-86
lines changed

BuiltinResources/Hidden/Shaders/UI/imgui.shader

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ VertexOutput VertexMain(Input input)
4141
float3 position = input.position;
4242

4343
output.color = float4(
44-
(input.color & uint(0xFF000000)) / 255.0,
45-
(input.color & uint(0x00FF0000)) / 255.0,
46-
(input.color & uint(0x0000FF00)) / 255.0,
47-
(input.color & uint(0x000000FF)) / 255.0,
44+
(input.color & 0xFF) / 255.0,
45+
(input.color >> 8 & 0xFF) / 255.0,
46+
(input.color >> 16 & 0xFF) / 255.0,
47+
(input.color >> 24 & 0xFF) / 255.0
4848
);
4949

5050
output.coord = input.coord;

Engine/Staple.Core/Rendering/RenderSystem/RenderSystem+Internal.cs

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -110,55 +110,6 @@ internal class RenderCommand
110110
#endregion
111111

112112
#region Helpers
113-
/// <summary>
114-
/// Calculates the blending function for blending flags
115-
/// </summary>
116-
/// <param name="source">The blending source flag</param>
117-
/// <param name="destination">The blending destination flag</param>
118-
/// <returns>The combined function</returns>
119-
/*
120-
[MethodImpl(MethodImplOptions.AggressiveInlining)]
121-
internal static ulong BlendFunction(bgfx.StateFlags source, bgfx.StateFlags destination)
122-
{
123-
return BlendFunction(source, destination, source, destination);
124-
}
125-
*/
126-
127-
/// <summary>
128-
/// Calculates the blending function for blending flags
129-
/// </summary>
130-
/// <param name="sourceColor">The source color flag</param>
131-
/// <param name="destinationColor">The destination color flag</param>
132-
/// <param name="sourceAlpha">The source alpha blending flag</param>
133-
/// <param name="destinationAlpha">The destination alpha blending flag</param>
134-
/// <returns>The combined function</returns>
135-
/*
136-
[MethodImpl(MethodImplOptions.AggressiveInlining)]
137-
internal static ulong BlendFunction(bgfx.StateFlags sourceColor, bgfx.StateFlags destinationColor, bgfx.StateFlags sourceAlpha, bgfx.StateFlags destinationAlpha)
138-
{
139-
return (ulong)sourceColor | (ulong)destinationColor << 4 | ((ulong)sourceAlpha | (ulong)destinationAlpha << 4) << 8;
140-
}
141-
*/
142-
143-
/// <summary>
144-
/// Checks if we have an available transient buffer
145-
/// </summary>
146-
/// <param name="numVertices">The amount of vertices to check</param>
147-
/// <param name="layout">The vertex layout to use</param>
148-
/// <param name="numIndices">The amount of indices to check</param>
149-
/// <returns></returns>
150-
/*
151-
[MethodImpl(MethodImplOptions.AggressiveInlining)]
152-
internal static bool CheckAvailableTransientBuffers(uint numVertices, bgfx.VertexLayout layout, uint numIndices)
153-
{
154-
unsafe
155-
{
156-
return numVertices == bgfx.get_avail_transient_vertex_buffer(numVertices, &layout)
157-
&& (0 == numIndices || numIndices == bgfx.get_avail_transient_index_buffer(numIndices, false));
158-
}
159-
}
160-
*/
161-
162113
/// <summary>
163114
/// Gets the reset flags for specific video flags
164115
/// </summary>

Engine/Staple.Editor/ImGuiProxy.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public bool Initialize()
113113
var setPtr = Marshal.GetFunctionPointerForDelegate(SetClipboardText);
114114
var getPtr = Marshal.GetFunctionPointerForDelegate(GetClipboardText);
115115

116-
platformIO.RendererTextureMaxWidth = platformIO.RendererTextureMaxHeight = 0;//(int)bgfx.get_caps()->limits.maxTextureSize;
116+
platformIO.RendererTextureMaxWidth = platformIO.RendererTextureMaxHeight = 8192;
117117
platformIO.PlatformSetClipboardTextFn = (void*)setPtr;
118118
platformIO.PlatformGetClipboardTextFn = (void*)getPtr;
119119
platformIO.PlatformClipboardUserData = (void *)nint.Zero;
@@ -519,7 +519,7 @@ private void Render(ImDrawDataPtr drawData)
519519

520520
var command = RenderSystem.Backend.BeginCommand();
521521

522-
var pass = command.BeginRenderPass(null, CameraClearMode.SolidColor, Color.LightBlue, new(0, 0, 1, 1), Matrix4x4.Identity, ortho);
522+
var pass = command.BeginRenderPass(null, CameraClearMode.SolidColor, StapleEditor.ClearColor, new(0, 0, 1, 1), Matrix4x4.Identity, ortho);
523523

524524
var clipPos = drawData.DisplayPos;
525525
var clipScale = drawData.FramebufferScale;

Engine/Staple.Editor/StapleEditor+Render.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,6 @@ internal partial class StapleEditor
1515
/// </summary>
1616
public void RenderScene()
1717
{
18-
/*
19-
bgfx.touch(SceneView);
20-
bgfx.touch(WireframeView);
21-
*/
22-
2318
ImGuizmo.SetDrawlist();
2419
ImGuizmo.SetOrthographic(false);
2520
ImGuizmo.SetRect(0, 0, window.width, window.height);

Engine/Staple.Editor/StapleEditor.cs

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ public void WorldChanged()
280280

281281
private const int TargetFramerate = 30;
282282

283-
private Color32 clearColor = new("#7393B3");
283+
public static readonly Color32 ClearColor = new("#7393B3");
284284

285285
private ViewportType viewportType = ViewportType.Scene;
286286

@@ -467,6 +467,7 @@ public void Run(string[] args)
467467
editorAppSettings.runInBackground = true;
468468
editorAppSettings.appName = "Staple Editor";
469469
editorAppSettings.companyName = "Staple Engine";
470+
editorAppSettings.renderers[AppPlatform.Windows] = [ RendererType.Vulkan ];
470471

471472
LayerMask.SetLayers(CollectionsMarshal.AsSpan(editorAppSettings.layers), CollectionsMarshal.AsSpan(editorAppSettings.sortingLayers));
472473

@@ -764,17 +765,6 @@ private void NormalEditorLoop()
764765

765766
style.WindowPadding = Vector2.Zero;
766767

767-
/*
768-
bgfx.set_view_rect_ratio(ClearView, 0, 0, bgfx.BackbufferRatio.Equal);
769-
bgfx.set_view_clear(ClearView, (ushort)(bgfx.ClearFlags.Color | bgfx.ClearFlags.Depth), clearColor.UIntValue, 1, 0);
770-
771-
bgfx.set_view_rect_ratio(SceneView, 0, 0, bgfx.BackbufferRatio.Equal);
772-
bgfx.set_view_clear(SceneView, (ushort)(bgfx.ClearFlags.Color | bgfx.ClearFlags.Depth), clearColor.UIntValue, 1, 0);
773-
774-
bgfx.set_view_rect_ratio(WireframeView, 0, 0, bgfx.BackbufferRatio.Equal);
775-
bgfx.set_view_clear(WireframeView, (ushort)bgfx.ClearFlags.Depth, 0, 1, 0);
776-
*/
777-
778768
Physics3D.Instance = new Physics3D(new JoltPhysics3D());
779769

780770
Physics3D.Instance.Startup();
@@ -1282,19 +1272,6 @@ private void NormalEditorLoop()
12821272

12831273
PlayerSettings.Save(playerSettings);
12841274

1285-
/*
1286-
bgfx.reset((uint)window.width, (uint)window.height, (uint)flags, bgfx.TextureFormat.RGBA8);
1287-
1288-
bgfx.set_view_rect_ratio(ClearView, 0, 0, bgfx.BackbufferRatio.Equal);
1289-
bgfx.set_view_clear(ClearView, (ushort)(bgfx.ClearFlags.Color | bgfx.ClearFlags.Depth), clearColor.UIntValue, 1, 0);
1290-
1291-
bgfx.set_view_rect_ratio(SceneView, 0, 0, bgfx.BackbufferRatio.Equal);
1292-
bgfx.set_view_clear(SceneView, (ushort)(bgfx.ClearFlags.Color | bgfx.ClearFlags.Depth), clearColor.UIntValue, 1, 0);
1293-
1294-
bgfx.set_view_rect_ratio(WireframeView, 0, 0, bgfx.BackbufferRatio.Equal);
1295-
bgfx.set_view_clear(WireframeView, (ushort)bgfx.ClearFlags.Depth, 0, 1, 0);
1296-
*/
1297-
12981275
if (hadFocus != hasFocus && hasFocus)
12991276
{
13001277
if (RefreshingAssets == false && ProjectManager.Instance.NeedsGameRecompile())

Engine/Staple.Player.Android/StapleActivity.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ private void InitIfNeeded()
316316
{
317317
if (AppPlayer.instance?.renderWindow == null)
318318
{
319-
new AppPlayer(Array.Empty<string>(), false);
319+
new AppPlayer(Array.Empty<string>(), false, false);
320320

321321
Log.Instance.onLog += (type, message) =>
322322
{

0 commit comments

Comments
 (0)