Esempio n. 1
0
        void Dispose(bool fin)
        {
            if (renderingState == RenderingState.Disposed)
            {
                return;
            }

            manager.WindowDisposed(this);
            renderData.Dispose();

            if (!fin)
            {
                GC.SuppressFinalize(this);
                renderData = null;
                listener   = null;
                effects    = null;
                manager    = null;
            }

            Action <IWindow> t = onDisposing;

            if (t != null)
            {
                t(this);
            }
        }
        public virtual void Initialise(IWindowBackend windowBackend)
        {
            Context = CreateContext();

            MakeCurrent(Context);

            loadTKBindings();

            string version = GL.GetString(StringName.Version);
            string versionNumberSubstring = getVersionNumberSubstring(version);

            GLVersion = new Version(versionNumberSubstring);

            // As defined by https://www.khronos.org/registry/OpenGL-Refpages/es2.0/xhtml/glGetString.xml
            IsEmbedded           = version.Contains("OpenGL ES");
            GLWrapper.IsEmbedded = IsEmbedded;

            version = GL.GetString(StringName.ShadingLanguageVersion);

            if (!string.IsNullOrEmpty(version))
            {
                try
                {
                    GLSLVersion = new Version(versionNumberSubstring);
                }
                catch (Exception e)
                {
                    Logger.Error(e, $@"couldn't set GLSL version using string '{version}'");
                }
            }

            if (GLSLVersion == null)
            {
                GLSLVersion = new Version();
            }

            Logger.Log($@"GL Initialized
                        GL Version:                 {GL.GetString(StringName.Version)}
                        GL Renderer:                {GL.GetString(StringName.Renderer)}
                        GL Shader Language version: {GL.GetString(StringName.ShadingLanguageVersion)}
                        GL Vendor:                  {GL.GetString(StringName.Vendor)}
                        GL Extensions:              {GL.GetString(StringName.Extensions)}");

            // We need to release the context in this thread, since Windows locks it and prevents
            // the draw thread from taking it. macOS seems to gracefully ignore this.
            MakeCurrent(IntPtr.Zero);
        }
        internal static bool IsBackendCompatible(IWindowBackend backend, IWindowModel model)
        {
            if (backend == null)
            {
                return(false);
            }

            bool isCompatible = false;

            //Last registered system has higherpriority
            for (int i = sRegisteredSystems.Count - 1; i >= 0; --i)
            {
                if (sRegisteredSystems[i].ValidateBackendCompatibility(backend, model, ref isCompatible))
                {
                    return(isCompatible);
                }
            }

            return(true);
        }
Esempio n. 4
0
        public IWindow CreateWindow(Guid resourceId, string title, string windowGroup,
                                    IWindowBackend listener, WindowOptions options, Vector2i position,
                                    Vector2i size, Vector2i?minSize, Vector2i?maxSize, WindowState state,
                                    IWindow parentWindow, bool blockParentInput)
        {
            lock (syncRoot)
            {
                AssertNotDisposed();


                DefaultWindow window = new DefaultWindow(this, resourceId, title, windowGroup,
                                                         listener, options, position, size, minSize.GetValueOrDefault(new Vector2i(0, 0)),
                                                         maxSize.GetValueOrDefault(new Vector2i(int.MaxValue, int.MaxValue)), state,
                                                         parentWindow, blockParentInput);

                windows.Add(window);

                return(window);
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Constructor.
        /// </summary>
        public DefaultWindow(DefaultWindowManager manager, Guid resourceId, string title, string windowGroup,
                             IWindowBackend listener, WindowOptions options, Vector2i position, Vector2i size,
                             Vector2i minSize, Vector2i maxSize, WindowState windowState, IWindow parentWindow,
                             bool blockParentInput)
        {
            this.manager            = manager;
            this.renderDataId       = resourceId;
            this.title              = title;
            this.group              = windowGroup;
            this.listener           = listener;
            this.options            = options;
            this.position           = position;
            this.size               = size;
            this.minSize            = minSize;
            this.maxSize            = maxSize;
            this.windowState        = windowState;
            this.blockInputToParent = blockParentInput;
            this.parentWindow       = parentWindow;

            TypelessTexture texture = manager.Device.GetShared(resourceId);

            // We create texture view upon it.
            this.renderData = (texture as TypelessTexture2D).CreateTexture();
        }
Esempio n. 6
0
 protected virtual void OnDisable()
 {
     windowBackend = null;
 }
Esempio n. 7
0
 protected virtual void OnEnable()
 {
     windowBackend = EditorWindowBackendManager.GetBackend(this);
 }