diff --git a/GL_EditorFramework-master/.gitattributes b/GL_EditorFramework-master/.gitattributes new file mode 100644 index 00000000..dfe07704 --- /dev/null +++ b/GL_EditorFramework-master/.gitattributes @@ -0,0 +1,2 @@ +# Auto detect text files and perform LF normalization +* text=auto diff --git a/GL_EditorFramework-master/.gitignore b/GL_EditorFramework-master/.gitignore new file mode 100644 index 00000000..3e759b75 --- /dev/null +++ b/GL_EditorFramework-master/.gitignore @@ -0,0 +1,330 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore + +# User-specific files +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ +**/Properties/launchSettings.json + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_i.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding add-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# JetBrains Rider +.idea/ +*.sln.iml + +# CodeRush +.cr/ + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ diff --git a/GL_EditorFramework-master/GL_Core/Cameras/Inspect.cs b/GL_EditorFramework-master/GL_Core/Cameras/Inspect.cs new file mode 100644 index 00000000..38b4815f --- /dev/null +++ b/GL_EditorFramework-master/GL_Core/Cameras/Inspect.cs @@ -0,0 +1,48 @@ +using GL_Core.Public_Interfaces; +using OpenTK; +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace GL_Core.Cameras +{ + public class InspectCamera : AbstractCamera + { + public InspectCamera() + { + + } + public override bool MouseMove(MouseEventArgs e, Point lastMouseLoc, float deltaX, float deltaY, ExtraArgs args, ref Vector3 camTarget, ref float rot, ref float lookup, ref float zoom) + { + if (e.Button == MouseButtons.Right) + { + rot += deltaX * 0.01f; + lookup += deltaY * 0.01f; + return true; + } + else if (e.Button == MouseButtons.Left) + { + deltaX *= Math.Min(0.1f, args.pickingDepth * args.factorX); + deltaY *= Math.Min(0.1f, args.pickingDepth * args.factorY); + + camTarget += Vector3.UnitX * (float)Math.Cos(rot) * deltaX; + camTarget -= Vector3.UnitX * (float)Math.Sin(rot) * (float)Math.Sin(lookup) * deltaY; + camTarget -= Vector3.UnitY * (float)Math.Cos(lookup) * deltaY; + camTarget += Vector3.UnitZ * (float)Math.Sin(rot) * deltaX; + camTarget += Vector3.UnitZ * (float)Math.Cos(rot) * (float)Math.Sin(lookup) * deltaY; + return true; + } + return false; + } + + public override bool MouseWheel(MouseEventArgs e, float xoff, float yoff, ExtraArgs args, ref Vector3 camTarget, ref float rot, ref float lookup, ref float zoom) + { + zoom *= 1f - e.Delta * 0.001f; + return true; + } + } +} diff --git a/GL_EditorFramework-master/GL_Core/Cameras/Walkaround.cs b/GL_EditorFramework-master/GL_Core/Cameras/Walkaround.cs new file mode 100644 index 00000000..5c75b89d --- /dev/null +++ b/GL_EditorFramework-master/GL_Core/Cameras/Walkaround.cs @@ -0,0 +1,64 @@ +using GL_Core.Public_Interfaces; +using OpenTK; +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace GL_Core.Cameras +{ + public class WalkaroundCamera : AbstractCamera + { + public WalkaroundCamera() + { + + } + public override bool MouseMove(MouseEventArgs e, Point lastMouseLoc, float deltaX, float deltaY, ExtraArgs args, ref Vector3 camTarget, ref float rot, ref float lookup, ref float zoom) + { + + if (e.Button == MouseButtons.Right) + { + rot += deltaX * 0.002f; + lookup += deltaY * 0.002f; + return true; + } + else if (e.Button == MouseButtons.Left) + { + //code from Whitehole + + deltaX *= Math.Min(0.1f, args.pickingDepth* args.factorX); + deltaY *= Math.Min(0.1f, args.pickingDepth* args.factorY); + + camTarget += Vector3.UnitX * deltaX * (float)Math.Cos(rot); + camTarget -= Vector3.UnitX * deltaY * (float)Math.Sin(rot) * (float)Math.Sin(lookup); + camTarget -= Vector3.UnitY * deltaY * (float)Math.Cos(lookup); + camTarget += Vector3.UnitZ * deltaX * (float)Math.Sin(rot); + camTarget += Vector3.UnitZ * deltaY * (float)Math.Cos(rot) * (float)Math.Sin(lookup); + + return true; + } + return false; + } + + public override bool MouseWheel(MouseEventArgs e, float xoff, float yoff, ExtraArgs args, ref Vector3 camTarget, ref float rot, ref float lookup, ref float zoom) + { + float delta = (float)(e.Delta * Math.Min(0.01f, args.pickingDepth / 500f)); + camTarget -= Vector3.UnitX * (float)Math.Sin(rot) * (float)Math.Cos(lookup) * delta; + camTarget += Vector3.UnitY * (float)Math.Sin(lookup) * delta; + camTarget += Vector3.UnitZ * (float)Math.Cos(rot) * (float)Math.Cos(lookup) * delta; + + float factoffX = (float)(-xoff * delta) * args.factorX; + float factoffY = (float)(-yoff * delta) * args.factorY; + + camTarget += Vector3.UnitX * (float)Math.Cos(rot) * factoffX; + camTarget -= Vector3.UnitX * (float)Math.Sin(rot) * (float)Math.Sin(lookup) * factoffY; + camTarget -= Vector3.UnitY * (float)Math.Cos(lookup) * factoffY; + camTarget += Vector3.UnitZ * (float)Math.Sin(rot) * factoffX; + camTarget += Vector3.UnitZ * (float)Math.Cos(rot) * (float)Math.Sin(lookup) * factoffY; + return true; + } + } +} diff --git a/GL_EditorFramework-master/GL_Core/GL_ControlLegacy.Designer.cs b/GL_EditorFramework-master/GL_Core/GL_ControlLegacy.Designer.cs new file mode 100644 index 00000000..0354c89a --- /dev/null +++ b/GL_EditorFramework-master/GL_Core/GL_ControlLegacy.Designer.cs @@ -0,0 +1,37 @@ +namespace GL_Core +{ + partial class GL_ControlLegacy + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + components = new System.ComponentModel.Container(); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + } + + #endregion + } +} diff --git a/GL_EditorFramework-master/GL_Core/GL_ControlLegacy.cs b/GL_EditorFramework-master/GL_Core/GL_ControlLegacy.cs new file mode 100644 index 00000000..bdbcac2a --- /dev/null +++ b/GL_EditorFramework-master/GL_Core/GL_ControlLegacy.cs @@ -0,0 +1,338 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Data; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using OpenTK; +using OpenTK.Graphics.OpenGL; +using GL_Core.Interfaces; +using GL_Core.Public_Interfaces; +using GL_Core.Cameras; + +namespace GL_Core +{ + public partial class GL_ControlLegacy : GLControl + { + public GL_ControlLegacy():base(OpenTK.Graphics.GraphicsMode.Default,1,1, OpenTK.Graphics.GraphicsContextFlags.Default) + { + InitializeComponent(); + } + + private Point lastMouseLoc; + private Point dragStartLoc; + private float lastDepth = 1000f; + private AbstractCamera activeCamera; + float rot = 0; + float lookup = 0; + float zoom = -10f; + Vector3 camTarget; + + float zfar = 1000f; + float znear = 0.01f; + float fov = MathHelper.PiOver4; + + uint[] pickingFrameBuffer = new uint[9]; + int pickingIndex; + float pickingModelDepth = 0f; + private float pickingDepth = 0f; + + public Matrix4 mtxMdl, mtxCam, mtxProj; + private float factorX, factorY; + + bool stereoscopy; + + int viewPortX(int x) => stereoscopy ? x % (Width / 2) : x; + int viewPortDX(int dx) => stereoscopy ? dx * 2 : dx; + int viewPortXOff(int x) => stereoscopy ? (x - Width / 4)*2 : x - Width / 2; + int viewPortWidth() => stereoscopy ? Width / 2 : Width; + + public bool Stereoscopy + { + get => stereoscopy; + set + { + stereoscopy = value; + OnResize(null); + Refresh(); + } + } + + AbstractGlDrawable mainDrawable; + + public AbstractGlDrawable MainDrawable + { + get => mainDrawable; + set + { + if (value == null) return; + mainDrawable = value; + MakeCurrent(); + mainDrawable.Prepare(this); + Refresh(); + } + } + + public AbstractCamera ActiveCamera + { + get => activeCamera; + set + { + if (value == null) return; + activeCamera = value; + MakeCurrent(); + Refresh(); + } + } + + public Color nextPickingColor() + { + return Color.FromArgb(pickingIndex++); + } + public void UpdateModelMatrix(Matrix4 matrix) + { + mtxMdl = matrix; + GL.MatrixMode(MatrixMode.Modelview); + GL.LoadMatrix(ref mtxMdl); + } + + public void ApplyModelTransform(Matrix4 matrix) + { + mtxMdl *= matrix; + GL.MatrixMode(MatrixMode.Modelview); + GL.LoadMatrix(ref mtxMdl); + } + + public void ResetModelMatrix() + { + mtxMdl = Matrix4.Identity; + GL.MatrixMode(MatrixMode.Modelview); + GL.LoadMatrix(ref mtxMdl); + } + + protected override void OnLoad(EventArgs e) + { + if (DesignMode) return; + + activeCamera = new WalkaroundCamera(); + + GL.Enable(EnableCap.DepthTest); + } + + protected override void OnResize(EventArgs e) + { + if (DesignMode || this.Context == null) return; + MakeCurrent(); + + float aspect_ratio; + if (stereoscopy) + aspect_ratio = Width / 2 / (float)Height; + else + aspect_ratio = Width / (float)Height; + + mtxProj = Matrix4.CreatePerspectiveFieldOfView(fov, aspect_ratio, znear, zfar); + + //using the calculation from whitehole + factorX = (2f * (float)Math.Tan(fov * 0.5f) * aspect_ratio) / Width; + + factorY = (2f * (float)Math.Tan(fov * 0.5f)) / Height; + } + + protected override void OnPaint(PaintEventArgs e) + { + if (mainDrawable == null || DesignMode) + { + e.Graphics.Clear(this.BackColor); + e.Graphics.DrawString("Legacy Gl" + (stereoscopy ? " stereoscopy" : ""), SystemFonts.DefaultFont, SystemBrushes.ControlLight, 10f, 10f); + return; + } + + GL.ClearColor(0.125f, 0.125f, 0.125f, 1.0f); + GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); + + if (stereoscopy) + { + #region left eye + GL.Viewport(0, 0, Width / 2, Height); + + mtxMdl = Matrix4.Identity; + mtxCam = + Matrix4.CreateTranslation(camTarget) * + Matrix4.CreateRotationY(rot + 0.02f) * + Matrix4.CreateRotationX(lookup) * + Matrix4.CreateTranslation(0, 0, zoom); + + GL.MatrixMode(MatrixMode.Projection); + Matrix4 computedMatrix = mtxCam * mtxProj; + GL.LoadMatrix(ref computedMatrix); + + mainDrawable.Draw(this); + #endregion + + #region right eye + GL.Viewport(Width / 2, 0, Width / 2, Height); + + mtxMdl = Matrix4.Identity; + mtxCam = + Matrix4.CreateTranslation(camTarget) * + Matrix4.CreateRotationY(rot - 0.02f) * + Matrix4.CreateRotationX(lookup) * + Matrix4.CreateTranslation(0, 0, zoom); + + computedMatrix = mtxCam * mtxProj; + GL.LoadMatrix(ref computedMatrix); + mainDrawable.Draw(this); + #endregion + } + else + { + GL.Viewport(0, 0, Width, Height); + + mtxMdl = Matrix4.Identity; + mtxCam = + Matrix4.CreateTranslation(camTarget) * + Matrix4.CreateRotationY(rot - 0.02f) * + Matrix4.CreateRotationX(lookup) * + Matrix4.CreateTranslation(0, 0, zoom); + + GL.MatrixMode(MatrixMode.Projection); + Matrix4 computedMatrix = mtxCam * mtxProj; + GL.LoadMatrix(ref computedMatrix); + mainDrawable.Draw(this); + } + + SwapBuffers(); + } + + protected override void OnMouseDown(MouseEventArgs e) + { + if (mainDrawable == null) return; + + lastMouseLoc = e.Location; + lastDepth = pickingDepth; + dragStartLoc = e.Location; + if (mainDrawable.MouseDown(e) || + activeCamera.MouseDown(e, ref camTarget, ref rot, ref lookup, ref zoom)) + Refresh(); + } + + protected override void OnMouseMove(MouseEventArgs e) + { + if (mainDrawable == null) return; + + float deltaX = viewPortDX(e.Location.X - lastMouseLoc.X); + float deltaY = e.Location.Y - lastMouseLoc.Y; + + bool shouldredraw = false; + shouldredraw = shouldredraw || activeCamera.MouseMove(e, lastMouseLoc, deltaX, deltaY, new ExtraArgs(factorX, factorY, lastDepth), ref camTarget, ref rot, ref lookup, ref zoom); + + lastMouseLoc = e.Location; + + #region picking + MakeCurrent(); + + GL.ClearColor(0f, 0f, 0f, 0f); + GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); + + if (stereoscopy) + GL.Viewport(0, 0, Width / 2, Height); + else + GL.Viewport(0, 0, Width, Height); + + int pickingMouseX = stereoscopy ? (lastMouseLoc.X % (Width / 2)) : lastMouseLoc.X; + + mtxMdl = Matrix4.Identity; + mtxCam = + Matrix4.CreateTranslation(camTarget) * + Matrix4.CreateRotationY(rot - (stereoscopy ? 0.02f : 0f)) * + Matrix4.CreateRotationX(lookup) * + Matrix4.CreateTranslation(0, 0, zoom); + + GL.MatrixMode(MatrixMode.Projection); + Matrix4 computedMatrix = mtxCam * mtxProj; + GL.LoadMatrix(ref computedMatrix); + + pickingIndex = 1; + + mainDrawable.DrawPicking(this); + GL.Flush(); + + GL.ReadPixels(pickingMouseX, Height - lastMouseLoc.Y, 1, 1, PixelFormat.DepthComponent, PixelType.Float, ref pickingModelDepth); + + pickingModelDepth = -(zfar * znear / (pickingModelDepth * (zfar - znear) - zfar)); + + + + GL.Flush(); + + GL.ReadPixels(pickingMouseX - 1, Height - lastMouseLoc.Y + 1, 3, 3, PixelFormat.Bgra, PixelType.UnsignedByte, pickingFrameBuffer); + + + + // depth math from http://www.opengl.org/resources/faq/technical/depthbuffer.htm + + GL.ReadPixels(pickingMouseX, Height - lastMouseLoc.Y, 1, 1, PixelFormat.DepthComponent, PixelType.Float, ref pickingDepth); + + pickingDepth = -(zfar * znear / (pickingDepth * (zfar - znear) - zfar)); + + shouldredraw = shouldredraw || mainDrawable.Picked(pickingFrameBuffer[4]); + + #endregion + + shouldredraw = shouldredraw || mainDrawable.MouseMove(e, lastMouseLoc, deltaX, deltaY, new ExtraArgs(factorX, factorY, lastDepth), rot, lookup); + + if (shouldredraw) + Refresh(); + } + + protected override void OnMouseWheel(MouseEventArgs e) + { + if (mainDrawable == null) return; + + int x = viewPortX(e.X); + + if (mainDrawable.MouseWheel(e, viewPortXOff(x), e.Y - Height / 2, new ExtraArgs(factorX,factorY, lastDepth), rot, lookup) || + activeCamera.MouseWheel(e, viewPortXOff(x), e.Y - Height / 2, new ExtraArgs(factorX, factorY, lastDepth), ref camTarget, ref rot, ref lookup, ref zoom)) + Refresh(); + } + + protected override void OnMouseUp(MouseEventArgs e) + { + if (mainDrawable == null) return; + + bool shouldredraw = false; + + if ((Math.Abs(e.X - dragStartLoc.X) < 3) && (Math.Abs(e.Y - dragStartLoc.Y) < 3)) + { + shouldredraw = shouldredraw || mainDrawable.MouseClick(e) || + activeCamera.MouseClick(e, ref camTarget, ref rot, ref lookup, ref zoom); + } + shouldredraw = shouldredraw || mainDrawable.MouseUp(e, dragStartLoc) || + activeCamera.MouseUp(e, dragStartLoc, ref camTarget, ref rot, ref lookup, ref zoom); + + if (shouldredraw) + Refresh(); + } + + protected override void OnKeyDown(KeyEventArgs e) + { + if (mainDrawable == null) return; + + if (mainDrawable.KeyDown(e) || + activeCamera.KeyDown(e, ref camTarget, ref rot, ref lookup, ref zoom)) + Refresh(); + } + + protected override void OnKeyUp(KeyEventArgs e) + { + if (mainDrawable == null) return; + + if (mainDrawable.KeyUp(e) || + activeCamera.KeyUp(e, ref camTarget, ref rot, ref lookup, ref zoom)) + Refresh(); + } + } +} diff --git a/GL_EditorFramework-master/GL_Core/GL_ControlModern.Designer.cs b/GL_EditorFramework-master/GL_Core/GL_ControlModern.Designer.cs new file mode 100644 index 00000000..3741c91d --- /dev/null +++ b/GL_EditorFramework-master/GL_Core/GL_ControlModern.Designer.cs @@ -0,0 +1,37 @@ +namespace GL_Core +{ + partial class GL_ControlModern + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + components = new System.ComponentModel.Container(); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + } + + #endregion + } +} diff --git a/GL_EditorFramework-master/GL_Core/GL_ControlModern.cs b/GL_EditorFramework-master/GL_Core/GL_ControlModern.cs new file mode 100644 index 00000000..b30edc06 --- /dev/null +++ b/GL_EditorFramework-master/GL_Core/GL_ControlModern.cs @@ -0,0 +1,352 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Data; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using OpenTK; +using OpenTK.Graphics.OpenGL; +using GL_Core.Interfaces; +using GL_Core.Public_Interfaces; +using GL_Core.Cameras; + +namespace GL_Core +{ + public partial class GL_ControlModern : GLControl + { + public GL_ControlModern() + { + InitializeComponent(); + } + + private Point lastMouseLoc; + private Point dragStartLoc; + private float lastDepth = 1000f; + private ShaderProgram shader; + private AbstractCamera activeCamera; + float rot = 0; + float lookup = 0; + float zoom = -10f; + Vector3 camTarget; + + public float zfar = 1000f; + public float znear = 0.01f; + public float PolyCount = 0; + public float VertCount = 0; + float fov = MathHelper.PiOver4; + + uint[] pickingFrameBuffer = new uint[9]; + int pickingIndex; + float pickingModelDepth = 0f; + private float pickingDepth = 0f; + + public Matrix4 mtxMdl, mtxCam, mtxProj; + private float factorX, factorY; + + bool stereoscopy; + bool displayPolyCount; + + int viewPortX(int x) => stereoscopy ? x % (Width / 2) : x; + int viewPortDX(int dx) => stereoscopy ? dx * 2 : dx; + int viewPortXOff(int x) => stereoscopy ? (x - Width / 4) * 2 : x - Width / 2; + int viewPortWidth() => stereoscopy ? Width / 2 : Width; + + public bool DisplayPolyCount + { + get => displayPolyCount; + set + { + displayPolyCount = value; + OnResize(null); + Refresh(); + } + } + public bool Stereoscopy + { + get => stereoscopy; + set + { + stereoscopy = value; + OnResize(null); + Refresh(); + } + } + + public ShaderProgram CurrentShader + { + get => shader; + set + { + if (value == null) return; + shader = value; + + shader.Setup(mtxMdl, mtxCam, mtxProj); + } + } + + AbstractGlDrawable mainDrawable; + public List abstractGlDrawables = new List(); + public AbstractGlDrawable MainDrawable + { + get => mainDrawable; + set + { + this.Visible = true; + + if (value == null) return; + mainDrawable = value; + MakeCurrent(); + mainDrawable.Prepare(this); + Refresh(); + } + } + + public AbstractCamera ActiveCamera + { + get => activeCamera; + set + { + if (value == null || this.Context == null) return; + activeCamera = value; + MakeCurrent(); + Refresh(); + } + } + + public Color nextPickingColor() + { + return Color.FromArgb(pickingIndex++); + } + + public void UpdateModelMatrix(Matrix4 matrix) + { + shader.UpdateModelMatrix(mtxMdl = matrix); + } + + public void ApplyModelTransform(Matrix4 matrix) + { + shader.UpdateModelMatrix(mtxMdl *= matrix); + } + + public void ResetModelMatrix() + { + shader.UpdateModelMatrix(mtxMdl = Matrix4.Identity); + } + + protected override void OnLoad(EventArgs e) + { + if (DesignMode) return; + + activeCamera = new InspectCamera(); + + GL.Enable(EnableCap.DepthTest); + } + + protected override void OnResize(EventArgs e) + { + if (DesignMode || this.Context == null) return; + MakeCurrent(); + + float aspect_ratio; + if (stereoscopy) + aspect_ratio = Width/2 / (float)Height; + else + aspect_ratio = Width / (float)Height; + + mtxProj = Matrix4.CreatePerspectiveFieldOfView(fov, aspect_ratio, znear, zfar); + + //using the calculation from whitehole + factorX = (2f * (float)Math.Tan(fov * 0.5f) * aspect_ratio) / Width; + + factorY = (2f * (float)Math.Tan(fov * 0.5f)) / Height; + } + + protected override void OnPaint(PaintEventArgs e) + { + if (mainDrawable == null || DesignMode) + { + e.Graphics.Clear(this.BackColor); + e.Graphics.DrawString("Modern Gl" + (stereoscopy ? " stereoscopy" : ""), SystemFonts.DefaultFont, SystemBrushes.ControlLight, 10f, 10f); + return; + } + // e.Graphics.DrawString((displayPolyCount ? $"poly count {PolyCount} vert count {VertCount}" : ""), SystemFonts.DefaultFont, SystemBrushes.ControlLight, 10f, 10f); + + + MakeCurrent(); + GL.ClearColor(0.125f, 0.125f, 0.125f, 1.0f); + GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); + + + if (stereoscopy) + { + #region left eye + GL.Viewport(0, 0, Width / 2, Height); + + mtxMdl = Matrix4.Identity; + mtxCam = + Matrix4.CreateTranslation(camTarget) * + Matrix4.CreateRotationY(rot + 0.02f) * + Matrix4.CreateRotationX(lookup) * + Matrix4.CreateTranslation(0, 0, zoom); + + mainDrawable.Draw(this); + #endregion + + #region right eye + GL.Viewport(Width / 2, 0, Width / 2, Height); + + mtxMdl = Matrix4.Identity; + mtxCam = + Matrix4.CreateTranslation(camTarget) * + Matrix4.CreateRotationY(rot - 0.02f) * + Matrix4.CreateRotationX(lookup) * + Matrix4.CreateTranslation(0, 0, zoom); + + mainDrawable.Draw(this); + #endregion + } + else + { + GL.Viewport(0, 0, Width, Height); + + mtxMdl = Matrix4.Identity; + mtxCam = + Matrix4.CreateTranslation(camTarget) * + Matrix4.CreateRotationY(rot) * + Matrix4.CreateRotationX(lookup) * + Matrix4.CreateTranslation(0, 0, zoom); + + mainDrawable.Draw(this); + } + + SwapBuffers(); + } + + protected override void OnMouseDown(MouseEventArgs e) + { + if (mainDrawable == null) return; + + lastMouseLoc = e.Location; + lastDepth = pickingDepth; + dragStartLoc = e.Location; + if (mainDrawable.MouseDown(e) || + activeCamera.MouseDown(e, ref camTarget, ref rot, ref lookup, ref zoom)) + Refresh(); + } + + protected override void OnMouseMove(MouseEventArgs e) + { + if (mainDrawable == null) return; + + float deltaX = viewPortDX(e.Location.X - lastMouseLoc.X); + float deltaY = (e.Location.Y - lastMouseLoc.Y); + + bool shouldredraw = false; + shouldredraw = shouldredraw || activeCamera.MouseMove(e, lastMouseLoc, deltaX, deltaY, new ExtraArgs(factorX, factorY, lastDepth), ref camTarget, ref rot, ref lookup, ref zoom); + + lastMouseLoc = e.Location; + + #region picking + MakeCurrent(); + + GL.ClearColor(0f, 0f, 0f, 0f); + GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); + + if (stereoscopy) + GL.Viewport(0, 0, Width / 2, Height); + else + GL.Viewport(0, 0, Width, Height); + + int pickingMouseX = stereoscopy ? (lastMouseLoc.X % (Width / 2)) : lastMouseLoc.X; + + mtxMdl = Matrix4.Identity; + mtxCam = + Matrix4.CreateTranslation(camTarget) * + Matrix4.CreateRotationY(rot - (stereoscopy?0.02f:0f)) * + Matrix4.CreateRotationX(lookup) * + Matrix4.CreateTranslation(0, 0, zoom); + + pickingIndex = 1; + + mainDrawable.DrawPicking(this); + GL.Flush(); + + GL.ReadPixels(pickingMouseX, Height - lastMouseLoc.Y, 1, 1, PixelFormat.DepthComponent, PixelType.Float, ref pickingModelDepth); + + pickingModelDepth = -(zfar * znear / (pickingModelDepth * (zfar - znear) - zfar)); + + + + GL.Flush(); + + GL.ReadPixels(pickingMouseX - 1, Height - lastMouseLoc.Y + 1, 3, 3, PixelFormat.Bgra, PixelType.UnsignedByte, pickingFrameBuffer); + + + + // depth math from http://www.opengl.org/resources/faq/technical/depthbuffer.htm + + GL.ReadPixels(pickingMouseX, Height - lastMouseLoc.Y, 1, 1, PixelFormat.DepthComponent, PixelType.Float, ref pickingDepth); + + pickingDepth = -(zfar * znear / (pickingDepth * (zfar - znear) - zfar)); + + shouldredraw = shouldredraw || mainDrawable.Picked(pickingFrameBuffer[4]); + + #endregion + + shouldredraw = shouldredraw || mainDrawable.MouseMove(e, lastMouseLoc, deltaX, deltaY, new ExtraArgs(factorX, factorY, lastDepth), rot, lookup); + + if (shouldredraw) + Refresh(); + } + + protected override void OnMouseWheel(MouseEventArgs e) + { + if (mainDrawable == null) return; + + int x = viewPortX(e.X); + + if (mainDrawable.MouseWheel(e, viewPortXOff(x), e.Y - Height / 2, new ExtraArgs(factorX, factorY, lastDepth), rot, lookup) || + activeCamera.MouseWheel(e, viewPortXOff(x), e.Y - Height / 2, new ExtraArgs(factorX, factorY, lastDepth), ref camTarget, ref rot, ref lookup, ref zoom)) + Refresh(); + } + + protected override void OnMouseUp(MouseEventArgs e) + { + if (mainDrawable == null) return; + + bool shouldredraw = false; + + if ((Math.Abs(e.X - dragStartLoc.X) < 3) && (Math.Abs(e.Y - dragStartLoc.Y) < 3)) + { + shouldredraw = shouldredraw || mainDrawable.MouseClick(e) || + activeCamera.MouseClick(e, ref camTarget, ref rot, ref lookup, ref zoom); + } + shouldredraw = shouldredraw || mainDrawable.MouseUp(e,dragStartLoc) || + activeCamera.MouseUp(e, dragStartLoc, ref camTarget, ref rot, ref lookup, ref zoom); + + if (shouldredraw) + Refresh(); + } + + protected override void OnKeyDown(KeyEventArgs e) + { + if (mainDrawable == null) return; + + if (mainDrawable.KeyDown(e) || + activeCamera.KeyDown(e, ref camTarget, ref rot, ref lookup, ref zoom)) + Refresh(); + } + + protected override void OnKeyUp(KeyEventArgs e) + { + if (mainDrawable == null) return; + + if (mainDrawable.KeyUp(e) || + activeCamera.KeyUp(e, ref camTarget, ref rot, ref lookup, ref zoom)) + Refresh(); + } + } +} diff --git a/GL_EditorFramework-master/GL_Core/GL_Core.csproj b/GL_EditorFramework-master/GL_Core/GL_Core.csproj new file mode 100644 index 00000000..ae4d1054 --- /dev/null +++ b/GL_EditorFramework-master/GL_Core/GL_Core.csproj @@ -0,0 +1,77 @@ + + + + + Debug + AnyCPU + {29647BA5-2859-46F0-A99E-C3A387A9447A} + Library + Properties + GL_Core + GL_Core + v4.6.2 + 512 + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\..\..\..\..\Documents\Visual Studio 2017\Projects\WindowsFormsApp2\WindowsFormsApp2\Lib\OpenTK.dll + + + ..\..\..\..\..\Documents\Visual Studio 2017\Projects\WindowsFormsApp2\WindowsFormsApp2\Lib\OpenTK.GLControl.dll + + + + + + + + + + + + + + + + + UserControl + + + GL_ControlLegacy.cs + + + UserControl + + + GL_ControlModern.cs + + + + + + + + + + + + + \ No newline at end of file diff --git a/GL_EditorFramework-master/GL_Core/OldGlEmulator.cs b/GL_EditorFramework-master/GL_Core/OldGlEmulator.cs new file mode 100644 index 00000000..fff732b7 --- /dev/null +++ b/GL_EditorFramework-master/GL_Core/OldGlEmulator.cs @@ -0,0 +1,52 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using OpenTK.Graphics.OpenGL; + +namespace GL_Core +{ + public class OldGlEmulator : IDisposable + { + List dataList = new List(); + + float current_r = 255f; + float current_g = 255f; + float current_b = 255f; + float current_a = 255f; + public OldGlEmulator() + { + + } + + public void Vertex3(float x, float y, float z) + { + dataList.Add(x); dataList.Add(y); dataList.Add(z); + dataList.Add(current_r); dataList.Add(current_g); dataList.Add(current_b); dataList.Add(current_a); + } + + public void Color3(float r, float g, float b) + { + current_r = r; + current_g = g; + current_b = b; + } + + public void WriteToBuffer(int buffer) { + GL.BindBuffer(BufferTarget.ArrayBuffer, buffer); + float[] arrayData = dataList.ToArray(); + GL.BufferData(BufferTarget.ArrayBuffer, sizeof(float) * arrayData.Length, arrayData, BufferUsageHint.StaticDraw); + + GL.EnableVertexAttribArray(0); + GL.VertexAttribPointer(0, 3, VertexAttribPointerType.Float, false, sizeof(float) * 7, 0); + GL.EnableVertexAttribArray(1); + GL.VertexAttribPointer(1, 4, VertexAttribPointerType.Float, false, sizeof(float) * 7, sizeof(float) * 3); + } + + public void Dispose() + { + + } + } +} diff --git a/GL_EditorFramework-master/GL_Core/OpenTK.dll.config b/GL_EditorFramework-master/GL_Core/OpenTK.dll.config new file mode 100644 index 00000000..7098d39e --- /dev/null +++ b/GL_EditorFramework-master/GL_Core/OpenTK.dll.config @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/GL_EditorFramework-master/GL_Core/Properties/AssemblyInfo.cs b/GL_EditorFramework-master/GL_Core/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..72b2257d --- /dev/null +++ b/GL_EditorFramework-master/GL_Core/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("GL_Core")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("GL_Core")] +[assembly: AssemblyCopyright("Copyright © 2018")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("29647ba5-2859-46f0-a99e-c3a387a9447a")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/GL_EditorFramework-master/GL_Core/Public Interfaces/AbstractCamera.cs b/GL_EditorFramework-master/GL_Core/Public Interfaces/AbstractCamera.cs new file mode 100644 index 00000000..433d508c --- /dev/null +++ b/GL_EditorFramework-master/GL_Core/Public Interfaces/AbstractCamera.cs @@ -0,0 +1,36 @@ +using OpenTK; +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace GL_Core.Public_Interfaces +{ + public abstract class AbstractCamera + { + public virtual bool MouseDown(MouseEventArgs e, ref Vector3 camTarget, ref float rot, ref float lookup, ref float zoom) { return false; } + public virtual bool MouseMove(MouseEventArgs e, Point lastMouseLoc, float deltaX, float deltaY, ExtraArgs args, ref Vector3 camTarget, ref float rot, ref float lookup, ref float zoom) { return false; } + public virtual bool MouseUp(MouseEventArgs e, Point dragStartMousePos, ref Vector3 camTarget, ref float rot, ref float lookup, ref float zoom) { return false; } + public virtual bool MouseWheel(MouseEventArgs e, float xoff, float yoff, ExtraArgs args, ref Vector3 camTarget, ref float rot, ref float lookup, ref float zoom) { return false; } + public virtual bool MouseClick(MouseEventArgs e, ref Vector3 camTarget, ref float rot, ref float lookup, ref float zoom) { return false; } + + public virtual bool KeyDown(KeyEventArgs e, ref Vector3 camTarget, ref float rot, ref float lookup, ref float zoom) { return false; } + public virtual bool KeyUp(KeyEventArgs e, ref Vector3 camTarget, ref float rot, ref float lookup, ref float zoom) { return false; } + + public virtual bool TimeStep(ref Vector3 camTarget, ref float rot, ref float lookup, ref float zoom) { return false; } + } + + public struct ExtraArgs{ + public float factorX, factorY, pickingDepth; + public ExtraArgs(float factorX, float factorY, float pickingDepth) + { + this.factorX = factorX; + this.factorY = factorY; + this.pickingDepth = pickingDepth; + } + + } +} diff --git a/GL_EditorFramework-master/GL_Core/Public Interfaces/AbstractGlDrawable.cs b/GL_EditorFramework-master/GL_Core/Public Interfaces/AbstractGlDrawable.cs new file mode 100644 index 00000000..fb0011a0 --- /dev/null +++ b/GL_EditorFramework-master/GL_Core/Public Interfaces/AbstractGlDrawable.cs @@ -0,0 +1,34 @@ +using GL_Core.Public_Interfaces; +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace GL_Core.Interfaces +{ + public abstract class AbstractGlDrawable + { + public abstract void Prepare(GL_ControlModern control); + public abstract void Prepare(GL_ControlLegacy control); + public abstract void Draw(GL_ControlModern control); + public abstract void Draw(GL_ControlLegacy control); + public virtual void DrawPicking(GL_ControlModern control) { } + public virtual void DrawPicking(GL_ControlLegacy control) { } + public virtual bool Picked(uint index) { return false; }//handling for Picking + public virtual uint GetPickableSpan() => 0;//tells how many pickable subobjects are in this object + + public virtual bool MouseDown(MouseEventArgs e) { return false; } + public virtual bool MouseMove(MouseEventArgs e, Point lastMouseLoc, float deltaX, float deltaY, ExtraArgs args, float rot, float lookup) { return false; } + public virtual bool MouseUp(MouseEventArgs e, Point dragStartMousePos) { return false; } + public virtual bool MouseWheel(MouseEventArgs e, float xoff, float yoff, ExtraArgs args, float rot, float lookup) { return false; } + public virtual bool MouseClick(MouseEventArgs e) { return false; } + + public virtual bool KeyDown(KeyEventArgs e) { return false; } + public virtual bool KeyUp(KeyEventArgs e) { return false; } + + public virtual bool TimeStep() { return false; } + } +} diff --git a/GL_EditorFramework-master/GL_Core/ShaderClass.cs b/GL_EditorFramework-master/GL_Core/ShaderClass.cs new file mode 100644 index 00000000..77d86b29 --- /dev/null +++ b/GL_EditorFramework-master/GL_Core/ShaderClass.cs @@ -0,0 +1,138 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using OpenTK; +using OpenTK.Graphics.OpenGL; + +namespace GL_Core +{ + public class ShaderProgram + { + private int fragSh, vertSh, program, mtxMdlLoc, mtxCamLoc; + private Matrix4 modelMatrix; + private Matrix4 computedCamMtx; + + public ShaderProgram(FragmentShader frag, VertexShader vert) + { + fragSh = frag.shader; + vertSh = vert.shader; + program = GL.CreateProgram(); + GL.AttachShader(program, vertSh); + GL.AttachShader(program, fragSh); + GL.LinkProgram(program); + Console.WriteLine("fragment:"); + Console.WriteLine(GL.GetShaderInfoLog(fragSh)); + Console.WriteLine("vertex:"); + Console.WriteLine(GL.GetShaderInfoLog(fragSh)); + + mtxMdlLoc = GL.GetUniformLocation(program, "mtxMdl"); + mtxCamLoc = GL.GetUniformLocation(program, "mtxCam"); + } + + public void AttachShader(ShaderGL shader) + { + GL.AttachShader(program, shader.shader); + } + + public void DetachShader(ShaderGL shader) + { + GL.DetachShader(program, shader.shader); + } + + public void LinkShaders() + { + GL.LinkProgram(program); + } + + public void SetFragmentShader(FragmentShader shader) + { + GL.DetachShader(program, fragSh); + GL.AttachShader(program, shader.shader); + fragSh = shader.shader; + GL.LinkProgram(program); + } + + public void SetVertexShader(VertexShader shader) + { + GL.DetachShader(program, vertSh); + GL.AttachShader(program, shader.shader); + vertSh = shader.shader; + GL.LinkProgram(program); + + mtxMdlLoc = GL.GetUniformLocation(program, "mtxMdl"); + mtxCamLoc = GL.GetUniformLocation(program, "mtxCam"); + + GL.UniformMatrix4(mtxMdlLoc, false, ref modelMatrix); + GL.UniformMatrix4(mtxCamLoc, false, ref computedCamMtx); + } + + + public void Setup(Matrix4 mtxMdl, Matrix4 mtxCam, Matrix4 mtxProj) + { + GL.UseProgram(program); + modelMatrix = mtxMdl; + GL.UniformMatrix4(mtxMdlLoc, false, ref modelMatrix); + computedCamMtx = mtxCam * mtxProj; + GL.UniformMatrix4(mtxCamLoc, false, ref computedCamMtx); + } + + public void UpdateModelMatrix(Matrix4 matrix) + { + modelMatrix = matrix; + GL.UniformMatrix4(mtxMdlLoc, false, ref matrix); + } + + public void Activate() + { + GL.UseProgram(program); + } + + public int this[string name]{ + get => GL.GetUniformLocation(program, name); + } + } + + public class ShaderGL + { + public ShaderGL(string src, ShaderType type) + { + shader = GL.CreateShader(type); + GL.ShaderSource(shader, src); + GL.CompileShader(shader); + this.type = type; + } + + public ShaderType type; + + public int shader; + } + + public class FragmentShader : ShaderGL + { + public FragmentShader(string src) + :base(src, ShaderType.FragmentShader) + { + + } + } + + public class GeomeryShader : ShaderGL + { + public GeomeryShader(string src) + : base(src, ShaderType.GeometryShader) + { + + } + } + + public class VertexShader : ShaderGL + { + public VertexShader(string src) + : base(src, ShaderType.VertexShader) + { + + } + } +} diff --git a/GL_EditorFramework-master/GL_Core/packages.config b/GL_EditorFramework-master/GL_Core/packages.config new file mode 100644 index 00000000..c96d3c76 --- /dev/null +++ b/GL_EditorFramework-master/GL_Core/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/GL_EditorFramework-master/GL_EditorFramework.sln b/GL_EditorFramework-master/GL_EditorFramework.sln new file mode 100644 index 00000000..76e2136b --- /dev/null +++ b/GL_EditorFramework-master/GL_EditorFramework.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.27703.2035 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GL_Core", "GL_Core\GL_Core.csproj", "{29647BA5-2859-46F0-A99E-C3A387A9447A}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Testing", "Testing\Testing.csproj", "{47680B79-3772-4339-8808-A97F84450CCE}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {29647BA5-2859-46F0-A99E-C3A387A9447A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {29647BA5-2859-46F0-A99E-C3A387A9447A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {29647BA5-2859-46F0-A99E-C3A387A9447A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {29647BA5-2859-46F0-A99E-C3A387A9447A}.Release|Any CPU.Build.0 = Release|Any CPU + {47680B79-3772-4339-8808-A97F84450CCE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {47680B79-3772-4339-8808-A97F84450CCE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {47680B79-3772-4339-8808-A97F84450CCE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {47680B79-3772-4339-8808-A97F84450CCE}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {F399969A-9DEC-48B3-A7FA-4DBC9341DAA6} + EndGlobalSection +EndGlobal diff --git a/GL_EditorFramework-master/README.md b/GL_EditorFramework-master/README.md new file mode 100644 index 00000000..9a7d81f9 --- /dev/null +++ b/GL_EditorFramework-master/README.md @@ -0,0 +1 @@ +# GL_EditorFramework diff --git a/GL_EditorFramework-master/Testing/App.config b/GL_EditorFramework-master/Testing/App.config new file mode 100644 index 00000000..731f6de6 --- /dev/null +++ b/GL_EditorFramework-master/Testing/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/GL_EditorFramework-master/Testing/MarioTposeTest.cs b/GL_EditorFramework-master/Testing/MarioTposeTest.cs new file mode 100644 index 00000000..ad818536 --- /dev/null +++ b/GL_EditorFramework-master/Testing/MarioTposeTest.cs @@ -0,0 +1,431 @@ +using GL_Core; +using GL_Core.Interfaces; +using OpenTK; +using OpenTK.Graphics; +using OpenTK.Graphics.OpenGL; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace Testing +{ + public class MarioTposeTest : AbstractGlDrawable + { + int testVao; + int marioTestVao; + ShaderProgram defaultShaderProgram; + FragmentShader defaultFrag; + VertexShader defaultVert, pickingVert; + ShaderProgram testShaderProgram; + + uint pickedIndex = 0; + uint selectedIndex = 0; + + public MarioTposeTest() + { + + } + + public override void Draw(GL_ControlModern control) + { + control.CurrentShader = testShaderProgram; + control.ResetModelMatrix(); + GL.BindVertexArray(testVao); + GL.DrawArrays(PrimitiveType.Quads, 0, 4); + + GL.BindVertexArray(marioTestVao); + + control.CurrentShader = defaultShaderProgram; + defaultShaderProgram.SetVertexShader(defaultVert); + control.ApplyModelTransform(Matrix4.CreateTranslation(-8, 0, 0)); + + for (int i = 0; i < 5; i++) + { + if (i + 1 == selectedIndex) + GL.Uniform4(defaultShaderProgram["highlightColor"], 1f, 1f, 0.2f, 0.5f); + else if (i + 1 == pickedIndex) + GL.Uniform4(defaultShaderProgram["highlightColor"], 1f, 1f, 0.5f, 0.2f); + else + GL.Uniform4(defaultShaderProgram["highlightColor"], 0f, 0f, 0f, 0f); + GL.DrawArrays(PrimitiveType.Quads, 0, 11 * 4); + + control.ApplyModelTransform(Matrix4.CreateTranslation(4, 0, 0)); + } + } + + public override void Draw(GL_ControlLegacy control) + { + control.ResetModelMatrix(); + GL.Begin(PrimitiveType.Quads); + GL.Color3(1f, 0f, 0f); + GL.Vertex3(-10f, -0.25f, 5f); + + GL.Color3(0f, 1f, 0f); + GL.Vertex3(10f, -0.25f, 5f); + + GL.Color3(1f, 1f, 0f); + GL.Vertex3(10f, -0.25f, -5f); + + GL.Color3(0f, 0f, 1f); + GL.Vertex3(-10f, -0.25f, -5f); + GL.End(); + + control.ApplyModelTransform(Matrix4.CreateTranslation(-8, 0, 0)); + + for (int i = 0; i < 5; i++) + { + GL.Begin(PrimitiveType.Quads); + if(i+1==pickedIndex) + GL.Color3(0f, 1f, 0f); + else + GL.Color3(1f, 0f, 0f); + GL.Vertex3(-0.5f, 2f, 0f); + GL.Vertex3(0.5f, 2f, 0f); + GL.Vertex3(0.5f, 1.25f, 0f); + GL.Vertex3(-0.5f, 1.25f, 0f); + + GL.Vertex3(-1.5f, 2.5f, 0f); + GL.Vertex3(1.5f, 2.5f, 0f); + GL.Vertex3(1.5f, 2f, 0f); + GL.Vertex3(-1.5f, 2f, 0f); + + //trowsers + if (i + 1 == selectedIndex) + GL.Color3(1f, 1f, 1f); + else + GL.Color3(0, 0.2f, 1f); + GL.Vertex3(-0.5f, 1.25f, 0f); + GL.Vertex3(0.5f, 1.25f, 0f); + GL.Vertex3(0.5f, 0.75f, 0f); + GL.Vertex3(-0.5f, 0.75f, 0f); + + GL.Vertex3(-0.5f, 0.75f, 0f); + GL.Vertex3(-0.125f, 0.75f, 0f); + GL.Vertex3(-0.125f, -0.25f, 0f); + GL.Vertex3(-0.5f, -0.25f, 0f); + + GL.Vertex3(0.125f, 0.75f, 0f); + GL.Vertex3(0.5f, 0.75f, 0f); + GL.Vertex3(0.5f, -0.25f, 0f); + GL.Vertex3(0.125f, -0.25f, 0f); + + //stripes + GL.Vertex3(-0.375f, 2.5f, -0.02f); + GL.Vertex3(-0.125f, 2.5f, -0.02f); + GL.Vertex3(-0.125f, 1.25f, -0.02f); + GL.Vertex3(-0.375f, 1.25f, -0.02f); + + GL.Vertex3(0.125f, 2.5f, -0.02f); + GL.Vertex3(0.375f, 2.5f, -0.02f); + GL.Vertex3(0.375f, 1.25f, -0.02f); + GL.Vertex3(0.125f, 1.25f, -0.02f); + + GL.Vertex3(-0.375f, 2.5f, 0.02f); + GL.Vertex3(-0.125f, 2.5f, 0.02f); + GL.Vertex3(-0.125f, 1.25f, 0.02f); + GL.Vertex3(-0.375f, 1.25f, 0.02f); + + GL.Vertex3(0.125f, 2.5f, 0.02f); + GL.Vertex3(0.375f, 2.5f, 0.02f); + GL.Vertex3(0.375f, 1.25f, 0.02f); + GL.Vertex3(0.125f, 1.25f, 0.02f); + + //knobs + GL.Color3(1f, 1f, 0f); + GL.Vertex3(-0.375f, 2.25f, 0.04f); + GL.Vertex3(-0.125f, 2.25f, 0.04f); + GL.Vertex3(-0.125f, 2f, 0.04f); + GL.Vertex3(-0.375f, 2f, 0.04f); + + GL.Vertex3(0.125f, 2.25f, 0.04f); + GL.Vertex3(0.375f, 2.25f, 0.04f); + GL.Vertex3(0.375f, 2f, 0.04f); + GL.Vertex3(0.125f, 2f, 0.04f); + GL.End(); + + control.ApplyModelTransform(Matrix4.CreateTranslation(4, 0, 0)); + } + } + + public override void Prepare(GL_ControlModern control) + { + defaultFrag = new FragmentShader( + @"#version 330 + in vec4 fragColor; + void main(){ + gl_FragColor = fragColor; + }"); + defaultVert = new VertexShader( + @"#version 330 + layout(location = 0) in vec4 position; + layout(location = 1) in vec4 color; + uniform mat4 mtxMdl; + uniform mat4 mtxCam; + uniform vec4 highlightColor; + out vec4 fragColor; + void main(){ + gl_Position = mtxCam*mtxMdl*position; + fragColor = color+highlightColor.xyz*highlightColor.w; + }"); + pickingVert = new VertexShader( + @"#version 330 + layout(location = 0) in vec4 position; + uniform vec4 color; + uniform mat4 mtxMdl; + uniform mat4 mtxCam; + out vec4 fragColor; + void main(){ + gl_Position = mtxCam*mtxMdl*position; + fragColor = color; + }"); + defaultShaderProgram = new ShaderProgram( + defaultFrag,defaultVert + ); + + testShaderProgram = new ShaderProgram( + new FragmentShader( + @"#version 330 + in vec4 vertPosition; + in vec4 fragColor; + void main(){ + float v = round(abs(mod(vertPosition.x,2.0)-1.0)+ + abs(mod(vertPosition.z,2.0)-1.0)); + gl_FragColor = fragColor*v; + }"), + new VertexShader( + @"#version 330 + layout(location = 0) in vec4 position; + layout(location = 1) in vec4 color; + uniform mat4 mtxMdl; + uniform mat4 mtxCam; + out vec4 vertPosition; + out vec4 fragColor; + void main(){ + gl_Position = mtxMdl*mtxCam*position; + vertPosition = position; + fragColor = color; + }")); + + control.CurrentShader = defaultShaderProgram; + + int buffer; + + GL.BindVertexArray(testVao = GL.GenVertexArray()); + + GL.BindBuffer(BufferTarget.ArrayBuffer, buffer = GL.GenBuffer()); + float[] data = new float[] { + -10f, -0.25f, 5f, 1f, 0f, 0f, 1f, + 10f, -0.25f, 5f, 0f, 1f, 0f, 1f, + 10f, -0.25f, -5f, 1f, 1f, 0f, 1f, + -10f, -0.25f, -5f, 0f, 0f, 1f, 1f, + }; + GL.BufferData(BufferTarget.ArrayBuffer, sizeof(float) * data.Length, data, BufferUsageHint.StaticDraw); + + GL.EnableVertexAttribArray(0); + GL.VertexAttribPointer(0, 3, VertexAttribPointerType.Float, false, sizeof(float) * 7, 0); + GL.EnableVertexAttribArray(1); + GL.VertexAttribPointer(1, 4, VertexAttribPointerType.Float, false, sizeof(float) * 7, sizeof(float) * 3); + + GL.BindVertexArray(marioTestVao = GL.GenVertexArray()); + using (OldGlEmulator GL = new OldGlEmulator()) + { + //body + GL.Color3(1f, 0f, 0f); + GL.Vertex3(-0.5f, 2f, 0f); + GL.Vertex3(0.5f, 2f, 0f); + GL.Vertex3(0.5f, 1.25f, 0f); + GL.Vertex3(-0.5f, 1.25f, 0f); + + GL.Vertex3(-1.5f, 2.5f, 0f); + GL.Vertex3(1.5f, 2.5f, 0f); + GL.Vertex3(1.5f, 2f, 0f); + GL.Vertex3(-1.5f, 2f, 0f); + + //trowsers + GL.Color3(0, 0.2f, 1f); + GL.Vertex3(-0.5f, 1.25f, 0f); + GL.Vertex3(0.5f, 1.25f, 0f); + GL.Vertex3(0.5f, 0.75f, 0f); + GL.Vertex3(-0.5f, 0.75f, 0f); + + GL.Vertex3(-0.5f, 0.75f, 0f); + GL.Vertex3(-0.125f, 0.75f, 0f); + GL.Vertex3(-0.125f, -0.25f, 0f); + GL.Vertex3(-0.5f, -0.25f, 0f); + + GL.Vertex3(0.125f, 0.75f, 0f); + GL.Vertex3(0.5f, 0.75f, 0f); + GL.Vertex3(0.5f, -0.25f, 0f); + GL.Vertex3(0.125f, -0.25f, 0f); + + //stripes + GL.Vertex3(-0.375f, 2.5f, -0.02f); + GL.Vertex3(-0.125f, 2.5f, -0.02f); + GL.Vertex3(-0.125f, 1.25f, -0.02f); + GL.Vertex3(-0.375f, 1.25f, -0.02f); + + GL.Vertex3(0.125f, 2.5f, -0.02f); + GL.Vertex3(0.375f, 2.5f, -0.02f); + GL.Vertex3(0.375f, 1.25f, -0.02f); + GL.Vertex3(0.125f, 1.25f, -0.02f); + + GL.Vertex3(-0.375f, 2.5f, 0.02f); + GL.Vertex3(-0.125f, 2.5f, 0.02f); + GL.Vertex3(-0.125f, 1.25f, 0.02f); + GL.Vertex3(-0.375f, 1.25f, 0.02f); + + GL.Vertex3(0.125f, 2.5f, 0.02f); + GL.Vertex3(0.375f, 2.5f, 0.02f); + GL.Vertex3(0.375f, 1.25f, 0.02f); + GL.Vertex3(0.125f, 1.25f, 0.02f); + + //knobs + GL.Color3(1f, 1f, 0f); + GL.Vertex3(-0.375f, 2.25f, 0.04f); + GL.Vertex3(-0.125f, 2.25f, 0.04f); + GL.Vertex3(-0.125f, 2f, 0.04f); + GL.Vertex3(-0.375f, 2f, 0.04f); + + GL.Vertex3(0.125f, 2.25f, 0.04f); + GL.Vertex3(0.375f, 2.25f, 0.04f); + GL.Vertex3(0.375f, 2f, 0.04f); + GL.Vertex3(0.125f, 2f, 0.04f); + + GL.WriteToBuffer(buffer = OpenTK.Graphics.OpenGL.GL.GenBuffer()); + } + } + + public override void Prepare(GL_ControlLegacy control) + { + + } + + public override bool MouseClick(MouseEventArgs e) + { + if (e.Button == MouseButtons.Left) + { + selectedIndex = pickedIndex; + return true; + } + return false; + } + + public override void DrawPicking(GL_ControlModern control) + { + defaultShaderProgram.SetVertexShader(pickingVert); + control.ResetModelMatrix(); + GL.Uniform4(defaultShaderProgram["color"], 0f, 0f, 0f, 0f); + GL.BindVertexArray(testVao); + GL.DrawArrays(PrimitiveType.Quads, 0, 4); + + GL.BindVertexArray(marioTestVao); + + control.ApplyModelTransform(Matrix4.CreateTranslation(-8, 0, 0)); + + for (int i = 0; i < 5; i++) + { + GL.Uniform4(defaultShaderProgram["color"], control.nextPickingColor()); + GL.DrawArrays(PrimitiveType.Quads, 0, 11 * 4); + + control.ApplyModelTransform(Matrix4.CreateTranslation(4, 0, 0)); + } + } + + public override void DrawPicking(GL_ControlLegacy control) + { + control.ResetModelMatrix(); + GL.Begin(PrimitiveType.Quads); + GL.Color4(0,0,0,0); + GL.Vertex3(-10f, -0.25f, 5f); + + GL.Vertex3(10f, -0.25f, 5f); + + GL.Vertex3(10f, -0.25f, -5f); + + GL.Vertex3(-10f, -0.25f, -5f); + GL.End(); + + control.ApplyModelTransform(Matrix4.CreateTranslation(-8, 0, 0)); + + for (int i = 0; i < 5; i++) + { + GL.Begin(PrimitiveType.Quads); + GL.Color4(control.nextPickingColor()); + GL.Vertex3(-0.5f, 2f, 0f); + GL.Vertex3(0.5f, 2f, 0f); + GL.Vertex3(0.5f, 1.25f, 0f); + GL.Vertex3(-0.5f, 1.25f, 0f); + + GL.Vertex3(-1.5f, 2.5f, 0f); + GL.Vertex3(1.5f, 2.5f, 0f); + GL.Vertex3(1.5f, 2f, 0f); + GL.Vertex3(-1.5f, 2f, 0f); + + //trowsers + GL.Vertex3(-0.5f, 1.25f, 0f); + GL.Vertex3(0.5f, 1.25f, 0f); + GL.Vertex3(0.5f, 0.75f, 0f); + GL.Vertex3(-0.5f, 0.75f, 0f); + + GL.Vertex3(-0.5f, 0.75f, 0f); + GL.Vertex3(-0.125f, 0.75f, 0f); + GL.Vertex3(-0.125f, -0.25f, 0f); + GL.Vertex3(-0.5f, -0.25f, 0f); + + GL.Vertex3(0.125f, 0.75f, 0f); + GL.Vertex3(0.5f, 0.75f, 0f); + GL.Vertex3(0.5f, -0.25f, 0f); + GL.Vertex3(0.125f, -0.25f, 0f); + + //stripes + GL.Vertex3(-0.375f, 2.5f, -0.02f); + GL.Vertex3(-0.125f, 2.5f, -0.02f); + GL.Vertex3(-0.125f, 1.25f, -0.02f); + GL.Vertex3(-0.375f, 1.25f, -0.02f); + + GL.Vertex3(0.125f, 2.5f, -0.02f); + GL.Vertex3(0.375f, 2.5f, -0.02f); + GL.Vertex3(0.375f, 1.25f, -0.02f); + GL.Vertex3(0.125f, 1.25f, -0.02f); + + GL.Vertex3(-0.375f, 2.5f, 0.02f); + GL.Vertex3(-0.125f, 2.5f, 0.02f); + GL.Vertex3(-0.125f, 1.25f, 0.02f); + GL.Vertex3(-0.375f, 1.25f, 0.02f); + + GL.Vertex3(0.125f, 2.5f, 0.02f); + GL.Vertex3(0.375f, 2.5f, 0.02f); + GL.Vertex3(0.375f, 1.25f, 0.02f); + GL.Vertex3(0.125f, 1.25f, 0.02f); + + //knobs + GL.Vertex3(-0.375f, 2.25f, 0.04f); + GL.Vertex3(-0.125f, 2.25f, 0.04f); + GL.Vertex3(-0.125f, 2f, 0.04f); + GL.Vertex3(-0.375f, 2f, 0.04f); + + GL.Vertex3(0.125f, 2.25f, 0.04f); + GL.Vertex3(0.375f, 2.25f, 0.04f); + GL.Vertex3(0.375f, 2f, 0.04f); + GL.Vertex3(0.125f, 2f, 0.04f); + GL.End(); + + control.ApplyModelTransform(Matrix4.CreateTranslation(4, 0, 0)); + } + } + + public override bool Picked(uint index) + { + pickedIndex = index; + Console.WriteLine(index); + return true; + } + + public override uint GetPickableSpan(){ + return 5; + } + } +} diff --git a/GL_EditorFramework-master/Testing/Program.cs b/GL_EditorFramework-master/Testing/Program.cs new file mode 100644 index 00000000..a5393954 --- /dev/null +++ b/GL_EditorFramework-master/Testing/Program.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace Testing +{ + static class Program + { + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new TestingForm()); + } + } +} diff --git a/GL_EditorFramework-master/Testing/Properties/AssemblyInfo.cs b/GL_EditorFramework-master/Testing/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..3e1d4450 --- /dev/null +++ b/GL_EditorFramework-master/Testing/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("GL_EditorFramework")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("GL_EditorFramework")] +[assembly: AssemblyCopyright("Copyright © 2018")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("47680b79-3772-4339-8808-a97f84450cce")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/GL_EditorFramework-master/Testing/Properties/Resources.Designer.cs b/GL_EditorFramework-master/Testing/Properties/Resources.Designer.cs new file mode 100644 index 00000000..10aa5c51 --- /dev/null +++ b/GL_EditorFramework-master/Testing/Properties/Resources.Designer.cs @@ -0,0 +1,71 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Testing.Properties +{ + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources + { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() + { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager + { + get + { + if ((resourceMan == null)) + { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("GL_EditorFramework.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture + { + get + { + return resourceCulture; + } + set + { + resourceCulture = value; + } + } + } +} diff --git a/GL_EditorFramework-master/Testing/Properties/Resources.resx b/GL_EditorFramework-master/Testing/Properties/Resources.resx new file mode 100644 index 00000000..af7dbebb --- /dev/null +++ b/GL_EditorFramework-master/Testing/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/GL_EditorFramework-master/Testing/Properties/Settings.Designer.cs b/GL_EditorFramework-master/Testing/Properties/Settings.Designer.cs new file mode 100644 index 00000000..caf79bd0 --- /dev/null +++ b/GL_EditorFramework-master/Testing/Properties/Settings.Designer.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Testing.Properties +{ + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/GL_EditorFramework-master/Testing/Properties/Settings.settings b/GL_EditorFramework-master/Testing/Properties/Settings.settings new file mode 100644 index 00000000..39645652 --- /dev/null +++ b/GL_EditorFramework-master/Testing/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/GL_EditorFramework-master/Testing/TestForm.Designer.cs b/GL_EditorFramework-master/Testing/TestForm.Designer.cs new file mode 100644 index 00000000..610119b9 --- /dev/null +++ b/GL_EditorFramework-master/Testing/TestForm.Designer.cs @@ -0,0 +1,81 @@ +namespace Testing +{ + partial class TestingForm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.gL_ControlModern1 = new GL_Core.GL_ControlModern(); + this.checkBox1 = new System.Windows.Forms.CheckBox(); + this.SuspendLayout(); + // + // gL_ControlModern1 + // + this.gL_ControlModern1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.gL_ControlModern1.BackColor = System.Drawing.Color.Black; + this.gL_ControlModern1.Location = new System.Drawing.Point(0, 35); + this.gL_ControlModern1.MainDrawable = null; + this.gL_ControlModern1.Name = "gL_ControlModern1"; + this.gL_ControlModern1.Size = new System.Drawing.Size(800, 467); + this.gL_ControlModern1.Stereoscopy = false; + this.gL_ControlModern1.TabIndex = 0; + this.gL_ControlModern1.VSync = false; + this.gL_ControlModern1.MouseClick += new System.Windows.Forms.MouseEventHandler(this.gL_ControlModern1_MouseClick); + // + // checkBox1 + // + this.checkBox1.AutoSize = true; + this.checkBox1.Location = new System.Drawing.Point(12, 12); + this.checkBox1.Name = "checkBox1"; + this.checkBox1.Size = new System.Drawing.Size(85, 17); + this.checkBox1.TabIndex = 1; + this.checkBox1.Text = "Stereoscopy"; + this.checkBox1.UseVisualStyleBackColor = true; + this.checkBox1.CheckedChanged += new System.EventHandler(this.checkBox1_CheckedChanged); + // + // TestingForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(800, 501); + this.Controls.Add(this.checkBox1); + this.Controls.Add(this.gL_ControlModern1); + this.Name = "TestingForm"; + this.Text = "Test Window"; + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private GL_Core.GL_ControlModern gL_ControlModern1; + private System.Windows.Forms.CheckBox checkBox1; + } +} + diff --git a/GL_EditorFramework-master/Testing/TestForm.cs b/GL_EditorFramework-master/Testing/TestForm.cs new file mode 100644 index 00000000..dfab666a --- /dev/null +++ b/GL_EditorFramework-master/Testing/TestForm.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using GL_Core; + +namespace Testing +{ + public partial class TestingForm : Form + { + public TestingForm() + { + InitializeComponent(); + } + + private void gL_ControlModern1_MouseClick(object sender, MouseEventArgs e) + { + if(gL_ControlModern1.MainDrawable==null) + gL_ControlModern1.MainDrawable = new MarioTposeTest(); + } + + private void checkBox1_CheckedChanged(object sender, EventArgs e) + { + gL_ControlModern1.Stereoscopy = checkBox1.Checked; + } + } +} diff --git a/GL_EditorFramework-master/Testing/TestForm.resx b/GL_EditorFramework-master/Testing/TestForm.resx new file mode 100644 index 00000000..1af7de15 --- /dev/null +++ b/GL_EditorFramework-master/Testing/TestForm.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/GL_EditorFramework-master/Testing/Testing.csproj b/GL_EditorFramework-master/Testing/Testing.csproj new file mode 100644 index 00000000..153c63bc --- /dev/null +++ b/GL_EditorFramework-master/Testing/Testing.csproj @@ -0,0 +1,95 @@ + + + + + Debug + AnyCPU + {47680B79-3772-4339-8808-A97F84450CCE} + WinExe + GL_EditorFramework + GL_EditorFramework + v4.6.1 + 512 + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\packages\OpenTK.3.0.1\lib\net20\OpenTK.dll + + + ..\packages\OpenTK.GLControl.3.0.1\lib\net20\OpenTK.GLControl.dll + + + + + + + + + + + + + + + + + Form + + + TestForm.cs + + + + + TestForm.cs + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + + + + {29647BA5-2859-46F0-A99E-C3A387A9447A} + GL_Core + + + + \ No newline at end of file