Fixed bitmap resize
This commit is contained in:
@@ -215,6 +215,17 @@ namespace _2DGAMELIB
|
|||||||
resVector.Y = ((double)height - (double)BaseSize.Height / resMag) * 0.5;
|
resVector.Y = ((double)height - (double)BaseSize.Height / resMag) * 0.5;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int fbW, fbH;
|
||||||
|
|
||||||
|
Glfw.GetFramebufferSize(GlImage.PtrToWindow(window), out fbW, out fbH);
|
||||||
|
|
||||||
|
uint vpW = (uint)(BaseSize.Width / resMag);
|
||||||
|
uint vpH = (uint)(BaseSize.Height / resMag);
|
||||||
|
int vpX = (int)(resVector.X);
|
||||||
|
int vpY = (int)(fbH - resVector.Y - vpH);
|
||||||
|
|
||||||
|
baseControl.SetViewport(vpW, vpH, vpX, vpY);
|
||||||
};
|
};
|
||||||
|
|
||||||
return BaseSize;
|
return BaseSize;
|
||||||
|
|||||||
@@ -37,9 +37,16 @@ namespace _2DGAMELIB
|
|||||||
private uint texture;
|
private uint texture;
|
||||||
private uint vertex_buf;
|
private uint vertex_buf;
|
||||||
private uint vao;
|
private uint vao;
|
||||||
|
public int texW = 0;
|
||||||
|
public int texH = 0;
|
||||||
|
|
||||||
public GlImage() { }
|
public GlImage() { }
|
||||||
|
|
||||||
|
public void SetViewport(uint vpW, uint vpH, int vpX, int vpY)
|
||||||
|
{
|
||||||
|
gl.Viewport(vpX, vpY, vpW, vpH);
|
||||||
|
}
|
||||||
|
|
||||||
public Vector2D GetCursorPoint() {
|
public Vector2D GetCursorPoint() {
|
||||||
double x, y;
|
double x, y;
|
||||||
Glfw.GetCursorPosition(window, out x, out y);
|
Glfw.GetCursorPosition(window, out x, out y);
|
||||||
@@ -92,13 +99,11 @@ namespace _2DGAMELIB
|
|||||||
public unsafe void SetBitmap(Bitmap bmp)
|
public unsafe void SetBitmap(Bitmap bmp)
|
||||||
{
|
{
|
||||||
gl.UseProgram(shader_program);
|
gl.UseProgram(shader_program);
|
||||||
gl.Viewport(new Size(bmp.Width, bmp.Height));
|
|
||||||
|
|
||||||
gl.ActiveTexture(Silk.NET.OpenGL.GLEnum.Texture0);
|
gl.ActiveTexture(Silk.NET.OpenGL.GLEnum.Texture0);
|
||||||
gl.BindTexture(Silk.NET.OpenGL.GLEnum.Texture2D, texture);
|
gl.BindTexture(Silk.NET.OpenGL.GLEnum.Texture2D, texture);
|
||||||
|
|
||||||
BitmapData data = bmp.LockBits(new System.Drawing.Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
|
if (bmp.Width != texW || bmp.Height != texH)
|
||||||
|
{
|
||||||
gl.TexImage2D(
|
gl.TexImage2D(
|
||||||
Silk.NET.OpenGL.GLEnum.Texture2D,
|
Silk.NET.OpenGL.GLEnum.Texture2D,
|
||||||
0,
|
0,
|
||||||
@@ -108,32 +113,33 @@ namespace _2DGAMELIB
|
|||||||
0,
|
0,
|
||||||
Silk.NET.OpenGL.GLEnum.Bgra,
|
Silk.NET.OpenGL.GLEnum.Bgra,
|
||||||
Silk.NET.OpenGL.GLEnum.UnsignedByte,
|
Silk.NET.OpenGL.GLEnum.UnsignedByte,
|
||||||
(void*)data.Scan0
|
null);
|
||||||
);
|
|
||||||
|
texW = bmp.Width;
|
||||||
|
texH = bmp.Height;
|
||||||
|
}
|
||||||
|
|
||||||
|
BitmapData data = bmp.LockBits(new System.Drawing.Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
|
||||||
|
|
||||||
|
gl.PixelStore(GLEnum.UnpackAlignment, 1);
|
||||||
|
|
||||||
|
gl.TexSubImage2D(
|
||||||
|
Silk.NET.OpenGL.GLEnum.Texture2D,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
(uint)bmp.Width,
|
||||||
|
(uint)bmp.Height,
|
||||||
|
Silk.NET.OpenGL.GLEnum.Bgra,
|
||||||
|
Silk.NET.OpenGL.GLEnum.UnsignedByte,
|
||||||
|
(void*)data.Scan0);
|
||||||
|
|
||||||
bmp.UnlockBits(data);
|
bmp.UnlockBits(data);
|
||||||
|
|
||||||
|
|
||||||
int res_pos = gl.GetUniformLocation(shader_program, "res");
|
|
||||||
gl.Uniform2(res_pos, (float)bmp.Width, (float)bmp.Height);
|
|
||||||
|
|
||||||
gl.BindBuffer(GLEnum.ArrayBuffer, vertex_buf);
|
|
||||||
uint vert_pos = (uint)gl.GetAttribLocation(shader_program, "vertPos");
|
|
||||||
gl.EnableVertexAttribArray(vert_pos);
|
|
||||||
|
|
||||||
|
|
||||||
gl.BindVertexArray(vao);
|
gl.BindVertexArray(vao);
|
||||||
gl.VertexAttribPointer(
|
|
||||||
vert_pos,
|
|
||||||
2,
|
|
||||||
GLEnum.Float,
|
|
||||||
false,
|
|
||||||
0,
|
|
||||||
IntPtr.Zero
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
gl.DrawArrays(GLEnum.TriangleStrip, 0, 4);
|
gl.DrawArrays(GLEnum.TriangleStrip, 0, 4);
|
||||||
|
gl.BindVertexArray(0);
|
||||||
|
|
||||||
Glfw.SwapBuffers(window);
|
Glfw.SwapBuffers(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -164,31 +170,33 @@ namespace _2DGAMELIB
|
|||||||
|
|
||||||
string vertexShaderSource =
|
string vertexShaderSource =
|
||||||
@"
|
@"
|
||||||
#version 100
|
#version 330 core
|
||||||
precision mediump float;
|
|
||||||
|
|
||||||
attribute vec2 vertPos;
|
layout (location = 0) in vec2 aPos;
|
||||||
|
layout (location = 1) in vec2 aUV;
|
||||||
|
|
||||||
|
out vec2 vUV;
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
gl_Position = vec4(vertPos, 0.0, 1.0);
|
gl_Position = vec4(aPos, 0.0f, 1.0f);
|
||||||
|
vUV = aUV;
|
||||||
}
|
}
|
||||||
";
|
";
|
||||||
|
|
||||||
string fragmentShaderSource =
|
string fragmentShaderSource =
|
||||||
@"
|
@"
|
||||||
#version 100
|
#version 330 core
|
||||||
precision mediump float;
|
|
||||||
|
in vec2 vUV;
|
||||||
|
|
||||||
|
out vec4 FragColor;
|
||||||
|
|
||||||
uniform sampler2D sTexture;
|
uniform sampler2D sTexture;
|
||||||
uniform vec2 res;
|
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
vec2 tc = gl_FragCoord.xy / res;
|
FragColor = texture(sTexture, vUV);
|
||||||
tc.y = 1.0 - tc.y;
|
|
||||||
|
|
||||||
gl_FragColor = texture2D(sTexture, tc);
|
|
||||||
}
|
}
|
||||||
";
|
";
|
||||||
|
|
||||||
@@ -223,13 +231,61 @@ void main()
|
|||||||
gl.TexParameterI(Silk.NET.OpenGL.GLEnum.Texture2D, Silk.NET.OpenGL.GLEnum.TextureMagFilter, new int[] {(int)TextureMagFilter.Nearest});
|
gl.TexParameterI(Silk.NET.OpenGL.GLEnum.Texture2D, Silk.NET.OpenGL.GLEnum.TextureMagFilter, new int[] {(int)TextureMagFilter.Nearest});
|
||||||
gl.TexParameterI(Silk.NET.OpenGL.GLEnum.Texture2D, Silk.NET.OpenGL.GLEnum.TextureMinFilter, new int[] {(int)TextureMinFilter.Nearest});
|
gl.TexParameterI(Silk.NET.OpenGL.GLEnum.Texture2D, Silk.NET.OpenGL.GLEnum.TextureMinFilter, new int[] {(int)TextureMinFilter.Nearest});
|
||||||
|
|
||||||
|
gl.TexImage2D(
|
||||||
|
Silk.NET.OpenGL.GLEnum.Texture2D,
|
||||||
|
0,
|
||||||
|
InternalFormat.Rgba8,
|
||||||
|
(uint)bmp.Width,
|
||||||
|
(uint)bmp.Height,
|
||||||
|
0,
|
||||||
|
Silk.NET.OpenGL.GLEnum.Bgra,
|
||||||
|
Silk.NET.OpenGL.GLEnum.UnsignedByte,
|
||||||
|
null
|
||||||
|
);
|
||||||
|
|
||||||
|
texW = bmp.Width;
|
||||||
|
texH = bmp.Height;
|
||||||
|
|
||||||
|
float[] buf = {
|
||||||
|
-1.0f, -1.0f, 0.0f, 1.0f,
|
||||||
|
1.0f, -1.0f, 1.0f, 1.0f,
|
||||||
|
-1.0f, 1.0f, 0.0f, 0.0f,
|
||||||
|
1.0f, 1.0f, 1.0f, 0.0f
|
||||||
|
};
|
||||||
|
|
||||||
float[] buf = { 1.0f, 1.0f, -1.0f, 1.0f, 1.0f, -1.0f, -1.0f, -1.0f };
|
|
||||||
vertex_buf = gl.GenBuffer();
|
vertex_buf = gl.GenBuffer();
|
||||||
gl.BindBuffer(Silk.NET.OpenGL.GLEnum.ArrayBuffer, vertex_buf);
|
gl.BindBuffer(Silk.NET.OpenGL.GLEnum.ArrayBuffer, vertex_buf);
|
||||||
fixed (float* buf_ = buf) gl.BufferData(Silk.NET.OpenGL.GLEnum.ArrayBuffer, (uint)(sizeof(float) * buf.Length), buf_, Silk.NET.OpenGL.GLEnum.StaticDraw);
|
fixed (float* buf_ = buf) gl.BufferData(Silk.NET.OpenGL.GLEnum.ArrayBuffer, (uint)(sizeof(float) * buf.Length), buf_, Silk.NET.OpenGL.GLEnum.StaticDraw);
|
||||||
|
|
||||||
vao = gl.GenVertexArray();
|
vao = gl.GenVertexArray();
|
||||||
|
|
||||||
|
gl.BindVertexArray(vao);
|
||||||
|
gl.BindBuffer(GLEnum.ArrayBuffer, vertex_buf);
|
||||||
|
|
||||||
|
|
||||||
|
gl.VertexAttribPointer(
|
||||||
|
0,
|
||||||
|
2,
|
||||||
|
GLEnum.Float,
|
||||||
|
false,
|
||||||
|
4 * sizeof(float),
|
||||||
|
IntPtr.Zero
|
||||||
|
);
|
||||||
|
|
||||||
|
gl.EnableVertexAttribArray(0);
|
||||||
|
|
||||||
|
gl.VertexAttribPointer(
|
||||||
|
1,
|
||||||
|
2,
|
||||||
|
GLEnum.Float,
|
||||||
|
false,
|
||||||
|
4 * sizeof(float),
|
||||||
|
(void*)(2 * sizeof(float))
|
||||||
|
);
|
||||||
|
|
||||||
|
gl.EnableVertexAttribArray(1);
|
||||||
|
|
||||||
|
gl.BindVertexArray(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2,7 +2,7 @@ using _2DGAMELIB;
|
|||||||
|
|
||||||
namespace SlaveMatrix
|
namespace SlaveMatrix
|
||||||
{
|
{
|
||||||
public class バイブ_デンマ : Ele
|
public class バイブ_デンマ : Ele //baibu_denma
|
||||||
{
|
{
|
||||||
public Par X0Y0_ヘッド;
|
public Par X0Y0_ヘッド;
|
||||||
|
|
||||||
|
|||||||
@@ -902,7 +902,7 @@ namespace SlaveMatrix
|
|||||||
return t[num][num2];
|
return t[num][num2];
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<string[]> パース(this string s)
|
public static List<string[]> Parse(this string s)
|
||||||
{
|
{
|
||||||
List<string[]> list = new List<string[]>();
|
List<string[]> list = new List<string[]>();
|
||||||
string[] array = s.Split("\r\n\r\n");
|
string[] array = s.Split("\r\n\r\n");
|
||||||
@@ -921,29 +921,29 @@ namespace SlaveMatrix
|
|||||||
public static void Set擬音()
|
public static void Set擬音()
|
||||||
{
|
{
|
||||||
string[] array = ImiPath.FromText().Split(',');
|
string[] array = ImiPath.FromText().Split(',');
|
||||||
口挿 = array[0].パース();
|
口挿 = array[0].Parse();
|
||||||
口中 = array[1].パース();
|
口中 = array[1].Parse();
|
||||||
口抜 = array[2].パース();
|
口抜 = array[2].Parse();
|
||||||
膣挿 = array[3].パース();
|
膣挿 = array[3].Parse();
|
||||||
膣中 = array[4].パース();
|
膣中 = array[4].Parse();
|
||||||
膣抜 = array[5].パース();
|
膣抜 = array[5].Parse();
|
||||||
肛挿 = array[6].パース();
|
肛挿 = array[6].Parse();
|
||||||
肛中 = array[7].パース();
|
肛中 = array[7].Parse();
|
||||||
肛抜 = array[8].パース();
|
肛抜 = array[8].Parse();
|
||||||
糸挿 = array[9].パース();
|
糸挿 = array[9].Parse();
|
||||||
糸中 = array[10].パース();
|
糸中 = array[10].Parse();
|
||||||
糸抜 = array[11].パース();
|
糸抜 = array[11].Parse();
|
||||||
潮吹 = array[12].パース();
|
潮吹 = array[12].Parse();
|
||||||
放尿 = array[13].パース();
|
放尿 = array[13].Parse();
|
||||||
くぱ = array[14].パース();
|
くぱ = array[14].Parse();
|
||||||
吸引 = array[15].パース();
|
吸引 = array[15].Parse();
|
||||||
吸着 = array[16].パース();
|
吸着 = array[16].Parse();
|
||||||
吸脱 = array[17].パース();
|
吸脱 = array[17].Parse();
|
||||||
振動 = array[18].パース();
|
振動 = array[18].Parse();
|
||||||
鞭振 = array[19].パース();
|
鞭振 = array[19].Parse();
|
||||||
鞭打 = array[20].パース();
|
鞭打 = array[20].Parse();
|
||||||
剃り = array[21].パース();
|
剃り = array[21].Parse();
|
||||||
射精 = array[22].パース();
|
射精 = array[22].Parse();
|
||||||
処女喪失 = (from f in array[23].Split("\r\n")
|
処女喪失 = (from f in array[23].Split("\r\n")
|
||||||
where !string.IsNullOrWhiteSpace(f) && !f.StartsWith("//")
|
where !string.IsNullOrWhiteSpace(f) && !f.StartsWith("//")
|
||||||
select f).First();
|
select f).First();
|
||||||
@@ -1088,9 +1088,9 @@ namespace SlaveMatrix
|
|||||||
obj.MigrateKeys();
|
obj.MigrateKeys();
|
||||||
胴体 = obj;
|
胴体 = obj;
|
||||||
|
|
||||||
//胴体.SaveExMod("C:\\Users\\dave\\Documents\\胴体");
|
//胴体.SaveExMod("C:\\Users\\adel4\\Documents\\胴体");
|
||||||
//Ser.ToJson(胴体, "C:\\Users\\dave\\Documents\\胴体.json");
|
//Ser.ToJson(胴体, "C:\\Users\\adel4\\Documents\\胴体.json");
|
||||||
//胴体 = Ser.UnJson<Obj>("C:\\Users\\dave\\Documents\\胴体.json");
|
//胴体 = Ser.UnJson<Obj>("C:\\Users\\adel4\\Documents\\胴体.json");
|
||||||
|
|
||||||
obj = Resources.肩左.ObjLoad();
|
obj = Resources.肩左.ObjLoad();
|
||||||
obj.MigrateKeys();
|
obj.MigrateKeys();
|
||||||
|
|||||||
Reference in New Issue
Block a user