Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[VL.ImGui.Stride.Viewports] #673

Open
wants to merge 44 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
09bf3cc
BUGFIX:
kopffarben Mar 12, 2024
9ee818e
BUGFIX:
kopffarben Mar 12, 2024
482e798
working SceneWidget and remove Properties/launchSettings.json
kopffarben Mar 12, 2024
93ec848
WIP RenderWidget with IInputSource Out
kopffarben Mar 14, 2024
3e251e6
WIP
kopffarben Mar 19, 2024
a065910
WIP CleanUp
kopffarben Mar 19, 2024
aede9c9
WIP
kopffarben Mar 20, 2024
e423c20
Merge remote-tracking branch 'remotes/origin/main' into feature/VL.Im…
kopffarben Mar 20, 2024
fdc69fb
WIP
kopffarben Mar 20, 2024
1318fee
Merge remote-tracking branch 'remotes/origin/main' into feature/VL.Im…
kopffarben Mar 20, 2024
4d30715
WIP
kopffarben Mar 20, 2024
e53e513
WIP
kopffarben Mar 21, 2024
75dffb6
WIP
kopffarben Mar 25, 2024
74d07a3
WIP
kopffarben Mar 27, 2024
04d9e0d
Merge remote-tracking branch 'remotes/origin/main' into feature/VL.Im…
kopffarben Mar 27, 2024
53688ac
WIP
kopffarben Mar 27, 2024
163e258
CleanUP
kopffarben Mar 27, 2024
9edf8bd
remove InputManager from StrideContext ... not needed
kopffarben Apr 4, 2024
f28bf90
Merge remote-tracking branch 'remotes/origin/main' into feature/VL.Im…
kopffarben Apr 4, 2024
893137c
Move Stride Pipeline Stuff to StrideDeviceContext
kopffarben Apr 4, 2024
777c985
CleanUp
kopffarben Apr 5, 2024
4a57a14
WIP
kopffarben Apr 5, 2024
d2410ea
WIP
kopffarben Apr 13, 2024
347b9f3
WIP first buggy working version ...
kopffarben Apr 13, 2024
7011c91
Working Version for Viewports
kopffarben Apr 14, 2024
0f363eb
some CleanUp
kopffarben Apr 14, 2024
4cfd87a
Merge remote-tracking branch 'remotes/origin/main' into feature/VL.Im…
kopffarben Apr 15, 2024
e27cb98
SkiaRendererWithOffset
kopffarben Apr 15, 2024
9e05b53
WIP
kopffarben Apr 16, 2024
060c2d2
ADD Bound to Document
kopffarben Apr 16, 2024
cd90ed0
revert launchSettings.json
kopffarben Apr 16, 2024
9d77ae2
Closing MainWindow will close all other Windows
kopffarben Apr 16, 2024
c78d9ab
Add MousButtons to globalMouseState
kopffarben Apr 16, 2024
60e4025
Merge remote-tracking branch 'remotes/origin/main' into feature/VL.Im…
kopffarben May 3, 2024
d9d4a7a
WIP fixed null ref on Closeing
kopffarben May 3, 2024
57254be
fix InputSource Handeling
kopffarben May 3, 2024
2b92219
[ImGui.Stride] Gets rid of earlier introduced hack by using same code…
azeno May 23, 2024
679e1f8
VL.ImGui.Stride TargetFramework net8.0-windows
kopffarben May 23, 2024
6f46662
Merge remote-tracking branch 'remotes/origin/main' into feature/VL.Im…
kopffarben May 23, 2024
bdafce1
[VL.ImGui.Skia]
kopffarben May 23, 2024
cec33a3
Merge remote-tracking branch 'remotes/origin/bugfix/issue-672' into f…
kopffarben May 23, 2024
524c1a8
IMappedDevice add SetSourceDevice
kopffarben May 30, 2024
71e475a
Merge branch 'main' into feature/VL.ImGui.Stride.Viewports
kopffarben Aug 28, 2024
a71b894
small bug-fix
kopffarben Aug 28, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 4 additions & 9 deletions VL.ImGui.Skia/src/SkiaWidget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,21 +52,20 @@ protected override void Draw(Context context, in ImDrawListPtr drawList, in Syst
//if (context.DrawList == DrawList.AtCursor)
// ImGui.Image(0, size);

// because we use Callback instead of Image


drawList.AddCallback(id, IntPtr.Zero);
}
}

[Pin(Ignore = true)]
public RectangleF? Bounds => !_disposed ? Layer?.Bounds : default;

// What is this for?
//SKMatrix? trans;

public void Render(CallerInfo caller)
{
if (_disposed || Layer is null)
return;
//trans = caller.Transformation;
Layer.Render(caller);
}

Expand All @@ -82,11 +81,7 @@ public bool Notify(INotification notification, CallerInfo caller)
if (EventFilter == EventFilter.WindowHasFocus && !_windowHasFocus)
return false;


//if (trans != null)
// return Layer.Notify(notification, caller.WithTransformation((SKMatrix)trans));
//else
return Layer.Notify(notification, caller); ;
return Layer.Notify(notification, caller); ;
}

public void Dispose()
Expand Down
2 changes: 1 addition & 1 deletion VL.ImGui.Skia/src/ToSkiaLayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ public bool Notify(INotification notification, CallerInfo caller)
{
using (_context.MakeCurrent())
{
_io.HandleNotification(notification, useWorldSpace: true);
_io.HandleNotification(notification);

foreach (var layer in _context.Layers)
{
Expand Down
2 changes: 1 addition & 1 deletion VL.ImGui.Skia/src/ToSkiaLayerVersion1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ public bool Notify(INotification notification, CallerInfo caller)
{
using (_context.MakeCurrent())
{
_io.HandleNotification(notification, useWorldSpace: true);
_io.HandleNotification(notification);

foreach (var layer in _context.Layers)
{
Expand Down
862 changes: 838 additions & 24 deletions VL.ImGui.Stride/VL.ImGui.Stride.vl

Large diffs are not rendered by default.

2,249 changes: 2,249 additions & 0 deletions VL.ImGui.Stride/help/Basics/HowTo ImGui Windows.vl

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion VL.ImGui.Stride/src/Effects/ImGuiEffectShader.sdsl
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
internal shader ImGuiEffectShader<bool TSRgb> : ShaderBase, PositionStream2, ColorBase, Texturing
{
matrix proj;
float2 offset;

override stage void VSMain()
{
streams.ShadingPosition = mul(proj, float4(streams.Position2, 0.0, 1.0f)) + float4(-1.0f, 1.0f, 0.0f, 0.0f);
streams.ShadingPosition = mul(proj, float4(streams.Position2 - offset, 0.0, 1.0f)) + float4( -1.0f, 1.0f, 0.0f, 0.0f);

if (TSRgb)
{
Expand Down
1 change: 1 addition & 0 deletions VL.ImGui.Stride/src/Effects/ImGuiEffectShader.sdsl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@ namespace VL.ImGui.Stride.Effects
internal static partial class ImGuiEffectShaderKeys
{
public static readonly ValueParameterKey<Matrix> proj = ParameterKeys.NewValue<Matrix>();
public static readonly ValueParameterKey<Vector2> offset = ParameterKeys.NewValue<Vector2>();
}
}
27 changes: 27 additions & 0 deletions VL.ImGui.Stride/src/FixedAsciiString.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System;
using System.Runtime.InteropServices;
using System.Text;

namespace VL.ImGui.Stride
{
public class FixedAsciiString : IDisposable
{
public IntPtr DataPtr { get; }

public unsafe FixedAsciiString(string s)
{
int byteCount = Encoding.ASCII.GetByteCount(s);
DataPtr = Marshal.AllocHGlobal(byteCount + 1);
fixed (char* sPtr = s)
{
int end = Encoding.ASCII.GetBytes(sPtr, s.Length, (byte*)DataPtr, byteCount);
((byte*)DataPtr)[end] = 0;
}
}

public void Dispose()
{
Marshal.FreeHGlobal(DataPtr);
}
}
}
33 changes: 26 additions & 7 deletions VL.ImGui.Stride/src/ImGuiRenderer.InputHandling.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
using Stride.Input;
using SkiaSharp;
using Stride.Input;
using Stride.Rendering;
using System.Reactive.Disposables;
using VL.Skia;
using VL.Stride;
using CommonSpace = VL.Skia.CommonSpace;

namespace VL.ImGui
{
Expand All @@ -16,14 +19,30 @@ IDisposable SubscribeToInputSource(IInputSource inputSource, RenderDrawContext c
if (inputManager is null)
return Disposable.Empty;

// Mimic the behavior of the Skia render path
var viewport = context.RenderContext.ViewportState.Viewport0;
var viewportLayer = new InViewportUpstream();
var withinCommonSpaceLayer = new SetSpaceUpstream2();

var self = new SetNotify();
self.Update(null, (n, c) =>
{
using (_strideDeviceContext.MakeCurrent())
{
_strideDeviceContext.IO.HandleNotification(n);
}
return n.Handled;
}, out _);

withinCommonSpaceLayer.Update(self, out var spaceLayer, CommonSpace.DIPTopLeft);
viewportLayer.Update(spaceLayer, SKRect.Create(viewport.X, viewport.Y, viewport.Width, viewport.Height), CommonSpace.PixelTopLeft, out _);

var callerInfo = CallerInfo.InRenderer(viewport.Width, viewport.Height, canvas: null, context: null);
return inputManager.GetNotifications(inputSource, sender: this)
.Subscribe(notification =>
.Subscribe(n =>
{
using (_context.MakeCurrent())
{
_io.HandleNotification(notification, useWorldSpace: false);
}
});
viewportLayer.Notify(n, callerInfo);
});
}
}
}
Loading