daily update on 20240209 by nitload youmu
This commit is contained in:
@@ -34,53 +34,9 @@ namespace StgSharp
|
||||
/// This method should be called before other
|
||||
/// graphic methods, after LoadGL method.
|
||||
/// </summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void InitGL(int majorVersion, int minorVersion)
|
||||
{
|
||||
if (InternalIO.glfw == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
InternalIO.glfw = new glFramework_PInvoke();
|
||||
InternalIO.glfw.Init();
|
||||
InternalIO.InternalWriteLog("Successfully load GLFW APIs. StgSharp is now working on p/invoke mode", LogType.Info);
|
||||
}
|
||||
catch (Exception sig)
|
||||
{
|
||||
string log = $"Failed to load GLFW APIs by P/Invoke," +
|
||||
$"StgSharp will switch to delegate mode. The detailed info is:\n" +
|
||||
$"{sig.Message}\n";
|
||||
|
||||
if (InternalIO.SSClibPtr == default)
|
||||
{
|
||||
InternalIO.SSClibPtr =
|
||||
InternalIO.InternalLoadWINlib(InternalIO.SSC_libname + ".dll");
|
||||
}
|
||||
|
||||
InternalIO.glfw = new glFramework_Delegate();
|
||||
InternalIO.SSClibPtr = InternalIO.InternalLoadWINlib(InternalIO.SSC_libname);
|
||||
FieldInfo[] glfwApis = typeof(glFramework_Delegate).GetFields();
|
||||
foreach (FieldInfo item in glfwApis)
|
||||
{
|
||||
if (item.FieldType.BaseType == typeof(Delegate))
|
||||
{
|
||||
try
|
||||
{
|
||||
IntPtr funcptr = InternalIO.InternalGetWINproc(
|
||||
InternalIO.SSClibPtr, item.Name);
|
||||
item.SetValue(null, ConvertAPI(funcptr, item.FieldType));
|
||||
log += $"Successfully load GLFW API called {item.Name}";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
log += $"Failed to load GLFW API called {item.Name}, the detailed info is\n" +
|
||||
$"{ex.Message}";
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
InternalIO.InternalWriteLog(log, LogType.Warning);
|
||||
}
|
||||
}
|
||||
InternalIO.InternalInitGL(majorVersion, minorVersion);
|
||||
}
|
||||
|
||||
|
||||
@@ -19,17 +19,17 @@ namespace StgSharp
|
||||
ElementBuffer ebo;
|
||||
Uniform<int> ourTexture;
|
||||
Uniform<int> ourTexture2;
|
||||
Shader shader;
|
||||
ShaderProgram shader;
|
||||
Texture texture;
|
||||
VertexArray vao;
|
||||
VertexBuffer vbo;
|
||||
|
||||
public static unsafe void ProcessInput(IntPtr windowPtr)
|
||||
{
|
||||
if (InternalIO.glfw.GetKey(windowPtr, (int)Operation.Key.ESCAPE)
|
||||
if (InternalIO.glfwGetKey(windowPtr, (int)Operation.Key.ESCAPE)
|
||||
== KeyStatus.PRESS)
|
||||
{
|
||||
InternalIO.glfw.SetWindowShouldClose(windowPtr, 1);
|
||||
InternalIO.glfwSetWindowShouldClose(windowPtr, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace StgSharp
|
||||
ebo.Dispose();
|
||||
/**/
|
||||
|
||||
InternalIO.glfw.Terminate();
|
||||
InternalIO.glfwTerminate();
|
||||
}
|
||||
|
||||
public unsafe void FormSizeCallback(IntPtr window, uint width, uint height)
|
||||
@@ -69,12 +69,15 @@ namespace StgSharp
|
||||
|
||||
this.LoadGLapi(null);
|
||||
|
||||
shader = CreateShader(ShaderType.Program, 1);
|
||||
shader = CreateShaderProgram();
|
||||
var vertex = CreateShader(ShaderType.Vertex, 1);
|
||||
var fragment = CreateShader(ShaderType.Fragment, 1);
|
||||
vertex.Compile(File.ReadAllText("Shader\\vertex.vert"));
|
||||
fragment.Compile(File.ReadAllText("Shader\\fragment.frag"));
|
||||
shader.Link(0);
|
||||
vertex.Compile(ShaderType.Vertex, File.ReadAllText("Shader\\vertex.vert"));
|
||||
vertex.AttachTo(0, shader);
|
||||
fragment.Compile(ShaderType.Fragment, File.ReadAllText("Shader\\fragment.frag"));
|
||||
fragment.AttachTo(0, shader);
|
||||
|
||||
shader.Link();
|
||||
|
||||
Triangle tri = new Triangle(
|
||||
-0.5f, -0.3f, 0.0f,
|
||||
@@ -115,13 +118,13 @@ namespace StgSharp
|
||||
ebo.SetValue(0, rec.Indices, BufferUsage.STATIC_DRAW);
|
||||
|
||||
vbo.SetValue(0, rec.VertexBuffer, BufferUsage.STATIC_DRAW);
|
||||
gl.SetVertexAttribute(0, 3, typeof(float), false, 4 * sizeof(float), 0);
|
||||
gl.SetVertexAttribute(0, 3, TypeCode.Single, false, 4 * sizeof(float), 0);
|
||||
|
||||
vbo.SetValueArray(1, texCoord, BufferUsage.STATIC_DRAW);
|
||||
gl.SetVertexAttribute(2, 2, typeof(float), false, 2 * sizeof(float), 0);
|
||||
gl.SetVertexAttribute(2, 2, TypeCode.Single, false, 2 * sizeof(float), 0);
|
||||
|
||||
/**/
|
||||
gl.BindBuffer(BufferType.ARRAY_BUFFER, 0);
|
||||
gl.BindBuffer(BufferType.ARRAY_BUFFER, glHandle.Zero);
|
||||
vao.BindNull();
|
||||
/**/
|
||||
|
||||
@@ -168,7 +171,7 @@ namespace StgSharp
|
||||
texture.Bind2D(1);
|
||||
/**/
|
||||
|
||||
float time = (float)InternalIO.glfw.GetTime();
|
||||
float time = (float)InternalIO.glfwGetTime();
|
||||
gl.SetValue(color,
|
||||
0.5f + MathF.Sin(time),
|
||||
0.5f + MathF.Sin(time/* + 0.667f * 3.14f/**/),
|
||||
@@ -177,12 +180,12 @@ namespace StgSharp
|
||||
|
||||
vao.Bind(0);
|
||||
|
||||
gl.DrawElements(GepmetryType.TRIANGLES, 6, typeof(uint), IntPtr.Zero);
|
||||
gl.DrawElements(GepmetryType.TRIANGLES, 6, TypeCode.UInt32, IntPtr.Zero);
|
||||
|
||||
vao.BindNull();
|
||||
|
||||
InternalIO.glfw.SwapBuffers(windowID);
|
||||
InternalIO.glfw.PollEvents();
|
||||
InternalIO.glfwSwapBuffers(windowID);
|
||||
InternalIO.glfwPollEvents();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ using System.Reflection;
|
||||
[assembly: System.Reflection.AssemblyCompanyAttribute("StgSharpDebug")]
|
||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Benchmark")]
|
||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+6fe6b3b3cf0f9c3e9661a85bbe9b084eae6439cd")]
|
||||
[assembly: System.Reflection.AssemblyProductAttribute("StgSharpDebug")]
|
||||
[assembly: System.Reflection.AssemblyTitleAttribute("StgSharpDebug")]
|
||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||
|
||||
@@ -1 +1 @@
|
||||
e340c06b75b4a2ce53efde5f4632c7a375a08a6b1987e3663da0e443a4eb16a3
|
||||
48dfbe97284dd3ebda2da46302a4529fe78a17c51349d96e6c0652ee5a8bf5f0
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
6bee2f0b7bdd2034c75e15618c5bcce64515bb43097f5e90879477a87416cc44
|
||||
aec1e613fe2e6b847e2739cf83946a30bb66e4ccb46edd6e47331a1ecca76c45
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"documents":{"D:\\NitloadIndustry\\研究项目\\1-Flagship\\TH2020\\ProjectFile\\*":"https://raw.githubusercontent.com/Nitload-NSI/CCD_Github/5d778e0f2f6e677453cebc990919697968c771f9/*"}}
|
||||
{"documents":{"D:\\NitloadIndustry\\研究项目\\1-Flagship\\TH2020\\ProjectFile\\*":"https://raw.githubusercontent.com/Nitload-NSI/CCD_Github/6fe6b3b3cf0f9c3e9661a85bbe9b084eae6439cd/*"}}
|
||||
Reference in New Issue
Block a user