コード例 #1
0
            public OpenGLWindowGraphics(OpenGLWindowGraphicsAdapter adapter, Window window, bool vsync)
            {
                _adapter = adapter;
                _window  = window ?? throw new ArgumentNullException(nameof(window));
                _vsync   = vsync;

                // Run OpenGL thread
                StartThread();
            }
コード例 #2
0
        private static void InitializeGraphicsAdapter()
        {
            // Set GLFW hints to use OpenGL 3.2 core (forward compatible)
            // We are assuming OpenGL is the only implementation relevant here. Sorry Vulkan!
            // In the future if a Vulkan implementation is introduced to Heirloom, we will have to rewrite this
            // initialization procedure.
            Glfw.SetWindowCreationHint(WindowAttribute.ClientApi, (int)ClientApi.OpenGL);
            Glfw.SetWindowCreationHint(WindowAttribute.OpenGLProfile, (int)OpenGLProfile.Core);
            Glfw.SetWindowCreationHint(WindowAttribute.OpenGLForwardCompatibility, true);
            Glfw.SetWindowCreationHint(WindowAttribute.ContextVersionMajor, 3);
            Glfw.SetWindowCreationHint(WindowAttribute.ContextVersionMinor, 2);

            // Creates the "sharing window" that is permanently hidden to the user.
            // It is used to query window capabilities and assist with sharing OpenGL resources.
            // It is also used when shaders or other OpenGL resources that need to be created
            // on an OGL bound thread but do not have a clear context available to them.
            Glfw.SetWindowCreationHint(WindowAttribute.TransparentFramebuffer, true);
            Glfw.SetWindowCreationHint(WindowAttribute.Visible, false);
            ShareContext = Glfw.CreateWindow(256, 256, "GLFW Background Window");

            // Use share context temporarily to load the GL functions and construct the graphics adapter object...
            Glfw.MakeContextCurrent(ShareContext);
            {
                // Loads the GL functions via GLFW lookup
                GL.LoadFunctions(Glfw.GetProcAddress);

                // On the desktop we actually use GL 3.2, but the implementation is limited to GLES 3.0 features.
                // This is to help make a uniform implementation for supportd on mobile platforms. This however,
                // does allow the user to create incompatible shaders between platforms. As mobile is currently not
                // a supported project, this is not yet a concern.
                GraphicsAdapter = new OpenGLWindowGraphicsAdapter();
                GraphicsFactory = GraphicsAdapter as IWindowGraphicsFactory;
                GraphicsAdapter.Initialize();
            }
            Glfw.MakeContextCurrent(WindowHandle.None);

            // Reset default window creation hints
            Glfw.SetWindowCreationHint(WindowAttribute.FocusOnShow, true);
            Glfw.SetWindowCreationHint(WindowAttribute.Visible, true);
        }