-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #619 from FUSEEProjectTeam/feature/618-cannot-set-…
…minwidth-and-minheight-for-imguirendercanvasimp Feature/618 cannot set minwidth and minheight for imguirendercanvasimp
- Loading branch information
Showing
18 changed files
with
332 additions
and
680 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
using Fusee.Engine.Common; | ||
using System; | ||
|
||
namespace Fusee.Engine.Core | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
157 changes: 157 additions & 0 deletions
157
src/Engine/Imp/Graphics/Desktop/RenderCanvasGameWindow.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,157 @@ | ||
using Fusee.Engine.Common; | ||
using OpenTK.Graphics.OpenGL; | ||
using OpenTK.Windowing.Desktop; | ||
using OpenTK.Windowing.GraphicsLibraryFramework; | ||
using System; | ||
|
||
namespace Fusee.Engine.Imp.Graphics.Desktop | ||
{ | ||
internal class RenderCanvasGameWindow : GameWindow | ||
{ | ||
#region Fields | ||
|
||
private readonly RenderCanvasImp _renderCanvasImp; | ||
|
||
/// <summary> | ||
/// True if the GameWindow/ the application uses multiple threads. | ||
/// With OpenTK 4.7 we need to use the "new" modifier to hide the GameWindow.IsMultithreaded property, which became obsolete in this version. | ||
/// </summary> | ||
public new bool IsMultiThreaded { get; private set; } = false; | ||
|
||
/// <summary> | ||
/// Gets the delta time. | ||
/// The delta time is the time that was required to render the last frame in milliseconds. | ||
/// This value can be used to determine the frames per second of the application. | ||
/// </summary> | ||
/// <value> | ||
/// The delta time in milliseconds. | ||
/// </value> | ||
public float DeltaTime { get; private set; } | ||
|
||
/// <summary> | ||
/// Gets the delta time. | ||
/// The delta time is the time that was required to update the last frame in milliseconds. | ||
/// </summary> | ||
/// <value> | ||
/// The delta time in milliseconds. | ||
/// </value> | ||
public float DeltaTimeUpdate { get; private set; } | ||
|
||
/// <summary> | ||
/// Gets and sets a value indicating whether [blending]. | ||
/// Blending is used to render transparent objects. | ||
/// </summary> | ||
/// <value> | ||
/// <c>true</c> if [blending]; otherwise, <c>false</c>. | ||
/// </value> | ||
public bool Blending | ||
{ | ||
get => GL.IsEnabled(EnableCap.Blend); | ||
set | ||
{ | ||
if (value) | ||
{ | ||
GL.Enable(EnableCap.Blend); | ||
GL.BlendFunc(BlendingFactor.SrcAlpha, BlendingFactor.OneMinusSrcAlpha); | ||
} | ||
else | ||
{ | ||
GL.Disable(EnableCap.Blend); | ||
} | ||
} | ||
} | ||
|
||
#endregion | ||
|
||
#region Constructors | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="RenderCanvasGameWindow"/> class. | ||
/// </summary> | ||
/// <param name="renderCanvasImp">The render canvas implementation.</param> | ||
/// <param name="width">The width.</param> | ||
/// <param name="height">The height.</param> | ||
/// <param name="antiAliasing">if set to <c>true</c> [anti aliasing] is on.</param> | ||
/// <param name="minimumWidth">The minimum width of the game window.</param> | ||
/// <param name="minimumHeight">The minimum height of the game window</param> | ||
/// <param name="isMultithreaded">If true OpenTk will call run() in a new Thread. The default value is false.</param> | ||
/// <param name="startVisible">Should the window be visible from the start, default: true.</param> | ||
public RenderCanvasGameWindow(RenderCanvasImp renderCanvasImp, int width, int height, bool antiAliasing, bool isMultithreaded = false, bool startVisible = true, int minimumWidth = 1280, int minimumHeight = 720) | ||
: base(new GameWindowSettings(), new NativeWindowSettings | ||
{ | ||
Size = new OpenTK.Mathematics.Vector2i(width, height), | ||
Profile = OpenTK.Windowing.Common.ContextProfile.Core, | ||
Flags = OpenTK.Windowing.Common.ContextFlags.ForwardCompatible, | ||
StartVisible = startVisible, | ||
MinimumSize = new OpenTK.Mathematics.Vector2i(minimumWidth, minimumHeight) | ||
}) | ||
{ | ||
IsMultiThreaded = isMultithreaded; | ||
_renderCanvasImp = renderCanvasImp; | ||
_renderCanvasImp.Width = width; | ||
_renderCanvasImp.Height = height; | ||
} | ||
|
||
#endregion | ||
|
||
#region Overrides | ||
|
||
protected override void OnLoad() | ||
{ | ||
// Check for necessary capabilities | ||
string version = GL.GetString(StringName.Version); | ||
|
||
int major = version[0]; | ||
// int minor = (int)version[2]; | ||
|
||
if (major < 2) | ||
{ | ||
throw new InvalidOperationException("You need at least OpenGL 2.0 to run this example. GLSL not supported."); | ||
} | ||
|
||
// Use VSync! | ||
VSync = OpenTK.Windowing.Common.VSyncMode.On; | ||
|
||
_renderCanvasImp.DoInit(); | ||
} | ||
|
||
protected override void OnUnload() | ||
{ | ||
_renderCanvasImp.DoUnLoad(); | ||
} | ||
|
||
protected override void OnResize(OpenTK.Windowing.Common.ResizeEventArgs e) | ||
{ | ||
base.OnResize(e); | ||
|
||
if (_renderCanvasImp != null) | ||
{ | ||
_renderCanvasImp.Width = e.Width; | ||
_renderCanvasImp.Height = e.Height; | ||
_renderCanvasImp.DoResize(e.Width, e.Height); | ||
} | ||
} | ||
|
||
protected override void OnUpdateFrame(OpenTK.Windowing.Common.FrameEventArgs args) | ||
{ | ||
base.OnUpdateFrame(args); | ||
|
||
DeltaTimeUpdate = (float)args.Time; | ||
|
||
if (KeyboardState.IsKeyPressed(OpenTK.Windowing.GraphicsLibraryFramework.Keys.F11)) | ||
WindowState = (WindowState != OpenTK.Windowing.Common.WindowState.Fullscreen) ? OpenTK.Windowing.Common.WindowState.Fullscreen : OpenTK.Windowing.Common.WindowState.Normal; | ||
|
||
_renderCanvasImp?.DoUpdate(); | ||
} | ||
|
||
protected override void OnRenderFrame(OpenTK.Windowing.Common.FrameEventArgs args) | ||
{ | ||
base.OnRenderFrame(args); | ||
|
||
DeltaTime = (float)args.Time; | ||
|
||
_renderCanvasImp?.DoRender(); | ||
} | ||
|
||
#endregion | ||
} | ||
} |
Oops, something went wrong.