Mitosis!
This commit is contained in:
@@ -4,8 +4,9 @@
|
|||||||
<AssemblyName>2DGAMELIB</AssemblyName>
|
<AssemblyName>2DGAMELIB</AssemblyName>
|
||||||
<GenerateAssemblyInfo>False</GenerateAssemblyInfo>
|
<GenerateAssemblyInfo>False</GenerateAssemblyInfo>
|
||||||
<UseWindowsForms>True</UseWindowsForms>
|
<UseWindowsForms>True</UseWindowsForms>
|
||||||
<TargetFramework>net45</TargetFramework>
|
<TargetFramework>net462</TargetFramework>
|
||||||
<PlatformTarget>x86</PlatformTarget>
|
<PlatformTarget>x86</PlatformTarget>
|
||||||
|
<Platforms>AnyCPU</Platforms>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<LangVersion>10.0</LangVersion>
|
<LangVersion>10.0</LangVersion>
|
||||||
@@ -15,7 +16,9 @@
|
|||||||
<RootNamespace />
|
<RootNamespace />
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<PackageReference Include="glfw-net" Version="3.3.1" />
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||||
|
<PackageReference Include="OpenGL.Net" Version="0.8.4" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="PresentationFramework">
|
<Reference Include="PresentationFramework">
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
|
using GLFW;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Drawing.Drawing2D;
|
using System.Drawing.Drawing2D;
|
||||||
|
using System.Net.Http.Headers;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
@@ -164,69 +166,135 @@ public class Med
|
|||||||
Clear();
|
Clear();
|
||||||
Sce = new Sce(BaseSize.Width, BaseSize.Height);
|
Sce = new Sce(BaseSize.Width, BaseSize.Height);
|
||||||
Modes = GetModes(this);
|
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);
|
Point Position5 = baseControl.PointToClient(System.Windows.Forms.Cursor.Position);
|
||||||
MouseButtons arg2 = MouseButtons.None;
|
MouseButtons arg2 = MouseButtons.None;
|
||||||
switch (e.ChangedButton)
|
switch (e.ChangedButton)
|
||||||
{
|
{
|
||||||
case MouseButton.Left:
|
case System.Windows.Input.MouseButton.Left:
|
||||||
arg2 = MouseButtons.Left;
|
arg2 = MouseButtons.Left;
|
||||||
break;
|
break;
|
||||||
case MouseButton.Middle:
|
case System.Windows.Input.MouseButton.Middle:
|
||||||
arg2 = MouseButtons.Middle;
|
arg2 = MouseButtons.Middle;
|
||||||
break;
|
break;
|
||||||
case MouseButton.Right:
|
case System.Windows.Input.MouseButton.Right:
|
||||||
arg2 = MouseButtons.Right;
|
arg2 = MouseButtons.Right;
|
||||||
break;
|
break;
|
||||||
case MouseButton.XButton1:
|
case System.Windows.Input.MouseButton.XButton1:
|
||||||
arg2 = MouseButtons.XButton1;
|
arg2 = MouseButtons.XButton1;
|
||||||
break;
|
break;
|
||||||
case MouseButton.XButton2:
|
case System.Windows.Input.MouseButton.XButton2:
|
||||||
arg2 = MouseButtons.XButton2;
|
arg2 = MouseButtons.XButton2;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Modes[mode].Down(arg2, ToBasePosition(Position5), GetHitColor(ref Position5));
|
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);
|
Point Position4 = baseControl.PointToClient(System.Windows.Forms.Cursor.Position);
|
||||||
MouseButtons arg = MouseButtons.None;
|
MouseButtons arg = MouseButtons.None;
|
||||||
switch (e.ChangedButton)
|
switch (e.ChangedButton)
|
||||||
{
|
{
|
||||||
case MouseButton.Left:
|
case System.Windows.Input.MouseButton.Left:
|
||||||
arg = MouseButtons.Left;
|
arg = MouseButtons.Left;
|
||||||
break;
|
break;
|
||||||
case MouseButton.Middle:
|
case System.Windows.Input.MouseButton.Middle:
|
||||||
arg = MouseButtons.Middle;
|
arg = MouseButtons.Middle;
|
||||||
break;
|
break;
|
||||||
case MouseButton.Right:
|
case System.Windows.Input.MouseButton.Right:
|
||||||
arg = MouseButtons.Right;
|
arg = MouseButtons.Right;
|
||||||
break;
|
break;
|
||||||
case MouseButton.XButton1:
|
case System.Windows.Input.MouseButton.XButton1:
|
||||||
arg = MouseButtons.XButton1;
|
arg = MouseButtons.XButton1;
|
||||||
break;
|
break;
|
||||||
case MouseButton.XButton2:
|
case System.Windows.Input.MouseButton.XButton2:
|
||||||
arg = MouseButtons.XButton2;
|
arg = MouseButtons.XButton2;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Modes[mode].Up(arg, ToBasePosition(Position4), GetHitColor(ref Position4));
|
Modes[mode].Up(arg, ToBasePosition(Position4), GetHitColor(ref Position4));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
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
|
BaseControl.Image.MouseMove += delegate
|
||||||
{
|
{
|
||||||
Point Position3 = baseControl.PointToClient(System.Windows.Forms.Cursor.Position);
|
Point Position3 = baseControl.PointToClient(System.Windows.Forms.Cursor.Position);
|
||||||
Modes[mode].Move(Control.MouseButtons, ToBasePosition(Position3), GetHitColor(ref Position3));
|
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
|
BaseControl.Image.MouseLeave += delegate
|
||||||
{
|
{
|
||||||
Point Position2 = baseControl.PointToClient(System.Windows.Forms.Cursor.Position);
|
Point Position2 = baseControl.PointToClient(System.Windows.Forms.Cursor.Position);
|
||||||
Modes[mode].Leave(Control.MouseButtons, ToBasePosition(Position2), GetHitColor(ref Position2));
|
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)
|
BaseControl.Image.MouseWheel += delegate(object s, MouseWheelEventArgs e)
|
||||||
{
|
{
|
||||||
Point Position = baseControl.PointToClient(System.Windows.Forms.Cursor.Position);
|
Point Position = baseControl.PointToClient(System.Windows.Forms.Cursor.Position);
|
||||||
Modes[mode].Wheel(Control.MouseButtons, ToBasePosition(Position), e.Delta, GetHitColor(ref 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
|
((Control)BaseControl).Resize += delegate
|
||||||
{
|
{
|
||||||
if (BaseSize.Width >= BaseSize.Height)
|
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;
|
return BaseSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -352,6 +458,7 @@ public class Med
|
|||||||
baseControl.Parent.Text = UITitle + " - FPS: " + System.Math.Round(FPSF.Value, 2);
|
baseControl.Parent.Text = UITitle + " - FPS: " + System.Math.Round(FPSF.Value, 2);
|
||||||
}
|
}
|
||||||
Application.DoEvents();
|
Application.DoEvents();
|
||||||
|
baseControl.PollEvents();
|
||||||
|
|
||||||
long frame_update_end = FPSF.sw.ElapsedMilliseconds;
|
long frame_update_end = FPSF.sw.ElapsedMilliseconds;
|
||||||
|
|
||||||
|
|||||||
@@ -10,9 +10,6 @@ namespace _2DGAMELIB;
|
|||||||
|
|
||||||
public class UI : Form
|
public class UI : Form
|
||||||
{
|
{
|
||||||
|
|
||||||
private Point Position = Point.Empty;
|
|
||||||
|
|
||||||
private Med Med;
|
private Med Med;
|
||||||
|
|
||||||
private IContainer components;
|
private IContainer components;
|
||||||
@@ -56,11 +53,6 @@ public class UI : Form
|
|||||||
base.ClientSize = new Size(1280, 960);
|
base.ClientSize = new Size(1280, 960);
|
||||||
}
|
}
|
||||||
UI_Resize(null, null);
|
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)
|
private void UI_FormClosing(object sender, FormClosingEventArgs e)
|
||||||
@@ -68,11 +60,6 @@ public class UI : Form
|
|||||||
Med.Drive = false;
|
Med.Drive = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UI_Move(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
Position = base.Location;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void UI_Resize(object sender, EventArgs e)
|
private void UI_Resize(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
wpfImage1.ImageSetting();
|
wpfImage1.ImageSetting();
|
||||||
@@ -115,8 +102,11 @@ public class UI : Form
|
|||||||
base.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
|
base.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
|
||||||
|
|
||||||
base.FormClosing += new System.Windows.Forms.FormClosingEventHandler(UI_FormClosing);
|
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.Load += new System.EventHandler(UI_Load);
|
||||||
base.Move += new System.EventHandler(UI_Move);
|
|
||||||
base.Resize += new System.EventHandler(UI_Resize);
|
base.Resize += new System.EventHandler(UI_Resize);
|
||||||
base.ResumeLayout(false);
|
base.ResumeLayout(false);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,12 @@
|
|||||||
|
using GLFW;
|
||||||
|
using OpenGL;
|
||||||
using System;
|
using System;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Drawing.Imaging;
|
using System.Drawing.Imaging;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Text;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
using System.Windows.Forms.Integration;
|
using System.Windows.Forms.Integration;
|
||||||
@@ -12,8 +15,187 @@ using System.Windows.Media.Imaging;
|
|||||||
|
|
||||||
namespace _2DGAMELIB;
|
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
|
public class WPFImage : ElementHost
|
||||||
{
|
{
|
||||||
|
public GlImage gl_img;
|
||||||
|
|
||||||
private int ByteSize;
|
private int ByteSize;
|
||||||
|
|
||||||
private Rectangle rect1;
|
private Rectangle rect1;
|
||||||
@@ -37,6 +219,12 @@ public class WPFImage : ElementHost
|
|||||||
Stretch = Stretch.Uniform
|
Stretch = Stretch.Uniform
|
||||||
};
|
};
|
||||||
base.Child = child;
|
base.Child = child;
|
||||||
|
|
||||||
|
gl_img = new GlImage();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void PollEvents() {
|
||||||
|
gl_img.PollEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ImageSetting()
|
public void ImageSetting()
|
||||||
@@ -81,6 +269,8 @@ public class WPFImage : ElementHost
|
|||||||
wb.AddDirtyRect(rect2);
|
wb.AddDirtyRect(rect2);
|
||||||
wb.Unlock();
|
wb.Unlock();
|
||||||
bmp.UnlockBits(data);
|
bmp.UnlockBits(data);
|
||||||
|
|
||||||
|
gl_img.SetBitmap(bmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void BitmapSetting(Bitmap bmp)
|
public void BitmapSetting(Bitmap bmp)
|
||||||
@@ -92,6 +282,8 @@ public class WPFImage : ElementHost
|
|||||||
wb = new WriteableBitmap(pixelWidth, num, bmp.HorizontalResolution, bmp.VerticalResolution, PixelFormats.Bgra32, null);
|
wb = new WriteableBitmap(pixelWidth, num, bmp.HorizontalResolution, bmp.VerticalResolution, PixelFormats.Bgra32, null);
|
||||||
ByteSize = wb.BackBufferStride * num;
|
ByteSize = wb.BackBufferStride * num;
|
||||||
Image.Source = wb;
|
Image.Source = wb;
|
||||||
|
|
||||||
|
gl_img.BitmapSetting(bmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<GenerateAssemblyInfo>False</GenerateAssemblyInfo>
|
<GenerateAssemblyInfo>False</GenerateAssemblyInfo>
|
||||||
<OutputType>WinExe</OutputType>
|
<OutputType>WinExe</OutputType>
|
||||||
<UseWindowsForms>True</UseWindowsForms>
|
<UseWindowsForms>True</UseWindowsForms>
|
||||||
<TargetFramework>net45</TargetFramework>
|
<TargetFramework>net462</TargetFramework>
|
||||||
<PlatformTarget>x86</PlatformTarget>
|
<PlatformTarget>x86</PlatformTarget>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
|
|||||||
@@ -6590,16 +6590,10 @@ public static class Mods
|
|||||||
|
|
||||||
Viola.両目_見つめ();
|
Viola.両目_見つめ();
|
||||||
Viola.Set基本姿勢();
|
Viola.Set基本姿勢();
|
||||||
|
|
||||||
//I added this
|
|
||||||
Viola.Bod.拘束具_表示 = false;
|
|
||||||
Viola.Set拘束姿勢();
|
|
||||||
};
|
};
|
||||||
DrawOP1 = delegate(Are a, FPS FPS)
|
DrawOP1 = delegate(Are a, FPS FPS)
|
||||||
{
|
{
|
||||||
System.Diagnostics.Debug.Print("Draw OP1\n");
|
|
||||||
a.Draw(OfficeBackground);
|
a.Draw(OfficeBackground);
|
||||||
//Viola.SetInitialAngle();
|
|
||||||
Viola.Draw(a, FPS);
|
Viola.Draw(a, FPS);
|
||||||
ヴィオラ吹出し.Draw(a, FPS);
|
ヴィオラ吹出し.Draw(a, FPS);
|
||||||
dbs.Draw(a);
|
dbs.Draw(a);
|
||||||
|
|||||||
12
Solution.sln
12
Solution.sln
@@ -8,20 +8,32 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "2DGAMELIB", "2DGAMELIB\2DGA
|
|||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|x64 = Debug|x64
|
||||||
Debug|x86 = Debug|x86
|
Debug|x86 = Debug|x86
|
||||||
|
Release|x64 = Release|x64
|
||||||
Release|x86 = Release|x86
|
Release|x86 = Release|x86
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
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.ActiveCfg = Debug|Any CPU
|
||||||
{627ABCB0-698F-4FF9-A85D-1E99EBCACF46}.Debug|x86.Build.0 = 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.ActiveCfg = Release|Any CPU
|
||||||
{627ABCB0-698F-4FF9-A85D-1E99EBCACF46}.Release|x86.Build.0 = 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.ActiveCfg = Debug|Any CPU
|
||||||
{A12B2957-8EC4-4DA7-AD38-4FE141C532E1}.Debug|x86.Build.0 = 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.ActiveCfg = Release|Any CPU
|
||||||
{A12B2957-8EC4-4DA7-AD38-4FE141C532E1}.Release|x86.Build.0 = Release|Any CPU
|
{A12B2957-8EC4-4DA7-AD38-4FE141C532E1}.Release|x86.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
|
SolutionGuid = {FDC934AE-CC78-4A00-8BA8-A0337351CCA8}
|
||||||
|
EndGlobalSection
|
||||||
EndGlobal
|
EndGlobal
|
||||||
|
|||||||
BIN
game_folder/glfw.dll
Normal file
BIN
game_folder/glfw.dll
Normal file
Binary file not shown.
Reference in New Issue
Block a user