public OpenGLESRenderContext(Window window, OpenGLPlatformContextInfo platformContext) { ResourceFactory = new OpenGLESResourceFactory(); RenderCapabilities = new RenderCapabilities(false, false); _swapBufferFunc = platformContext.SwapBuffer; GraphicsContext.GetAddressDelegate getAddressFunc = s => platformContext.GetProcAddress(s); GraphicsContext.GetCurrentContextDelegate getCurrentContextFunc = () => new ContextHandle(platformContext.GetCurrentContext()); _openGLGraphicsContext = new GraphicsContext(new ContextHandle(platformContext.ContextHandle), getAddressFunc, getCurrentContextFunc); _openGLGraphicsContext.LoadAll(); _defaultFramebuffer = new OpenGLESDefaultFramebuffer(window.Width, window.Height); OnWindowResized(window.Width, window.Height); _textureSamplerManager = new OpenGLESTextureSamplerManager(); _maxConstantBufferSlots = GL.GetInteger(GetPName.MaxUniformBufferBindings); Utilities.CheckLastGLES3Error(); _constantBuffersBySlot = new OpenGLESConstantBuffer[_maxConstantBufferSlots]; _newConstantBuffersBySlot = new OpenGLESConstantBuffer[_maxConstantBufferSlots]; SetInitialStates(); PostContextCreated(); }
public OpenGLRenderContext(Window window, OpenGLPlatformContextInfo platformContext) { _resourceFactory = new OpenGLResourceFactory(); RenderCapabilities = new RenderCapabilities(true, true); _swapBufferFunc = platformContext.SwapBuffer; GraphicsContext.GetAddressDelegate getAddressFunc = s => platformContext.GetProcAddress(s); GraphicsContext.GetCurrentContextDelegate getCurrentContextFunc = () => new ContextHandle(platformContext.GetCurrentContext()); _openGLGraphicsContext = new GraphicsContext(new ContextHandle(platformContext.ContextHandle), getAddressFunc, getCurrentContextFunc); _openGLGraphicsContext.LoadAll(); // NOTE: I am binding a single VAO globally. _vertexArrayID = GL.GenVertexArray(); GL.BindVertexArray(_vertexArrayID); _defaultFramebuffer = new OpenGLDefaultFramebuffer(window.Width, window.Height); OnWindowResized(window.Width, window.Height); SetInitialStates(); PostContextCreated(); int extensionCount = GL.GetInteger(GetPName.NumExtensions); HashSet <string> extensions = new HashSet <string>(); for (int i = 0; i < extensionCount; i++) { extensions.Add(GL.GetString(StringNameIndexed.Extensions, i)); } _extensions = new OpenGLExtensions(extensions); _textureSamplerManager = new OpenGLTextureSamplerManager(_extensions); _maxConstantBufferSlots = GL.GetInteger(GetPName.MaxUniformBufferBindings); _constantBuffersBySlot = new OpenGLConstantBuffer[_maxConstantBufferSlots]; _newConstantBuffersBySlot = new OpenGLConstantBuffer[_maxConstantBufferSlots]; _maxTextureUnits = GL.GetInteger(GetPName.MaxTextureImageUnits); _maxVertexAttributeSlots = GL.GetInteger(GetPName.MaxVertexAttribs); _vertexAttribDivisors = new int[_maxVertexAttributeSlots]; }