From ac39a65511680f4e3ad8964ab92130f10d6ec354 Mon Sep 17 00:00:00 2001 From: Leon Rauschenberg Date: Thu, 14 Feb 2019 15:46:16 +0100 Subject: [PATCH] Nichts besonderes --- src/JuicyGraphics.csproj | 13 ++--- src/JuicyGraphics/renderer/camera2D.cs | 7 ++- .../graphicalObjects/gridBackground.cs | 9 ++++ .../renderer/{ => graphicalObjects}/line.cs | 0 src/JuicyGraphics/renderer/renderCam.cs | 6 ++- src/JuicyGraphics/ui/canvas.cs | 13 +++++ ...Form1.Designer.cs => mainForm.Designer.cs} | 48 ++++++++++++++----- .../ui/{Form1.cs => mainForm.cs} | 0 .../ui/{Form1.resx => mainForm.resx} | 0 .../ExternalRenderContextProvider.cs | 2 - .../FBORenderContextProvider.cs | 1 - .../RenderContextProvider.cs | 1 - src/SharpGL/Shaders/ShaderProgram.cs | 1 - 13 files changed, 76 insertions(+), 25 deletions(-) create mode 100644 src/JuicyGraphics/renderer/graphicalObjects/gridBackground.cs rename src/JuicyGraphics/renderer/{ => graphicalObjects}/line.cs (100%) rename src/JuicyGraphics/ui/{Form1.Designer.cs => mainForm.Designer.cs} (81%) rename src/JuicyGraphics/ui/{Form1.cs => mainForm.cs} (100%) rename src/JuicyGraphics/ui/{Form1.resx => mainForm.resx} (100%) diff --git a/src/JuicyGraphics.csproj b/src/JuicyGraphics.csproj index 0534749..28769c1 100644 --- a/src/JuicyGraphics.csproj +++ b/src/JuicyGraphics.csproj @@ -51,19 +51,20 @@ + - + Component - + Form - - Form1.cs + + mainForm.cs @@ -91,8 +92,8 @@ - - Form1.cs + + mainForm.cs ResXFileCodeGenerator diff --git a/src/JuicyGraphics/renderer/camera2D.cs b/src/JuicyGraphics/renderer/camera2D.cs index d430f27..638881a 100644 --- a/src/JuicyGraphics/renderer/camera2D.cs +++ b/src/JuicyGraphics/renderer/camera2D.cs @@ -1,4 +1,5 @@ using SharpGL; +using System; using System.Numerics; namespace Graphics { @@ -15,13 +16,15 @@ namespace Graphics { } } + const double maxScale = 18.0; + public double scale { get { return mat[0, 0]; } set { - mat[0, 0] = value; - mat[1, 1] = value; + mat[0, 0] = Math.Min(value, maxScale); + mat[1, 1] = Math.Min(value, maxScale); } } diff --git a/src/JuicyGraphics/renderer/graphicalObjects/gridBackground.cs b/src/JuicyGraphics/renderer/graphicalObjects/gridBackground.cs new file mode 100644 index 0000000..626eff6 --- /dev/null +++ b/src/JuicyGraphics/renderer/graphicalObjects/gridBackground.cs @@ -0,0 +1,9 @@ +using System.Numerics; + +namespace Graphics.Objects { + class gridBackground : iGraphicalObject { + public void render(renderCam context) { + + } + } +} diff --git a/src/JuicyGraphics/renderer/line.cs b/src/JuicyGraphics/renderer/graphicalObjects/line.cs similarity index 100% rename from src/JuicyGraphics/renderer/line.cs rename to src/JuicyGraphics/renderer/graphicalObjects/line.cs diff --git a/src/JuicyGraphics/renderer/renderCam.cs b/src/JuicyGraphics/renderer/renderCam.cs index ae97d96..ef05d60 100644 --- a/src/JuicyGraphics/renderer/renderCam.cs +++ b/src/JuicyGraphics/renderer/renderCam.cs @@ -1,7 +1,7 @@ using System.Windows.Forms; using System.Numerics; using SharpGL; - +using System.Drawing; namespace Graphics { class renderCam : camera2D { @@ -9,6 +9,10 @@ namespace Graphics { OpenGL gl; Control ownerControl; + public Vector2 resolution { + get { return new Vector2(ownerControl.Size.Width, ownerControl.Size.Height); } + } + public renderCam(OpenGL glContext, Control owner) : base() { gl = glContext; ownerControl = owner; diff --git a/src/JuicyGraphics/ui/canvas.cs b/src/JuicyGraphics/ui/canvas.cs index 13df864..c8f6d37 100644 --- a/src/JuicyGraphics/ui/canvas.cs +++ b/src/JuicyGraphics/ui/canvas.cs @@ -111,6 +111,7 @@ namespace JuicyGraphics { break; } prevMousePosition = MousePosition; + this.Focus(); } protected override void OnMouseMove(MouseEventArgs e) { @@ -145,7 +146,19 @@ namespace JuicyGraphics { } } + Control prevFocused = null; + + protected override void OnMouseEnter(EventArgs e) { + prevFocused = Form.ActiveForm.ActiveControl; + this.Focus(); + } + + protected override void OnMouseLeave(EventArgs e) { + prevFocused.Focus(); + } + protected override void OnMouseWheel(MouseEventArgs e) { + Form.ActiveForm.Text = e.Delta.ToString(); rc.scale *= Math.Pow(1.0008, e.Delta); Invalidate(); } diff --git a/src/JuicyGraphics/ui/Form1.Designer.cs b/src/JuicyGraphics/ui/mainForm.Designer.cs similarity index 81% rename from src/JuicyGraphics/ui/Form1.Designer.cs rename to src/JuicyGraphics/ui/mainForm.Designer.cs index dc29d44..9e435e0 100644 --- a/src/JuicyGraphics/ui/Form1.Designer.cs +++ b/src/JuicyGraphics/ui/mainForm.Designer.cs @@ -28,8 +28,10 @@ this.editToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.tabControl1 = new System.Windows.Forms.TabControl(); this.tabPage1 = new System.Windows.Forms.TabPage(); - this.canvas1 = new JuicyGraphics.canvas(); this.tabPage2 = new System.Windows.Forms.TabPage(); + this.button1 = new System.Windows.Forms.Button(); + this.button2 = new System.Windows.Forms.Button(); + this.canvas1 = new JuicyGraphics.canvas(); this.menuStrip1.SuspendLayout(); this.tabControl1.SuspendLayout(); this.tabPage1.SuspendLayout(); @@ -74,6 +76,8 @@ // // tabPage1 // + this.tabPage1.Controls.Add(this.button2); + this.tabPage1.Controls.Add(this.button1); this.tabPage1.Controls.Add(this.canvas1); this.tabPage1.Location = new System.Drawing.Point(4, 22); this.tabPage1.Name = "tabPage1"; @@ -83,6 +87,36 @@ this.tabPage1.Text = "Scene Editor"; this.tabPage1.UseVisualStyleBackColor = true; // + // tabPage2 + // + this.tabPage2.Location = new System.Drawing.Point(4, 22); + this.tabPage2.Name = "tabPage2"; + this.tabPage2.Padding = new System.Windows.Forms.Padding(3); + this.tabPage2.Size = new System.Drawing.Size(671, 455); + this.tabPage2.TabIndex = 1; + this.tabPage2.Text = "Object Editor"; + this.tabPage2.UseVisualStyleBackColor = true; + // + // button1 + // + this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.button1.Location = new System.Drawing.Point(532, 7); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(75, 23); + this.button1.TabIndex = 1; + this.button1.Text = "button1"; + this.button1.UseVisualStyleBackColor = true; + // + // button2 + // + this.button2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.button2.Location = new System.Drawing.Point(532, 37); + this.button2.Name = "button2"; + this.button2.Size = new System.Drawing.Size(75, 23); + this.button2.TabIndex = 2; + this.button2.Text = "button2"; + this.button2.UseVisualStyleBackColor = true; + // // canvas1 // this.canvas1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) @@ -94,16 +128,6 @@ this.canvas1.TabIndex = 0; this.canvas1.Text = "canvas1"; // - // tabPage2 - // - this.tabPage2.Location = new System.Drawing.Point(4, 22); - this.tabPage2.Name = "tabPage2"; - this.tabPage2.Padding = new System.Windows.Forms.Padding(3); - this.tabPage2.Size = new System.Drawing.Size(671, 455); - this.tabPage2.TabIndex = 1; - this.tabPage2.Text = "Object Editor"; - this.tabPage2.UseVisualStyleBackColor = true; - // // mainForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -133,6 +157,8 @@ private System.Windows.Forms.TabPage tabPage1; private canvas canvas1; private System.Windows.Forms.TabPage tabPage2; + private System.Windows.Forms.Button button2; + private System.Windows.Forms.Button button1; } } diff --git a/src/JuicyGraphics/ui/Form1.cs b/src/JuicyGraphics/ui/mainForm.cs similarity index 100% rename from src/JuicyGraphics/ui/Form1.cs rename to src/JuicyGraphics/ui/mainForm.cs diff --git a/src/JuicyGraphics/ui/Form1.resx b/src/JuicyGraphics/ui/mainForm.resx similarity index 100% rename from src/JuicyGraphics/ui/Form1.resx rename to src/JuicyGraphics/ui/mainForm.resx diff --git a/src/SharpGL/RenderContextProviders/ExternalRenderContextProvider.cs b/src/SharpGL/RenderContextProviders/ExternalRenderContextProvider.cs index 6267dd8..ab3ab72 100644 --- a/src/SharpGL/RenderContextProviders/ExternalRenderContextProvider.cs +++ b/src/SharpGL/RenderContextProviders/ExternalRenderContextProvider.cs @@ -40,7 +40,6 @@ namespace SharpGL.RenderContextProviders /// The HDC. public override void Blit(IntPtr hdc) { - // TODO: Should this do something in the case of an external context? if (this.deviceContextHandle != IntPtr.Zero || this.windowHandle != IntPtr.Zero) { //Swap the buffers. @@ -53,7 +52,6 @@ namespace SharpGL.RenderContextProviders /// public override void MakeCurrent() { - // TODO: Should this have an effect with an external context? // if (renderContextHandle != IntPtr.Zero) // Win32.wglMakeCurrent(deviceContextHandle, renderContextHandle); } diff --git a/src/SharpGL/RenderContextProviders/FBORenderContextProvider.cs b/src/SharpGL/RenderContextProviders/FBORenderContextProvider.cs index ff72d25..71fcb1f 100644 --- a/src/SharpGL/RenderContextProviders/FBORenderContextProvider.cs +++ b/src/SharpGL/RenderContextProviders/FBORenderContextProvider.cs @@ -104,7 +104,6 @@ namespace SharpGL.RenderContextProviders DestroyFramebuffers(); - // TODO: We should be able to just use the code below - however we // get invalid dimension issues at the moment, so recreate for now. /* diff --git a/src/SharpGL/RenderContextProviders/RenderContextProvider.cs b/src/SharpGL/RenderContextProviders/RenderContextProvider.cs index 8e69b17..d96c547 100644 --- a/src/SharpGL/RenderContextProviders/RenderContextProvider.cs +++ b/src/SharpGL/RenderContextProviders/RenderContextProvider.cs @@ -112,7 +112,6 @@ namespace SharpGL.RenderContextProviders } catch(Exception) { - // TODO: can we actually get the real version? createdOpenGLVersion = OpenGLVersion.OpenGL2_1; } } diff --git a/src/SharpGL/Shaders/ShaderProgram.cs b/src/SharpGL/Shaders/ShaderProgram.cs index e25b171..429bf1d 100644 --- a/src/SharpGL/Shaders/ShaderProgram.cs +++ b/src/SharpGL/Shaders/ShaderProgram.cs @@ -137,7 +137,6 @@ namespace SharpGL.Shaders if (uniformNamesToLocations.ContainsKey(uniformName) == false) { uniformNamesToLocations[uniformName] = gl.GetUniformLocation(shaderProgramObject, uniformName); - // TODO: if it's not found, we should probably throw an exception. } // Return the uniform location.