diff --git a/2DGAMELIB/2DGAMELIB.csproj b/2DGAMELIB/2DGAMELIB.csproj
index 23a42cb..e9af2bc 100644
--- a/2DGAMELIB/2DGAMELIB.csproj
+++ b/2DGAMELIB/2DGAMELIB.csproj
@@ -4,8 +4,9 @@
2DGAMELIB
False
True
- net45
+ net462
x86
+ AnyCPU
10.0
@@ -15,7 +16,9 @@
+
+
diff --git a/2DGAMELIB/_2DGAMELIB/Med.cs b/2DGAMELIB/_2DGAMELIB/Med.cs
index 84d990d..85b84c5 100644
--- a/2DGAMELIB/_2DGAMELIB/Med.cs
+++ b/2DGAMELIB/_2DGAMELIB/Med.cs
@@ -1,7 +1,9 @@
+using GLFW;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
+using System.Net.Http.Headers;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using System.Windows.Input;
@@ -164,69 +166,135 @@ public class Med
Clear();
Sce = new Sce(BaseSize.Width, BaseSize.Height);
Modes = GetModes(this);
- BaseControl.Image.MouseDown += delegate(object s, MouseButtonEventArgs e)
+
+
+ BaseControl.Image.MouseDown += delegate(object s, System.Windows.Input.MouseButtonEventArgs e)
{
Point Position5 = baseControl.PointToClient(System.Windows.Forms.Cursor.Position);
MouseButtons arg2 = MouseButtons.None;
switch (e.ChangedButton)
{
- case MouseButton.Left:
+ case System.Windows.Input.MouseButton.Left:
arg2 = MouseButtons.Left;
break;
- case MouseButton.Middle:
+ case System.Windows.Input.MouseButton.Middle:
arg2 = MouseButtons.Middle;
break;
- case MouseButton.Right:
+ case System.Windows.Input.MouseButton.Right:
arg2 = MouseButtons.Right;
break;
- case MouseButton.XButton1:
+ case System.Windows.Input.MouseButton.XButton1:
arg2 = MouseButtons.XButton1;
break;
- case MouseButton.XButton2:
+ case System.Windows.Input.MouseButton.XButton2:
arg2 = MouseButtons.XButton2;
break;
}
Modes[mode].Down(arg2, ToBasePosition(Position5), GetHitColor(ref Position5));
};
- BaseControl.Image.MouseUp += delegate(object s, MouseButtonEventArgs e)
+
+ BaseControl.Image.MouseUp += delegate(object s, System.Windows.Input.MouseButtonEventArgs e)
{
Point Position4 = baseControl.PointToClient(System.Windows.Forms.Cursor.Position);
MouseButtons arg = MouseButtons.None;
switch (e.ChangedButton)
{
- case MouseButton.Left:
+ case System.Windows.Input.MouseButton.Left:
arg = MouseButtons.Left;
break;
- case MouseButton.Middle:
+ case System.Windows.Input.MouseButton.Middle:
arg = MouseButtons.Middle;
break;
- case MouseButton.Right:
+ case System.Windows.Input.MouseButton.Right:
arg = MouseButtons.Right;
break;
- case MouseButton.XButton1:
+ case System.Windows.Input.MouseButton.XButton1:
arg = MouseButtons.XButton1;
break;
- case MouseButton.XButton2:
+ case System.Windows.Input.MouseButton.XButton2:
arg = MouseButtons.XButton2;
break;
}
Modes[mode].Up(arg, ToBasePosition(Position4), GetHitColor(ref Position4));
};
- BaseControl.Image.MouseMove += delegate
+
+
+ BaseControl.gl_img.Click = delegate (IntPtr window, GLFW.MouseButton button, InputState state, GLFW.ModifierKeys modifiers)
+ {
+ double x, y;
+ Glfw.GetCursorPosition(GlImage.PtrToWindow(window), out x, out y);
+ Point Position5 = new Point((int)x, (int)y);
+ MouseButtons arg2 = MouseButtons.None;
+ switch (button)
+ {
+ case GLFW.MouseButton.Left:
+ arg2 = MouseButtons.Left;
+ break;
+ case GLFW.MouseButton.Middle:
+ arg2 = MouseButtons.Middle;
+ break;
+ case GLFW.MouseButton.Right:
+ arg2 = MouseButtons.Right;
+ break;
+ case GLFW.MouseButton.Button4:
+ arg2 = MouseButtons.XButton1;
+ break;
+ case GLFW.MouseButton.Button5:
+ arg2 = MouseButtons.XButton2;
+ break;
+ }
+
+
+ (state == InputState.Press ? Modes[mode].Down : Modes[mode].Up)(arg2, ToBasePosition(Position5), GetHitColor(ref Position5));
+ };
+
+
+ BaseControl.Image.MouseMove += delegate
{
Point Position3 = baseControl.PointToClient(System.Windows.Forms.Cursor.Position);
Modes[mode].Move(Control.MouseButtons, ToBasePosition(Position3), GetHitColor(ref Position3));
};
+
+ BaseControl.gl_img.Move = delegate (IntPtr window, double x, double y)
+ {
+ Point Position3 = new Point((int)x, (int)y);
+ Modes[mode].Move(Control.MouseButtons, ToBasePosition(Position3), GetHitColor(ref Position3));
+ };
+
+
BaseControl.Image.MouseLeave += delegate
{
Point Position2 = baseControl.PointToClient(System.Windows.Forms.Cursor.Position);
Modes[mode].Leave(Control.MouseButtons, ToBasePosition(Position2), GetHitColor(ref Position2));
};
+
+ BaseControl.gl_img.Leave = delegate (IntPtr window, bool entered)
+ {
+ if (!entered)
+ {
+ double x, y;
+ Glfw.GetCursorPosition(GlImage.PtrToWindow(window), out x, out y);
+ Point Position2 = new Point((int)x, (int)y);
+ Modes[mode].Leave(Control.MouseButtons, ToBasePosition(Position2), GetHitColor(ref Position2));
+ }
+ };
+
BaseControl.Image.MouseWheel += delegate(object s, MouseWheelEventArgs e)
{
Point Position = baseControl.PointToClient(System.Windows.Forms.Cursor.Position);
Modes[mode].Wheel(Control.MouseButtons, ToBasePosition(Position), e.Delta, GetHitColor(ref Position));
};
+
+ BaseControl.gl_img.Scroll = delegate (IntPtr window, double xo, double yo)
+ {
+ double x, y;
+ Glfw.GetCursorPosition(GlImage.PtrToWindow(window), out x, out y);
+ Point Position = new Point((int)x, (int)y);
+ //Note: yo may be inverted
+ Modes[mode].Wheel(Control.MouseButtons, ToBasePosition(Position), (int)yo, GetHitColor(ref Position));
+ };
+
+
((Control)BaseControl).Resize += delegate
{
if (BaseSize.Width >= BaseSize.Height)
@@ -262,6 +330,44 @@ public class Med
}
}
};
+
+ BaseControl.gl_img.Resize = delegate (IntPtr window, int width, int height)
+ {
+ //TODO mess with viewport
+ if (BaseSize.Width >= BaseSize.Height)
+ {
+ double num = (double)BaseSize.Width / (double)BaseSize.Height;
+ if ((double)width / (double)height <= num)
+ {
+ resMag = (double)BaseSize.Width / (double)width;
+ resVector.X = 0.0;
+ resVector.Y = ((double)height - (double)BaseSize.Height / resMag) * 0.5;
+ }
+ else
+ {
+ resMag = (double)BaseSize.Height / (double)height;
+ resVector.X = ((double)width - (double)BaseSize.Width / resMag) * 0.5;
+ resVector.Y = 0.0;
+ }
+ }
+ else
+ {
+ double num2 = (double)BaseSize.Height / (double)BaseSize.Width;
+ if ((double)height / (double)width <= num2)
+ {
+ resMag = (double)BaseSize.Height / (double)height;
+ resVector.X = ((double)width - (double)BaseSize.Width / resMag) * 0.5;
+ resVector.Y = 0.0;
+ }
+ else
+ {
+ resMag = (double)BaseSize.Width / (double)width;
+ resVector.X = 0.0;
+ resVector.Y = ((double)height - (double)BaseSize.Height / resMag) * 0.5;
+ }
+ }
+ };
+
return BaseSize;
}
@@ -352,6 +458,7 @@ public class Med
baseControl.Parent.Text = UITitle + " - FPS: " + System.Math.Round(FPSF.Value, 2);
}
Application.DoEvents();
+ baseControl.PollEvents();
long frame_update_end = FPSF.sw.ElapsedMilliseconds;
diff --git a/2DGAMELIB/_2DGAMELIB/UI.cs b/2DGAMELIB/_2DGAMELIB/UI.cs
index fd0a5b0..5c3c2a3 100644
--- a/2DGAMELIB/_2DGAMELIB/UI.cs
+++ b/2DGAMELIB/_2DGAMELIB/UI.cs
@@ -10,9 +10,6 @@ namespace _2DGAMELIB;
public class UI : Form
{
-
- private Point Position = Point.Empty;
-
private Med Med;
private IContainer components;
@@ -56,11 +53,6 @@ public class UI : Form
base.ClientSize = new Size(1280, 960);
}
UI_Resize(null, null);
- if (Position == Point.Empty)
- {
- Position = (Screen.PrimaryScreen.Bounds.Size.ToVector2D() * 0.5 - base.Size.ToVector2D() * 0.5).ToPoint();
- }
- base.Location = Position;
}
private void UI_FormClosing(object sender, FormClosingEventArgs e)
@@ -68,11 +60,6 @@ public class UI : Form
Med.Drive = false;
}
- private void UI_Move(object sender, EventArgs e)
- {
- Position = base.Location;
- }
-
private void UI_Resize(object sender, EventArgs e)
{
wpfImage1.ImageSetting();
@@ -115,8 +102,11 @@ public class UI : Form
base.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
base.FormClosing += new System.Windows.Forms.FormClosingEventHandler(UI_FormClosing);
+
+ //beauty
+ this.wpfImage1.gl_img.Closing = delegate () { UI_FormClosing(null, null); };
+
base.Load += new System.EventHandler(UI_Load);
- base.Move += new System.EventHandler(UI_Move);
base.Resize += new System.EventHandler(UI_Resize);
base.ResumeLayout(false);
}
diff --git a/2DGAMELIB/_2DGAMELIB/WPFImage.cs b/2DGAMELIB/_2DGAMELIB/WPFImage.cs
index 1677439..10eb3e7 100644
--- a/2DGAMELIB/_2DGAMELIB/WPFImage.cs
+++ b/2DGAMELIB/_2DGAMELIB/WPFImage.cs
@@ -1,9 +1,12 @@
+using GLFW;
+using OpenGL;
using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
+using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Forms.Integration;
@@ -12,9 +15,188 @@ using System.Windows.Media.Imaging;
namespace _2DGAMELIB;
+public class GlImage
+{
+
+ //yeah this is a little bit sketchy
+ public static unsafe GLFW.Window PtrToWindow(IntPtr source)
+ {
+ var sourceRef = __makeref(source);
+ var dest = default(GLFW.Window);
+ var destRef = __makeref(dest);
+ *(IntPtr*)&destRef = *(IntPtr*)&sourceRef;
+ return __refvalue(destRef, GLFW.Window);
+ }
+
+ private GLFW.Window window;
+ uint shader_program;
+ uint texture;
+ uint vertex_buf;
+ uint vao;
+
+
+ public GlImage() { }
+
+ public void ImageSetting() { }
+
+ public delegate void ShouldCloseCallback();
+
+ public ShouldCloseCallback Closing = delegate () { };
+ public MouseButtonCallback Click = delegate (IntPtr window, MouseButton button, InputState state, ModifierKeys modifiers) { };
+ public MouseCallback Move = delegate (IntPtr window, double x, double y) { };
+ public SizeCallback Resize = delegate (IntPtr window, int width, int height) { };
+ public MouseCallback Scroll = delegate (IntPtr window, double x, double y) { };
+ public MouseEnterCallback Leave = delegate (IntPtr window, bool entered) { };
+
+ public void PollEvents() {
+ Glfw.PollEvents();
+ if (Glfw.WindowShouldClose(window))
+ Closing();
+ }
+ public void SetBitmap(Bitmap bmp)
+ {
+ Gl.UseProgram(shader_program);
+ Gl.Viewport(0, 0, bmp.Width, bmp.Height);
+
+ Gl.ActiveTexture(TextureUnit.Texture0);
+ Gl.BindTexture(TextureTarget.Texture2d, texture);
+
+ BitmapData data = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
+ Gl.TexImage2D(TextureTarget.Texture2d, 0, InternalFormat.Rgba8, bmp.Width, bmp.Height, 0, OpenGL.PixelFormat.Bgra, PixelType.UnsignedByte, data.Scan0);
+ bmp.UnlockBits(data);
+
+ int res_pos = Gl.GetUniformLocation(shader_program, "res");
+ Gl.Uniform2(res_pos, (float)bmp.Width, (float)bmp.Height);
+
+ Gl.BindBuffer(BufferTarget.ArrayBuffer, vertex_buf);
+ uint vert_pos = (uint)Gl.GetAttribLocation(shader_program, "vertPos");
+ Gl.EnableVertexAttribArray(vert_pos);
+
+ Gl.BindVertexArray(vao);
+ Gl.VertexAttribPointer(
+ vert_pos,
+ 2,
+ VertexAttribType.Float,
+ false,
+ 0,
+ IntPtr.Zero
+ );
+
+ Gl.DrawArrays(PrimitiveType.TriangleStrip, 0, 4);
+ Glfw.SwapBuffers(window);
+ }
+
+ public void BitmapSetting(Bitmap bmp)
+ {
+ Glfw.WindowHint(Hint.ClientApi, ClientApi.OpenGL);
+ Glfw.WindowHint(Hint.ContextVersionMajor, 3);
+ Glfw.WindowHint(Hint.ContextVersionMinor, 3);
+ Glfw.WindowHint(Hint.OpenglProfile, Profile.Core);
+ Glfw.WindowHint(Hint.Doublebuffer, true);
+ Glfw.WindowHint(Hint.Decorated, true);
+ Glfw.WindowHint(Hint.OpenglForwardCompatible, true);
+
+ window = Glfw.CreateWindow(bmp.Width, bmp.Height, "yayy", Monitor.None, GLFW.Window.None);
+
+ Glfw.SetWindowSizeCallback(window, Resize);
+ Glfw.SetMouseButtonCallback(window, Click);
+ Glfw.SetCursorPositionCallback(window, Move);
+ Glfw.SetScrollCallback(window, Scroll);
+ Glfw.SetCursorEnterCallback(window, Leave);
+
+ GCHandle handle = GCHandle.Alloc(this);
+ Glfw.SetWindowUserPointer(window, GCHandle.ToIntPtr(handle));
+
+ Gl.Initialize();
+ Glfw.MakeContextCurrent(window);
+
+
+ string[] vertexShaderSource = {
+@"
+#version 100
+precision mediump float;
+
+attribute vec2 vertPos;
+
+void main()
+{
+ gl_Position = vec4(vertPos, 0.0, 1.0);
+}
+"
+ };
+
+ string[] fragmentShaderSource = {
+@"
+#version 100
+precision mediump float;
+
+uniform sampler2D sTexture;
+uniform vec2 res;
+
+void main()
+{
+ vec2 tc = gl_FragCoord.xy / res;
+ tc.y = 1.0 - tc.y;
+
+ gl_FragColor = texture2D(sTexture, tc);
+}
+"
+ };
+
+ uint vertexShader = Gl.CreateShader(ShaderType.VertexShader);
+ Gl.ShaderSource(vertexShader, vertexShaderSource);
+ Gl.CompileShader(vertexShader);
+
+ uint fragmentShader = Gl.CreateShader(ShaderType.FragmentShader);
+ Gl.ShaderSource(fragmentShader, fragmentShaderSource);
+ Gl.CompileShader(fragmentShader);
+
+ shader_program = Gl.CreateProgram();
+ Gl.AttachShader(shader_program, vertexShader);
+ Gl.AttachShader(shader_program, fragmentShader);
+ Gl.LinkProgram(shader_program);
+
+ int length;
+ StringBuilder stringBuilder = new StringBuilder(10000);
+ Gl.GetShaderInfoLog(fragmentShader, 10000, out length, stringBuilder);
+ System.Diagnostics.Debug.WriteLine(stringBuilder);
+ stringBuilder.Clear();
+ Gl.GetShaderInfoLog(vertexShader, 10000, out length, stringBuilder);
+ System.Diagnostics.Debug.WriteLine(stringBuilder);
+ stringBuilder.Clear();
+ Gl.GetProgramInfoLog(shader_program, 10000, out length, stringBuilder);
+ System.Diagnostics.Debug.WriteLine(stringBuilder);
+ stringBuilder.Clear();
+
+ Gl.UseProgram(shader_program);
+
+ Gl.Uniform1(Gl.GetUniformLocation(shader_program, "sTexture"), 0);
+
+
+ texture = Gl.GenTexture();
+
+ Gl.ActiveTexture(TextureUnit.Texture0);
+ Gl.BindTexture(TextureTarget.Texture2d, texture);
+ Gl.TexParameteri(TextureTarget.Texture2d, TextureParameterName.TextureWrapS, TextureWrapMode.ClampToEdge);
+ Gl.TexParameteri(TextureTarget.Texture2d, TextureParameterName.TextureWrapT, TextureWrapMode.ClampToEdge);
+ Gl.TexParameteri(TextureTarget.Texture2d, TextureParameterName.TextureMagFilter, TextureMagFilter.Nearest);
+ Gl.TexParameteri(TextureTarget.Texture2d, TextureParameterName.TextureMinFilter, TextureMagFilter.Nearest);
+
+
+ float[] buf = { 1.0f, 1.0f, -1.0f, 1.0f, 1.0f, -1.0f, -1.0f, -1.0f };
+ vertex_buf = Gl.GenBuffer();
+ Gl.BindBuffer(BufferTarget.ArrayBuffer, vertex_buf);
+ Gl.BufferData(BufferTarget.ArrayBuffer, (uint)(sizeof(float) * buf.Length), buf, BufferUsage.StaticDraw);
+
+ vao = Gl.GenVertexArray();
+ }
+}
+
public class WPFImage : ElementHost
{
- private int ByteSize;
+ public GlImage gl_img;
+
+ private int ByteSize;
private Rectangle rect1;
@@ -37,6 +219,12 @@ public class WPFImage : ElementHost
Stretch = Stretch.Uniform
};
base.Child = child;
+
+ gl_img = new GlImage();
+ }
+
+ public void PollEvents() {
+ gl_img.PollEvents();
}
public void ImageSetting()
@@ -81,9 +269,11 @@ public class WPFImage : ElementHost
wb.AddDirtyRect(rect2);
wb.Unlock();
bmp.UnlockBits(data);
+
+ gl_img.SetBitmap(bmp);
}
- public void BitmapSetting(Bitmap bmp)
+ public void BitmapSetting(Bitmap bmp)
{
int pixelWidth = bmp.Width;
int num = bmp.Height;
@@ -92,6 +282,8 @@ public class WPFImage : ElementHost
wb = new WriteableBitmap(pixelWidth, num, bmp.HorizontalResolution, bmp.VerticalResolution, PixelFormats.Bgra32, null);
ByteSize = wb.BackBufferStride * num;
Image.Source = wb;
- }
+
+ gl_img.BitmapSetting(bmp);
+ }
}
diff --git a/SlaveMatrix/SlaveMatrix.csproj b/SlaveMatrix/SlaveMatrix.csproj
index 04dfd76..60cf0ff 100644
--- a/SlaveMatrix/SlaveMatrix.csproj
+++ b/SlaveMatrix/SlaveMatrix.csproj
@@ -5,7 +5,7 @@
False
WinExe
True
- net45
+ net462
x86
diff --git a/SlaveMatrix/SlaveMatrix/GameClasses/Mods.cs b/SlaveMatrix/SlaveMatrix/GameClasses/Mods.cs
index fdad2fa..e1b6dab 100644
--- a/SlaveMatrix/SlaveMatrix/GameClasses/Mods.cs
+++ b/SlaveMatrix/SlaveMatrix/GameClasses/Mods.cs
@@ -6590,16 +6590,10 @@ public static class Mods
Viola.両目_見つめ();
Viola.Set基本姿勢();
-
- //I added this
- Viola.Bod.拘束具_表示 = false;
- Viola.Set拘束姿勢();
};
DrawOP1 = delegate(Are a, FPS FPS)
{
- System.Diagnostics.Debug.Print("Draw OP1\n");
a.Draw(OfficeBackground);
- //Viola.SetInitialAngle();
Viola.Draw(a, FPS);
ヴィオラ吹出し.Draw(a, FPS);
dbs.Draw(a);
diff --git a/Solution.sln b/Solution.sln
index 254d911..e411602 100644
--- a/Solution.sln
+++ b/Solution.sln
@@ -8,20 +8,32 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "2DGAMELIB", "2DGAMELIB\2DGA
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
+ Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {627ABCB0-698F-4FF9-A85D-1E99EBCACF46}.Debug|x64.ActiveCfg = Debug|Any CPU
+ {627ABCB0-698F-4FF9-A85D-1E99EBCACF46}.Debug|x64.Build.0 = Debug|Any CPU
{627ABCB0-698F-4FF9-A85D-1E99EBCACF46}.Debug|x86.ActiveCfg = Debug|Any CPU
{627ABCB0-698F-4FF9-A85D-1E99EBCACF46}.Debug|x86.Build.0 = Debug|Any CPU
+ {627ABCB0-698F-4FF9-A85D-1E99EBCACF46}.Release|x64.ActiveCfg = Release|Any CPU
+ {627ABCB0-698F-4FF9-A85D-1E99EBCACF46}.Release|x64.Build.0 = Release|Any CPU
{627ABCB0-698F-4FF9-A85D-1E99EBCACF46}.Release|x86.ActiveCfg = Release|Any CPU
{627ABCB0-698F-4FF9-A85D-1E99EBCACF46}.Release|x86.Build.0 = Release|Any CPU
+ {A12B2957-8EC4-4DA7-AD38-4FE141C532E1}.Debug|x64.ActiveCfg = Debug|Any CPU
+ {A12B2957-8EC4-4DA7-AD38-4FE141C532E1}.Debug|x64.Build.0 = Debug|Any CPU
{A12B2957-8EC4-4DA7-AD38-4FE141C532E1}.Debug|x86.ActiveCfg = Debug|Any CPU
{A12B2957-8EC4-4DA7-AD38-4FE141C532E1}.Debug|x86.Build.0 = Debug|Any CPU
+ {A12B2957-8EC4-4DA7-AD38-4FE141C532E1}.Release|x64.ActiveCfg = Release|Any CPU
{A12B2957-8EC4-4DA7-AD38-4FE141C532E1}.Release|x86.ActiveCfg = Release|Any CPU
{A12B2957-8EC4-4DA7-AD38-4FE141C532E1}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {FDC934AE-CC78-4A00-8BA8-A0337351CCA8}
+ EndGlobalSection
EndGlobal
diff --git a/game_folder/glfw.dll b/game_folder/glfw.dll
new file mode 100644
index 0000000..17330db
Binary files /dev/null and b/game_folder/glfw.dll differ