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];
        }
Exemple #2
0
 public OpenGLIndexBufferTests()
 {
     _context = new OpenGLRenderContext(new TestWindow());
     _factory = new OpenGLResourceFactory();
 }
Exemple #3
0
 public OpenGLIndexBufferTests()
 {
     _context = TestData.CreateDefaultOpenGLRenderContext(TestData.CreateTestWindow());
     _factory = (OpenGLResourceFactory)_context.ResourceFactory;
 }