Esempio n. 1
0
        static ContextManager()
        {
            Gl.Initialize();
            Glfw.Init();
            Glfw.DefaultWindowHints();

            Glfw.WindowHint(Glfw.ContextVersionMajor, 4);
            Glfw.WindowHint(Glfw.ContextVersionMinor, 1);
            Glfw.WindowHint(Glfw.OpenglProfile, Glfw.OpenglCoreProfile);
            Glfw.WindowHint(Glfw.OpenglForwardCompat, Glfw.True);
            Glfw.WindowHint(Glfw.Doublebuffer, Glfw.True);

            Glfw.WindowHint(Glfw.Visible, Glfw.False);

            DefaultContext = Glfw.CreateWindow(1, 1, "", IntPtr.Zero, IntPtr.Zero);
            if (DefaultContext == IntPtr.Zero)
            {
                throw new NullReferenceException("Default OpenGL context failed to initialize.");
            }

            SetActiveContext(DefaultContext);

            Glx.IsRequired = true;
            Gl.BindAPI(new KhronosVersion(4, 1, "gl"), new Gl.Extensions());
        }
Esempio n. 2
0
    private static void SetGlfwWindowHints()
    {
        _glfw.DefaultWindowHints();
        if (_useOpenGl)
        {
            _glfw.WindowHint(WindowHintContextApi.ContextCreationApi,
                             _automaticFallback || !_useEgl ? ContextApi.NativeContextApi : ContextApi.EglContextApi);
            _glfw.WindowHint(WindowHintClientApi.ClientApi, ClientApi.OpenGL);
            _glfw.WindowHint(WindowHintOpenGlProfile.OpenGlProfile, OpenGlProfile.Core);

            _glfw.WindowHint(WindowHintInt.ContextVersionMajor, 3);
            _glfw.WindowHint(WindowHintInt.ContextVersionMinor, 2);
        }
        else
        {
            _glfw.WindowHint(WindowHintContextApi.ContextCreationApi,
                             _automaticFallback || _useEgl ? ContextApi.EglContextApi : ContextApi.NativeContextApi);
            _glfw.WindowHint(WindowHintClientApi.ClientApi, ClientApi.OpenGLES);

            _glfw.WindowHint(WindowHintInt.ContextVersionMajor, _majOES);
            _glfw.WindowHint(WindowHintInt.ContextVersionMinor, 0);
        }

        _glfw.WindowHint(WindowHintInt.RedBits, 8);
        _glfw.WindowHint(WindowHintInt.GreenBits, 8);
        _glfw.WindowHint(WindowHintInt.BlueBits, 8);
        _glfw.WindowHint(WindowHintInt.DepthBits, 24);
        _glfw.WindowHint(WindowHintInt.StencilBits, 8);

        if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
        {
            // osx graphics switching
            _glfw.WindowHint((WindowHintBool)0x00023003, true);
        }
    }
Esempio n. 3
0
        /// <summary>
        /// Initialize this windows instance.
        /// </summary>
        public void Initialize()
        {
            // - Reset window hints
            Glfw.DefaultWindowHints();

            // - Let the user choose whenever show the window
            Glfw.WindowHint(Hint.ClientApi, 0);
            Glfw.WindowHint(Hint.Visible, false);

            // - Make the new window saving the GLFW pointer
            GLFWHAndle = Glfw.CreateWindow
                         (
                Size.Value.Width,
                Size.Value.Height,
                Title,
                Monitor.None,
                Window.None
                         );

            // - Manage events handlers
            Glfw.SetWindowSizeCallback(GLFWHAndle, pSizeCallback);

            // - Send initialization event
            Initialized?.Invoke(this, EventArgs.Empty);
        }