Exemplo n.º 1
0
        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();
        }
Exemplo n.º 2
0
 public DummyGLContext(ContextHandle handle, GraphicsContext.GetAddressDelegate loader)
     : this()
 {
     if (handle != ContextHandle.Zero)
     {
         Handle = handle;
     }
     Loader = loader;
     Mode = new GraphicsMode(new IntPtr(2), 32, 16, 0, 0, 0, 2, false);
 }
Exemplo n.º 3
0
 public DummyGLContext(ContextHandle handle, GraphicsContext.GetAddressDelegate loader)
     : this()
 {
     if (handle != ContextHandle.Zero)
     {
         Handle = handle;
     }
     Loader = loader;
     Mode   = new GraphicsMode(new IntPtr(2), 32, 16, 0, 0, 0, 2, false);
 }
Exemplo n.º 4
0
        public _GraphicsContext()
        {
            addaddrfunc = addaddrfunc ?? (GraphicsContext.GetAddressDelegate) typeof(Utilities).InvokePrivateStatic("CreateGetAddress");

            this.ctx = new GraphicsContext(new ContextHandle(), addaddrfunc, FrameFactory.getcurrentfunc);

            this.ctx.LoadAll();

            int major, minor;

            GL.GetInteger(GetPName.MajorVersion, out major);
            GL.GetInteger(GetPName.MinorVersion, out minor);

            Console.WriteLine("Major {0}\nMinor {1}", major, minor);

            Console.WriteLine($"Context-Handle {FrameFactory.getcurrentfunc()}");
        }
        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];
        }
Exemplo n.º 6
0
 internal static GraphicsContext.GetAddressDelegate CreateGetAddress()
 {
     GraphicsContext.GetAddressDelegate loader = null;
     if (Configuration.RunningOnWindows)
     {
         loader = Platform.Windows.Wgl.GetProcAddress;
     }
     else if (Configuration.RunningOnX11)
     {
         loader = Platform.X11.Glx.GetProcAddress;
     }
     else if (Configuration.RunningOnMacOS)
     {
         loader = Platform.MacOS.NS.GetAddress;
     }
     else
     {
         throw new PlatformNotSupportedException();
     }
     return(loader);
 }