MVVM rebuild complete
This commit is contained in:
@@ -29,6 +29,9 @@
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
using StgSharp.Math;
|
||||
using StgSharp.MVVM;
|
||||
using StgSharp.MVVM.View;
|
||||
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -45,8 +48,7 @@ namespace StgSharp.Graphics.OpenGL
|
||||
private const int glExtension = 0x1f03;
|
||||
private const int glVersion = 0x1f02;
|
||||
|
||||
private static readonly string[] glBranch =
|
||||
new string[] {
|
||||
private static readonly string[] glBranch = {
|
||||
"OpenGL ES-CM ",
|
||||
"OpenGL ES-CL ",
|
||||
"OpenGL ES ",
|
||||
@@ -56,16 +58,14 @@ namespace StgSharp.Graphics.OpenGL
|
||||
private static string glExtensionList;
|
||||
|
||||
/// <summary>
|
||||
/// Load all supported OpenGL APIs and bind them to given <see cref="ViewPort"/> viewPortDisplay.
|
||||
/// Load all supported OpenGL APIs and bind them to given <see cref="ViewPort"/>.
|
||||
/// </summary>
|
||||
/// <param name="vp">The <see cref="ViewPort"/> used as current OpenGL viewPortDisplay</param>
|
||||
/// <param name="contextHandle">The handle to current OpenGL viewPortDisplay</param>
|
||||
public static unsafe void LoadOpenGLApiTo(IntPtr contextHandle)
|
||||
{
|
||||
GLcontext* context = (GLcontext*)contextHandle;
|
||||
OpenglContext* context = (OpenglContext*)contextHandle;
|
||||
delegate*<string,IntPtr> loader = &InternalIO.glfwGetProcAddress;
|
||||
#pragma warning disable CS8909
|
||||
if (context->glGetString != (delegate*<uint, IntPtr>)IntPtr.Zero)
|
||||
#pragma warning restore CS8909
|
||||
if ((IntPtr)context->glGetString != IntPtr.Zero)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -84,7 +84,7 @@ namespace StgSharp.Graphics.OpenGL
|
||||
{
|
||||
InternalIO.InternalWriteLog("Failed to call glGetString", LogType.Error);
|
||||
}
|
||||
coreVersion = Marshal.PtrToStringAnsi(context->glGetString(glVersion));
|
||||
coreVersion = Marshal.PtrToStringAnsi(context->glGetString(glVersion))??string.Empty;
|
||||
|
||||
foreach (string branch in glBranch)
|
||||
{
|
||||
@@ -132,20 +132,32 @@ namespace StgSharp.Graphics.OpenGL
|
||||
}
|
||||
}
|
||||
|
||||
IntPtr strPtr = context->glGetString(glExtension);
|
||||
string extension;
|
||||
if (strPtr == IntPtr.Zero)
|
||||
uint code = context->glGetError();
|
||||
Console.WriteLine(code);
|
||||
if (code != 0)
|
||||
{
|
||||
throw new GlExecutionException(code);
|
||||
}
|
||||
|
||||
int extensionCount;
|
||||
context->glGetIntegerv(GLconst.NUM_EXTENSIONS,&extensionCount);
|
||||
if (extensionCount == 0)
|
||||
{
|
||||
InternalIO.InternalWriteLog("No supported OpenGL extensions are found.", LogType.Info);
|
||||
return;
|
||||
}
|
||||
else
|
||||
|
||||
List<string> extensions = new List<string>();
|
||||
|
||||
for (uint i = 0; i < extensionCount; i++)
|
||||
{
|
||||
extension = Marshal.PtrToStringAnsi(strPtr);
|
||||
byte* strPtr = context->glGetStringi(GLconst.EXTENSIONS,i);
|
||||
extensions.Add(Marshal.PtrToStringAnsi((IntPtr)strPtr));
|
||||
}
|
||||
|
||||
List<string> extensions =
|
||||
extension.Split(" ").ToList();
|
||||
InternalIO.InternalWriteLog($"Find OpenGL extensions:" + Environment.NewLine +
|
||||
$"{string.Join(';', extensions)}",
|
||||
LogType.Info);
|
||||
|
||||
#region checkGLextensions
|
||||
|
||||
@@ -771,9 +783,11 @@ namespace StgSharp.Graphics.OpenGL
|
||||
|
||||
#endregion checkGLextensions
|
||||
|
||||
InternalIO.InternalWriteLog("Find OpenGL extensions.", LogType.Info);
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------
|
||||
|
||||
/// <summary>
|
||||
/// Get the function pointer of given OpenGL api name
|
||||
/// </summary>
|
||||
@@ -793,6 +807,11 @@ namespace StgSharp.Graphics.OpenGL
|
||||
|
||||
internal static void CheckCoreVersion(int majorVersion, int minorVersion)
|
||||
{
|
||||
if (majorVersion < 3)
|
||||
{
|
||||
throw new InvalidOperationException("StgSharp does not support OpenGL immediate mode.");
|
||||
}
|
||||
|
||||
if ((majorVersion >= 1) || ((majorVersion == 1) && (minorVersion == 0)))
|
||||
{
|
||||
core10 = true;
|
||||
@@ -971,7 +990,7 @@ namespace StgSharp.Graphics.OpenGL
|
||||
}
|
||||
}
|
||||
|
||||
internal static unsafe string GetExtensions(this GLcontext context)
|
||||
internal static unsafe string GetExtensions(this OpenglContext context)
|
||||
{
|
||||
if (context.glGetString == null)
|
||||
{
|
||||
@@ -998,7 +1017,7 @@ namespace StgSharp.Graphics.OpenGL
|
||||
}
|
||||
}
|
||||
|
||||
internal static unsafe void LoadGLcore10(GLcontext* contextPtr, delegate*<string, IntPtr> load)
|
||||
internal static unsafe void LoadGLcore10(OpenglContext* contextPtr, delegate*<string, IntPtr> load)
|
||||
{
|
||||
if (!core10)
|
||||
{
|
||||
@@ -1062,7 +1081,7 @@ namespace StgSharp.Graphics.OpenGL
|
||||
InternalIO.InternalAppendLog("Successfully load all OpenGL 1.0 APIs");
|
||||
}
|
||||
|
||||
internal static unsafe void LoadGLcore11(GLcontext* contextPtr, delegate*<string, IntPtr> load)
|
||||
internal static unsafe void LoadGLcore11(OpenglContext* contextPtr, delegate*<string, IntPtr> load)
|
||||
{
|
||||
if (!core11)
|
||||
{
|
||||
@@ -1092,7 +1111,7 @@ namespace StgSharp.Graphics.OpenGL
|
||||
InternalIO.InternalAppendLog("Successfully load all OpenGL 1.1 APIs");
|
||||
}
|
||||
|
||||
internal static unsafe void LoadGLcore12(GLcontext* contextPtr, delegate*<string, IntPtr> load)
|
||||
internal static unsafe void LoadGLcore12(OpenglContext* contextPtr, delegate*<string, IntPtr> load)
|
||||
{
|
||||
if (!core12)
|
||||
{
|
||||
@@ -1112,7 +1131,7 @@ namespace StgSharp.Graphics.OpenGL
|
||||
InternalIO.InternalAppendLog("Successfully load all OpenGL 1.2 APIs");
|
||||
}
|
||||
|
||||
internal static unsafe void LoadGLcore13(GLcontext* contextPtr, delegate*<string, IntPtr> load)
|
||||
internal static unsafe void LoadGLcore13(OpenglContext* contextPtr, delegate*<string, IntPtr> load)
|
||||
{
|
||||
if (!core13)
|
||||
{
|
||||
@@ -1137,7 +1156,7 @@ namespace StgSharp.Graphics.OpenGL
|
||||
InternalIO.InternalAppendLog("Successfully load all OpenGL 1.3 APIs");
|
||||
}
|
||||
|
||||
internal static unsafe void LoadGLcore14(GLcontext* contextPtr, delegate*<string, IntPtr> load)
|
||||
internal static unsafe void LoadGLcore14(OpenglContext* contextPtr, delegate*<string, IntPtr> load)
|
||||
{
|
||||
if (!core14)
|
||||
{
|
||||
@@ -1162,7 +1181,7 @@ namespace StgSharp.Graphics.OpenGL
|
||||
InternalIO.InternalAppendLog("Successfully load all OpenGL 1.4 APIs");
|
||||
}
|
||||
|
||||
internal static unsafe void LoadGLcore15(GLcontext* contextPtr, delegate*<string, IntPtr> load)
|
||||
internal static unsafe void LoadGLcore15(OpenglContext* contextPtr, delegate*<string, IntPtr> load)
|
||||
{
|
||||
if (!core15)
|
||||
{
|
||||
@@ -1197,7 +1216,7 @@ namespace StgSharp.Graphics.OpenGL
|
||||
InternalIO.InternalAppendLog("Successfully load all OpenGL 1.5 APIs");
|
||||
}
|
||||
|
||||
internal static unsafe void LoadGLcore20(GLcontext* contextPtr, delegate*<string, IntPtr> load)
|
||||
internal static unsafe void LoadGLcore20(OpenglContext* contextPtr, delegate*<string, IntPtr> load)
|
||||
{
|
||||
if (!core20)
|
||||
{
|
||||
@@ -1306,7 +1325,7 @@ namespace StgSharp.Graphics.OpenGL
|
||||
InternalIO.InternalAppendLog("Successfully load all OpenGL 2.0 APIs");
|
||||
}
|
||||
|
||||
internal static unsafe void LoadGLcore21(GLcontext* contextPtr, delegate*<string, IntPtr> load)
|
||||
internal static unsafe void LoadGLcore21(OpenglContext* contextPtr, delegate*<string, IntPtr> load)
|
||||
{
|
||||
if (!core21)
|
||||
{
|
||||
@@ -1328,7 +1347,7 @@ namespace StgSharp.Graphics.OpenGL
|
||||
InternalIO.InternalAppendLog("Successfully load all OpenGL 2.1 APIs");
|
||||
}
|
||||
|
||||
internal static unsafe void LoadGLcore30(GLcontext* contextPtr, delegate*<string, IntPtr> load)
|
||||
internal static unsafe void LoadGLcore30(OpenglContext* contextPtr, delegate*<string, IntPtr> load)
|
||||
{
|
||||
if (!core30)
|
||||
{
|
||||
@@ -1428,7 +1447,7 @@ namespace StgSharp.Graphics.OpenGL
|
||||
InternalIO.InternalAppendLog("Successfully load all OpenGL 3.0 APIs");
|
||||
}
|
||||
|
||||
internal static unsafe void LoadGLcore31(GLcontext* contextPtr, delegate*<string, IntPtr> load)
|
||||
internal static unsafe void LoadGLcore31(OpenglContext* contextPtr, delegate*<string, IntPtr> load)
|
||||
{
|
||||
if (!core31)
|
||||
{
|
||||
@@ -1459,7 +1478,7 @@ namespace StgSharp.Graphics.OpenGL
|
||||
InternalIO.InternalAppendLog("Successfully load all OpenGL 3.1 APIs");
|
||||
}
|
||||
|
||||
internal static unsafe void LoadGLcore32(GLcontext* contextPtr, delegate*<string, IntPtr> load)
|
||||
internal static unsafe void LoadGLcore32(OpenglContext* contextPtr, delegate*<string, IntPtr> load)
|
||||
{
|
||||
if (!core32)
|
||||
{
|
||||
@@ -1494,7 +1513,7 @@ namespace StgSharp.Graphics.OpenGL
|
||||
InternalIO.InternalAppendLog("Successfully load all OpenGL 3.2 APIs");
|
||||
}
|
||||
|
||||
internal static unsafe void LoadGLcore33(GLcontext* contextPtr, delegate*<string, IntPtr> load)
|
||||
internal static unsafe void LoadGLcore33(OpenglContext* contextPtr, delegate*<string, IntPtr> load)
|
||||
{
|
||||
if (!core33)
|
||||
{
|
||||
@@ -1538,7 +1557,7 @@ namespace StgSharp.Graphics.OpenGL
|
||||
InternalIO.InternalAppendLog("Successfully load all OpenGL 3.3 APIs");
|
||||
}
|
||||
|
||||
internal static unsafe void LoadGLcore40(GLcontext* contextPtr, delegate*<string, IntPtr> load)
|
||||
internal static unsafe void LoadGLcore40(OpenglContext* contextPtr, delegate*<string, IntPtr> load)
|
||||
{
|
||||
if (!core40)
|
||||
{
|
||||
@@ -1600,7 +1619,7 @@ namespace StgSharp.Graphics.OpenGL
|
||||
InternalIO.InternalAppendLog("Successfully load all OpenGL 4.0 APIs");
|
||||
}
|
||||
|
||||
internal static unsafe void LoadGLcore41(GLcontext* contextPtr, delegate*<string, IntPtr> load)
|
||||
internal static unsafe void LoadGLcore41(OpenglContext* contextPtr, delegate*<string, IntPtr> load)
|
||||
{
|
||||
if (!core41)
|
||||
{
|
||||
@@ -1704,7 +1723,7 @@ namespace StgSharp.Graphics.OpenGL
|
||||
InternalIO.InternalAppendLog("Successfully load all OpenGL 4.1 APIs");
|
||||
}
|
||||
|
||||
internal static unsafe void LoadGLcore42(GLcontext* contextPtr, delegate*<string, IntPtr> load)
|
||||
internal static unsafe void LoadGLcore42(OpenglContext* contextPtr, delegate*<string, IntPtr> load)
|
||||
{
|
||||
if (!core42)
|
||||
{
|
||||
@@ -1732,7 +1751,7 @@ namespace StgSharp.Graphics.OpenGL
|
||||
InternalIO.InternalAppendLog("Successfully load all OpenGL 4.2 APIs");
|
||||
}
|
||||
|
||||
internal static unsafe void LoadGLcore43(GLcontext* contextPtr, delegate*<string, IntPtr> load)
|
||||
internal static unsafe void LoadGLcore43(OpenglContext* contextPtr, delegate*<string, IntPtr> load)
|
||||
{
|
||||
if (!core43)
|
||||
{
|
||||
@@ -1792,7 +1811,7 @@ namespace StgSharp.Graphics.OpenGL
|
||||
InternalIO.InternalAppendLog("Successfully load all OpenGL 4.3 APIs");
|
||||
}
|
||||
|
||||
internal static unsafe void LoadGLcore44(GLcontext* contextPtr, delegate*<string, IntPtr> load)
|
||||
internal static unsafe void LoadGLcore44(OpenglContext* contextPtr, delegate*<string, IntPtr> load)
|
||||
{
|
||||
if (!core44)
|
||||
{
|
||||
@@ -1817,7 +1836,7 @@ namespace StgSharp.Graphics.OpenGL
|
||||
InternalIO.InternalAppendLog("Successfully load all OpenGL 4.4 APIs");
|
||||
}
|
||||
|
||||
internal static unsafe void LoadGLcore45(GLcontext* contextPtr, delegate*<string, IntPtr> load)
|
||||
internal static unsafe void LoadGLcore45(OpenglContext* contextPtr, delegate*<string, IntPtr> load)
|
||||
{
|
||||
if (!core45)
|
||||
{
|
||||
@@ -1943,7 +1962,7 @@ namespace StgSharp.Graphics.OpenGL
|
||||
InternalIO.InternalAppendLog("Successfully load all OpenGL 4.5 APIs");
|
||||
}
|
||||
|
||||
internal static unsafe void LoadGLcore46(GLcontext* contextPtr, delegate*<string, IntPtr> load)
|
||||
internal static unsafe void LoadGLcore46(OpenglContext* contextPtr, delegate*<string, IntPtr> load)
|
||||
{
|
||||
if (!core46)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user