internal static void loadUniform4i() { try { glUniform4iPtr = (glUniform4iFunc)Marshal.GetDelegateForFunctionPointer(OpenGLInit.GetProcAddress("glUniform4i"), typeof(glUniform4iFunc)); } catch { Console.WriteLine("Failed to get function pointer for 'glUniform4i'."); } }
internal glContext(WGL.Context WGLContext) { _WGLContext = WGLContext; _WGLContext.MakeCurrent(); _notSupportedPtr = System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate((NotSupportedFunc)notSupported); glGetString = WGL.GetProcAddress <glGetStringFunc>("glGetString"); glGetIntegerv = WGL.GetProcAddress <glGetIntegervFunc>("glGetIntegerv"); glGetBooleanv = WGL.GetProcAddress <glGetBooleanvFunc>("glGetBooleanv"); glGetFloatv = WGL.GetProcAddress <glGetFloatvFunc>("glGetFloatv"); glGetDoublev = WGL.GetProcAddress <glGetDoublevFunc>("glGetDoublev"); if (glGetString == null || glGetIntegerv == null || glGetFloatv == null || glGetDoublev == null) { throw new Exception("OpenGL 1.0 is not supported"); } int major, minor; glGetIntegerv(GL_MAJOR_VERSION, &major); glGetIntegerv(GL_MINOR_VERSION, &minor); _Version = new Version(major, minor); _glEnable = WGL.GetProcAddress <glEnableFunc>("glEnable"); _glDisable = WGL.GetProcAddress <glDisableFunc>("glDisable"); _glBufferData = WGL.GetProcAddress <glBufferDataFunc>("glBufferData"); _glGenBuffers = WGL.GetProcAddress <glGenBuffersFunc>("glGenBuffers"); _glDeleteBuffers = WGL.GetProcAddress <glDeleteBuffersFunc>("glDeleteBuffers"); _glBindBuffer = WGL.GetProcAddress <glBindBufferFunc>("glBindBuffer"); _glClearDepth = WGL.GetProcAddress <glClearDepthFunc>("glClearDepth"); _glClearColor = WGL.GetProcAddress <glClearColorFunc>("glClearColor"); _glClear = WGL.GetProcAddress <glClearFunc>("glClear"); _glDepthFunc = WGL.GetProcAddress <glDepthFuncFunc>("glDepthFunc"); _glCreateShader = WGL.GetProcAddress <glCreateShaderFunc>("glCreateShader"); _glDeleteShader = WGL.GetProcAddress <glDeleteShaderFunc>("glDeleteShader"); _glShaderSource = WGL.GetProcAddress <glShaderSourceFunc>("glShaderSource"); _glCompileShader = WGL.GetProcAddress <glCompileShaderFunc>("glCompileShader"); _glGetShaderiv = WGL.GetProcAddress <glGetShaderivFunc>("glGetShaderiv"); _glGetShaderInfoLog = WGL.GetProcAddress <glGetShaderInfoLogFunc>("glGetShaderInfoLog"); _glCreateProgram = WGL.GetProcAddress <glCreateProgramFunc>("glCreateProgram"); _glDeleteProgram = WGL.GetProcAddress <glDeleteProgramFunc>("glDeleteProgram"); _glAttachShader = WGL.GetProcAddress <glAttachShaderFunc>("glAttachShader"); _glLinkProgram = WGL.GetProcAddress <glLinkProgramFunc>("glLinkProgram"); _glLinkProgram = WGL.GetProcAddress <glLinkProgramFunc>("glLinkProgram"); _glGetAttribLocation = WGL.GetProcAddress <glGetAttribLocationFunc>("glGetAttribLocation"); _glGetUniformLocation = WGL.GetProcAddress <glGetUniformLocationFunc>("glGetUniformLocation"); _glBindAttribLocation = WGL.GetProcAddress <glBindAttribLocationFunc>("glBindAttribLocation"); _glGetProgramInfoLog = WGL.GetProcAddress <glGetProgramInfoLogFunc>("glGetProgramInfoLog"); _glGetProgramiv = WGL.GetProcAddress <glGetProgramivFunc>("glGetProgramiv"); _glUseProgram = WGL.GetProcAddress <glUseProgramFunc>("glUseProgram"); _glUniform1f = WGL.GetProcAddress <glUniform1fFunc>("glUniform1f"); _glUniform2f = WGL.GetProcAddress <glUniform2fFunc>("glUniform2f"); _glUniform3f = WGL.GetProcAddress <glUniform3fFunc>("glUniform3f"); _glUniform4f = WGL.GetProcAddress <glUniform4fFunc>("glUniform4f"); _glUniform1i = WGL.GetProcAddress <glUniform1iFunc>("glUniform1i"); _glUniform2i = WGL.GetProcAddress <glUniform2iFunc>("glUniform2i"); _glUniform3i = WGL.GetProcAddress <glUniform3iFunc>("glUniform3i"); _glUniform4i = WGL.GetProcAddress <glUniform4iFunc>("glUniform4i"); _glUniformMatrix4fv = WGL.GetProcAddress <glUniformMatrix4fvFunc>("glUniformMatrix4fv"); _glGenTextures = WGL.GetProcAddress <glGenTexturesFunc>("glGenTextures"); _glDeleteTextures = WGL.GetProcAddress <glDeleteTexturesFunc>("glDeleteTextures"); _glBindTexture = WGL.GetProcAddress <glBindTextureFunc>("glBindTexture"); _glTexImage2D = WGL.GetProcAddress <glTexImage2DFunc>("glTexImage2D"); _glActiveTexture = WGL.GetProcAddress <glActiveTextureFunc>("glActiveTexture"); _glTexParameteri = WGL.GetProcAddress <glTexParameteriFunc>("glTexParameteri"); _glDrawElements = WGL.GetProcAddress <glDrawElementsFunc>("glDrawElements"); _glEnableVertexAttribArray = WGL.GetProcAddress <glEnableVertexAttribArrayFunc>("glEnableVertexAttribArray"); _glVertexAttribPointer = WGL.GetProcAddress <glVertexAttribPointerFunc>("glVertexAttribPointer"); _glDebugMessageCallback = WGL.GetProcAddress <glDebugMessageCallbackFunc>("glDebugMessageCallback"); _glViewport = WGL.GetProcAddress <glViewportFunc>("glViewport"); _glDrawBuffer = WGL.GetProcAddress <glDrawBufferFunc>("glDrawBuffer"); _glFlushFunc = WGL.GetProcAddress <glFlushFunc>("glFlush"); try { _glGenFramebuffers = WGL.GetProcAddress <glGenFramebuffersFunc>("glGenFramebuffers"); _glDeleteFramebuffers = WGL.GetProcAddress <glDeleteFramebuffersFunc>("glDeleteFramebuffers"); _glBindFramebuffer = WGL.GetProcAddress <glBindFramebufferFunc>("glBindFramebuffer"); _glFramebufferTexture = WGL.GetProcAddress <glFramebufferTextureFunc>("glFramebufferTexture"); _glDrawBuffers = WGL.GetProcAddress <glDrawBuffersFunc>("glDrawBuffers"); } catch { _glGenFramebuffers = CastDelegate <glGenFramebuffersFunc>(_notSupportedPtr); _glDeleteFramebuffers = CastDelegate <glDeleteFramebuffersFunc>(_notSupportedPtr); _glBindFramebuffer = CastDelegate <glBindFramebufferFunc>(_notSupportedPtr); _glFramebufferTexture = CastDelegate <glFramebufferTextureFunc>(_notSupportedPtr); } _glBlendFunc = WGL.GetProcAddress <glBlendFunc>("glBlendFunc"); _ActiveTextureUnit = new TextureUnitTracker(this); _TextureUnitTrackers.Add(_ActiveTextureUnitIndex, _ActiveTextureUnit); }