#pragma warning restore CS8618 public static void Init(GL_Graphics graphics, ISystemOpenGL system) { bindings = new GL_Bindings(system); GetIntegerv((GLEnum)0x821B, out MajorVersion); GetIntegerv((GLEnum)0x821C, out MinorVersion); GetIntegerv((GLEnum)0x8CDF, out MaxColorAttachments); GetIntegerv((GLEnum)0x851C, out MaxCubeMapTextureSize); GetIntegerv((GLEnum)0x8824, out MaxDrawBuffers); GetIntegerv((GLEnum)0x80E9, out MaxElementIndices); GetIntegerv((GLEnum)0x80E8, out MaxElementVertices); GetIntegerv((GLEnum)0x84E8, out MaxRenderbufferSize); GetIntegerv((GLEnum)0x8D57, out MaxSamples); GetIntegerv((GLEnum)0x8872, out MaxTextureImageUnits); GetIntegerv((GLEnum)0x0D33, out MaxTextureSize); #if DEBUG if (bindings.glDebugMessageCallback != null) { Enable(GLEnum.DEBUG_OUTPUT); Enable(GLEnum.DEBUG_OUTPUT_SYNCHRONOUS); DebugMessageCallback(Marshal.GetFunctionPointerForDelegate(onErrorRef = new OnError((source, type, id, severity, length, message, userParam) => { string typeName; string severityName; string output = Marshal.PtrToStringAnsi(message, (int)length); switch (type) { case GLEnum.DEBUG_TYPE_ERROR: typeName = "ERROR"; break; case GLEnum.DEBUG_TYPE_DEPRECATED_BEHAVIOR: typeName = "DEPRECATED BEHAVIOR"; break; case GLEnum.DEBUG_TYPE_MARKER: typeName = "MARKER"; break; case GLEnum.DEBUG_TYPE_OTHER: typeName = "OTHER"; break; case GLEnum.DEBUG_TYPE_PERFORMANCE: typeName = "PEROFRMANCE"; break; case GLEnum.DEBUG_TYPE_POP_GROUP: typeName = "POP GROUP"; break; case GLEnum.DEBUG_TYPE_PORTABILITY: typeName = "PORTABILITY"; break; case GLEnum.DEBUG_TYPE_PUSH_GROUP: typeName = "PUSH GROUP"; break; default: case GLEnum.DEBUG_TYPE_UNDEFINED_BEHAVIOR: typeName = "UNDEFINED BEHAVIOR"; break; } switch (severity) { case GLEnum.DEBUG_SEVERITY_HIGH: severityName = "HIGH"; break; case GLEnum.DEBUG_SEVERITY_MEDIUM: severityName = "MEDIUM"; break; case GLEnum.DEBUG_SEVERITY_LOW: severityName = "LOW"; break; // skip notifications default: case GLEnum.DEBUG_SEVERITY_NOTIFICATION: return; } if (type == GLEnum.DEBUG_TYPE_ERROR) { throw new Exception(output); } Log.Warning(graphics.Name, $"{typeName}, {severityName}: {output}"); })), IntPtr.Zero); } #endif }
public GL_Bindings(ISystemOpenGL system) { this.system = system ?? throw new Exception("GL Module requires a System that implements ProcAddress"); CreateDelegate(ref glGetString, "glGetString"); CreateDelegate(ref glDebugMessageCallback, "glDebugMessageCallback"); CreateDelegate(ref glFlush, "glFlush"); CreateDelegate(ref glEnable, "glEnable"); CreateDelegate(ref glDisable, "glDisable"); CreateDelegate(ref glClear, "glClear"); CreateDelegate(ref glClearColor, "glClearColor"); CreateDelegate(ref glClearDepth, "glClearDepth"); CreateDelegate(ref glClearStencil, "glClearStencil"); CreateDelegate(ref glDepthMask, "glDepthMask"); CreateDelegate(ref glDepthFunc, "glDepthFunc"); CreateDelegate(ref glViewport, "glViewport"); CreateDelegate(ref glCullFace, "glCullFace"); CreateDelegate(ref glScissor, "glScissor"); CreateDelegate(ref glBlendEquation, "glBlendEquation"); CreateDelegate(ref glBlendEquationSeparate, "glBlendEquationSeparate"); CreateDelegate(ref glBlendFunc, "glBlendFunc"); CreateDelegate(ref glBlendFuncSeparate, "glBlendFuncSeparate"); CreateDelegate(ref glBlendColor, "glBlendColor"); CreateDelegate(ref glColorMask, "glColorMask"); CreateDelegate(ref glGetIntegerv, "glGetIntegerv"); CreateDelegate(ref glGenTextures, "glGenTextures"); CreateDelegate(ref glGenRenderbuffers, "glGenRenderbuffers"); CreateDelegate(ref glGenFramebuffers, "glGenFramebuffers"); CreateDelegate(ref glActiveTexture, "glActiveTexture"); CreateDelegate(ref glBindTexture, "glBindTexture"); CreateDelegate(ref glBindRenderbuffer, "glBindRenderbuffer"); CreateDelegate(ref glBindFramebuffer, "glBindFramebuffer"); CreateDelegate(ref glTexImage2D, "glTexImage2D"); CreateDelegate(ref glFramebufferRenderbuffer, "glFramebufferRenderbuffer"); CreateDelegate(ref glFramebufferTexture2D, "glFramebufferTexture2D"); CreateDelegate(ref glTexParameteri, "glTexParameteri"); CreateDelegate(ref glRenderbufferStorage, "glRenderbufferStorage"); CreateDelegate(ref glGetTexImage, "glGetTexImage"); CreateDelegate(ref glDrawElements, "glDrawElements"); CreateDelegate(ref glDrawElementsInstanced, "glDrawElementsInstanced"); CreateDelegate(ref glDeleteTextures, "glDeleteTextures"); CreateDelegate(ref glDeleteRenderbuffers, "glDeleteRenderbuffers"); CreateDelegate(ref glDeleteFramebuffers, "glDeleteFramebuffers"); CreateDelegate(ref glGenVertexArrays, "glGenVertexArrays"); CreateDelegate(ref glBindVertexArray, "glBindVertexArray"); CreateDelegate(ref glGenBuffers, "glGenBuffers"); CreateDelegate(ref glBindBuffer, "glBindBuffer"); CreateDelegate(ref glBufferData, "glBufferData"); CreateDelegate(ref glBufferSubData, "glBufferSubData"); CreateDelegate(ref glDeleteBuffers, "glDeleteBuffers"); CreateDelegate(ref glDeleteVertexArrays, "glDeleteVertexArrays"); CreateDelegate(ref glEnableVertexAttribArray, "glEnableVertexAttribArray"); CreateDelegate(ref glDisableVertexAttribArray, "glDisableVertexAttribArray"); CreateDelegate(ref glVertexAttribPointer, "glVertexAttribPointer"); CreateDelegate(ref glVertexAttribDivisor, "glVertexAttribDivisor"); CreateDelegate(ref glCreateShader, "glCreateShader"); CreateDelegate(ref glAttachShader, "glAttachShader"); CreateDelegate(ref glDetachShader, "glDetachShader"); CreateDelegate(ref glDeleteShader, "glDeleteShader"); CreateDelegate(ref glShaderSource, "glShaderSource"); CreateDelegate(ref glCompileShader, "glCompileShader"); CreateDelegate(ref glGetShaderiv, "glGetShaderiv"); CreateDelegate(ref glGetShaderInfoLog, "glGetShaderInfoLog"); CreateDelegate(ref glCreateProgram, "glCreateProgram"); CreateDelegate(ref glDeleteProgram, "glDeleteProgram"); CreateDelegate(ref glLinkProgram, "glLinkProgram"); CreateDelegate(ref glGetProgramiv, "glGetProgramiv"); CreateDelegate(ref glGetProgramInfoLog, "glGetProgramInfoLog"); CreateDelegate(ref glGetActiveUniform, "glGetActiveUniform"); CreateDelegate(ref glGetActiveAttrib, "glGetActiveAttrib"); CreateDelegate(ref glUseProgram, "glUseProgram"); CreateDelegate(ref glGetUniformLocation, "glGetUniformLocation"); CreateDelegate(ref glGetAttribLocation, "glGetAttribLocation"); CreateDelegate(ref glUniform1f, "glUniform1f"); CreateDelegate(ref glUniform2f, "glUniform2f"); CreateDelegate(ref glUniform3f, "glUniform3f"); CreateDelegate(ref glUniform4f, "glUniform4f"); CreateDelegate(ref glUniform1fv, "glUniform1fv"); CreateDelegate(ref glUniform2fv, "glUniform2fv"); CreateDelegate(ref glUniform3fv, "glUniform3fv"); CreateDelegate(ref glUniform4fv, "glUniform4fv"); CreateDelegate(ref glUniform1i, "glUniform1i"); CreateDelegate(ref glUniform2i, "glUniform2i"); CreateDelegate(ref glUniform3i, "glUniform3i"); CreateDelegate(ref glUniform4i, "glUniform4i"); CreateDelegate(ref glUniform1iv, "glUniform1iv"); CreateDelegate(ref glUniform2iv, "glUniform2iv"); CreateDelegate(ref glUniform3iv, "glUniform3iv"); CreateDelegate(ref glUniform4iv, "glUniform4iv"); CreateDelegate(ref glUniform1ui, "glUniform1ui"); CreateDelegate(ref glUniform2ui, "glUniform2ui"); CreateDelegate(ref glUniform3ui, "glUniform3ui"); CreateDelegate(ref glUniform4ui, "glUniform4ui"); CreateDelegate(ref glUniform1uiv, "glUniform1uiv"); CreateDelegate(ref glUniform2uiv, "glUniform2uiv"); CreateDelegate(ref glUniform3uiv, "glUniform3uiv"); CreateDelegate(ref glUniform4uiv, "glUniform4uiv"); CreateDelegate(ref glUniformMatrix2fv, "glUniformMatrix2fv"); CreateDelegate(ref glUniformMatrix3fv, "glUniformMatrix3fv"); CreateDelegate(ref glUniformMatrix4fv, "glUniformMatrix4fv"); CreateDelegate(ref glUniformMatrix2x3fv, "glUniformMatrix2x3fv"); CreateDelegate(ref glUniformMatrix3x2fv, "glUniformMatrix3x2fv"); CreateDelegate(ref glUniformMatrix2x4fv, "glUniformMatrix2x4fv"); CreateDelegate(ref glUniformMatrix4x2fv, "glUniformMatrix4x2fv"); CreateDelegate(ref glUniformMatrix3x4fv, "glUniformMatrix3x4fv"); CreateDelegate(ref glUniformMatrix4x3fv, "glUniformMatrix4x3fv"); }