Add GL framwork

This commit is contained in:
KillzXGaming 2018-11-11 20:07:44 -05:00
parent dbb73d165e
commit 70efde9cf1
30 changed files with 2691 additions and 0 deletions

View file

@ -0,0 +1,2 @@
# Auto detect text files and perform LF normalization
* text=auto

330
GL_EditorFramework-master/.gitignore vendored Normal file
View file

@ -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/

View file

@ -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;
}
}
}

View file

@ -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;
}
}
}

View file

@ -0,0 +1,37 @@
namespace GL_Core
{
partial class GL_ControlLegacy
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
components = new System.ComponentModel.Container();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
}
#endregion
}
}

View file

@ -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();
}
}
}

View file

@ -0,0 +1,37 @@
namespace GL_Core
{
partial class GL_ControlModern
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
components = new System.ComponentModel.Container();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
}
#endregion
}
}

View file

@ -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<AbstractGlDrawable> abstractGlDrawables = new List<AbstractGlDrawable>();
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();
}
}
}

View file

@ -0,0 +1,77 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{29647BA5-2859-46F0-A99E-C3A387A9447A}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>GL_Core</RootNamespace>
<AssemblyName>GL_Core</AssemblyName>
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="OpenTK, Version=3.0.1.0, Culture=neutral, PublicKeyToken=bad199fe84eb3df4, processorArchitecture=MSIL">
<HintPath>..\..\..\..\..\Documents\Visual Studio 2017\Projects\WindowsFormsApp2\WindowsFormsApp2\Lib\OpenTK.dll</HintPath>
</Reference>
<Reference Include="OpenTK.GLControl, Version=3.0.1.0, Culture=neutral, PublicKeyToken=bad199fe84eb3df4, processorArchitecture=MSIL">
<HintPath>..\..\..\..\..\Documents\Visual Studio 2017\Projects\WindowsFormsApp2\WindowsFormsApp2\Lib\OpenTK.GLControl.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Cameras\Inspect.cs" />
<Compile Include="Cameras\Walkaround.cs" />
<Compile Include="GL_ControlLegacy.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="GL_ControlLegacy.Designer.cs">
<DependentUpon>GL_ControlLegacy.cs</DependentUpon>
</Compile>
<Compile Include="GL_ControlModern.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="GL_ControlModern.Designer.cs">
<DependentUpon>GL_ControlModern.cs</DependentUpon>
</Compile>
<Compile Include="Public Interfaces\AbstractCamera.cs" />
<Compile Include="Public Interfaces\AbstractGlDrawable.cs" />
<Compile Include="OldGlEmulator.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ShaderClass.cs" />
</ItemGroup>
<ItemGroup>
<None Include="OpenTK.dll.config" />
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View file

@ -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<float> dataList = new List<float>();
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()
{
}
}
}

View file

@ -0,0 +1,25 @@
<configuration>
<dllmap os="linux" dll="opengl32.dll" target="libGL.so.1"/>
<dllmap os="linux" dll="glu32.dll" target="libGLU.so.1"/>
<dllmap os="linux" dll="openal32.dll" target="libopenal.so.1"/>
<dllmap os="linux" dll="alut.dll" target="libalut.so.0"/>
<dllmap os="linux" dll="opencl.dll" target="libOpenCL.so"/>
<dllmap os="linux" dll="libX11" target="libX11.so.6"/>
<dllmap os="linux" dll="libXi" target="libXi.so.6"/>
<dllmap os="linux" dll="SDL2.dll" target="libSDL2-2.0.so.0"/>
<dllmap os="osx" dll="opengl32.dll" target="/System/Library/Frameworks/OpenGL.framework/OpenGL"/>
<dllmap os="osx" dll="openal32.dll" target="/System/Library/Frameworks/OpenAL.framework/OpenAL" />
<dllmap os="osx" dll="alut.dll" target="/System/Library/Frameworks/OpenAL.framework/OpenAL" />
<dllmap os="osx" dll="libGLES.dll" target="/System/Library/Frameworks/OpenGLES.framework/OpenGLES" />
<dllmap os="osx" dll="libGLESv1_CM.dll" target="/System/Library/Frameworks/OpenGLES.framework/OpenGLES" />
<dllmap os="osx" dll="libGLESv2.dll" target="/System/Library/Frameworks/OpenGLES.framework/OpenGLES" />
<dllmap os="osx" dll="opencl.dll" target="/System/Library/Frameworks/OpenCL.framework/OpenCL"/>
<dllmap os="osx" dll="SDL2.dll" target="libSDL2.dylib"/>
<!-- XQuartz compatibility (X11 on Mac) -->
<dllmap os="osx" dll="libGL.so.1" target="/usr/X11/lib/libGL.dylib"/>
<dllmap os="osx" dll="libX11" target="/usr/X11/lib/libX11.dylib"/>
<dllmap os="osx" dll="libXcursor.so.1" target="/usr/X11/lib/libXcursor.dylib"/>
<dllmap os="osx" dll="libXi" target="/usr/X11/lib/libXi.dylib"/>
<dllmap os="osx" dll="libXinerama" target="/usr/X11/lib/libXinerama.dylib"/>
<dllmap os="osx" dll="libXrandr.so.2" target="/usr/X11/lib/libXrandr.dylib"/>
</configuration>

View file

@ -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")]

View file

@ -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;
}
}
}

View file

@ -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; }
}
}

View file

@ -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)
{
}
}
}

View file

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="OpenTK" version="3.0.1" targetFramework="net461" />
<package id="OpenTK.GLControl" version="3.0.1" targetFramework="net461" />
</packages>

View file

@ -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

View file

@ -0,0 +1 @@
# GL_EditorFramework

View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
</configuration>

View file

@ -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;
}
}
}

View file

@ -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
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new TestingForm());
}
}
}

View file

@ -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")]

View file

@ -0,0 +1,71 @@
//------------------------------------------------------------------------------
// <auto-generated>
// 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.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Testing.Properties
{
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// 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()
{
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[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;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture
{
get
{
return resourceCulture;
}
set
{
resourceCulture = value;
}
}
}
}

View file

@ -0,0 +1,117 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View file

@ -0,0 +1,30 @@
//------------------------------------------------------------------------------
// <auto-generated>
// 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.
// </auto-generated>
//------------------------------------------------------------------------------
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;
}
}
}
}

View file

@ -0,0 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>

View file

@ -0,0 +1,81 @@
namespace Testing
{
partial class TestingForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
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;
}
}

View file

@ -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;
}
}
}

View file

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View file

@ -0,0 +1,95 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{47680B79-3772-4339-8808-A97F84450CCE}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>GL_EditorFramework</RootNamespace>
<AssemblyName>GL_EditorFramework</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="OpenTK">
<HintPath>..\packages\OpenTK.3.0.1\lib\net20\OpenTK.dll</HintPath>
</Reference>
<Reference Include="OpenTK.GLControl">
<HintPath>..\packages\OpenTK.GLControl.3.0.1\lib\net20\OpenTK.GLControl.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="MarioTposeTest.cs" />
<Compile Include="TestForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="TestForm.Designer.cs">
<DependentUpon>TestForm.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="TestForm.resx">
<DependentUpon>TestForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\GL_Core\GL_Core.csproj">
<Project>{29647BA5-2859-46F0-A99E-C3A387A9447A}</Project>
<Name>GL_Core</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>