mirror of
				https://github.com/Ryujinx/Opentk.git
				synced 2025-11-04 12:44:57 +00:00 
			
		
		
		
	Addressed comments
This commit is contained in:
		
							parent
							
								
									8ffe3bc504
								
							
						
					
					
						commit
						70ac147b5c
					
				| 
						 | 
				
			
			@ -130,15 +130,15 @@ namespace OpenTK.Graphics
 | 
			
		|||
                    minor = 0;
 | 
			
		||||
 | 
			
		||||
                // Angle needs an embedded context
 | 
			
		||||
                var use_angle_flag = GraphicsContextFlags.Angle
 | 
			
		||||
                                | GraphicsContextFlags.AngleD3D9
 | 
			
		||||
                                | GraphicsContextFlags.AngleD3D11
 | 
			
		||||
                                | GraphicsContextFlags.AngleOpenGL;
 | 
			
		||||
                var use_angle = false;
 | 
			
		||||
                if ((flags & use_angle_flag) != 0)
 | 
			
		||||
                const GraphicsContextFlags useAngleFlag = GraphicsContextFlags.Angle
 | 
			
		||||
                                                          | GraphicsContextFlags.AngleD3D9
 | 
			
		||||
                                                          | GraphicsContextFlags.AngleD3D11
 | 
			
		||||
                                                          | GraphicsContextFlags.AngleOpenGL;
 | 
			
		||||
                var useAngle = false;
 | 
			
		||||
                if ((flags & useAngleFlag) != 0)
 | 
			
		||||
                {
 | 
			
		||||
                    flags |= GraphicsContextFlags.Embedded;
 | 
			
		||||
                    use_angle = true;
 | 
			
		||||
                    useAngle = true;
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                Debug.Print("Creating GraphicsContext.");
 | 
			
		||||
| 
						 | 
				
			
			@ -164,7 +164,7 @@ namespace OpenTK.Graphics
 | 
			
		|||
                                factory = Factory.Default;
 | 
			
		||||
                                break;
 | 
			
		||||
                            case true:
 | 
			
		||||
                                factory = use_angle ? Factory.Angle : Factory.Embedded;
 | 
			
		||||
                                factory = useAngle ? Factory.Angle : Factory.Embedded;
 | 
			
		||||
                                break;
 | 
			
		||||
                        }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -212,8 +212,7 @@ namespace OpenTK.Platform.Egl
 | 
			
		|||
        public static extern bool QuerySurfacePointerANGLE(EGLDisplay display, EGLSurface surface, int attribute, out IntPtr value);
 | 
			
		||||
 | 
			
		||||
        [DllImport("libEGL.dll", EntryPoint = "eglGetPlatformDisplayEXT")]
 | 
			
		||||
        public static extern EGLDisplay GetPlatformDisplay(int platform, EGLNativeDisplayType display_id,
 | 
			
		||||
            int[] attrib_list);
 | 
			
		||||
        public static extern EGLDisplay GetPlatformDisplay(int platform, EGLNativeDisplayType displayId, int[] attribList);
 | 
			
		||||
 | 
			
		||||
        // EGL_ANGLE_software_display
 | 
			
		||||
        public static readonly EGLNativeDisplayType SOFTWARE_DISPLAY_ANGLE = new EGLNativeDisplayType(-1);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -90,11 +90,11 @@ namespace OpenTK.Platform.Egl
 | 
			
		|||
 | 
			
		||||
            bool offscreen = (flags & GraphicsContextFlags.Offscreen) != 0;
 | 
			
		||||
 | 
			
		||||
            SurfaceType surface_type = offscreen 
 | 
			
		||||
            SurfaceType surfaceType = offscreen 
 | 
			
		||||
                ? SurfaceType.PBUFFER_BIT 
 | 
			
		||||
                : SurfaceType.WINDOW_BIT;
 | 
			
		||||
 | 
			
		||||
            Mode = new EglGraphicsMode().SelectGraphicsMode(surface_type,
 | 
			
		||||
            Mode = new EglGraphicsMode().SelectGraphicsMode(surfaceType,
 | 
			
		||||
                    window.Display, mode.ColorFormat, mode.Depth, mode.Stencil,
 | 
			
		||||
                    mode.Samples, mode.AccumulatorFormat, mode.Buffers, mode.Stereo,
 | 
			
		||||
                    Renderable);
 | 
			
		||||
| 
						 | 
				
			
			@ -115,9 +115,9 @@ namespace OpenTK.Platform.Egl
 | 
			
		|||
                }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            int[] attrib_list = new int[] { Egl.CONTEXT_CLIENT_VERSION, major, Egl.NONE };
 | 
			
		||||
            var share_context = shared != null ? shared.HandleAsEGLContext : IntPtr.Zero;
 | 
			
		||||
            HandleAsEGLContext = Egl.CreateContext(window.Display, config, share_context, attrib_list);
 | 
			
		||||
            int[] attribList = { Egl.CONTEXT_CLIENT_VERSION, major, Egl.NONE };
 | 
			
		||||
            var shareContext = shared?.HandleAsEGLContext ?? IntPtr.Zero;
 | 
			
		||||
            HandleAsEGLContext = Egl.CreateContext(window.Display, config, shareContext, attribList);
 | 
			
		||||
 | 
			
		||||
            GraphicsContextFlags = flags;
 | 
			
		||||
        }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -26,8 +26,6 @@
 | 
			
		|||
#endregion
 | 
			
		||||
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using OpenTK.Graphics;
 | 
			
		||||
 | 
			
		||||
namespace OpenTK.Platform.Egl
 | 
			
		||||
| 
						 | 
				
			
			@ -46,25 +44,24 @@ namespace OpenTK.Platform.Egl
 | 
			
		|||
        public GraphicsMode SelectGraphicsMode(EglWindowInfo window,
 | 
			
		||||
            ColorFormat color, int depth, int stencil,
 | 
			
		||||
            int samples, ColorFormat accum, int buffers, bool stereo,
 | 
			
		||||
            RenderableFlags renderable_flags)
 | 
			
		||||
            RenderableFlags renderableFlags)
 | 
			
		||||
        {
 | 
			
		||||
            return SelectGraphicsMode(
 | 
			
		||||
                SurfaceType.WINDOW_BIT, 
 | 
			
		||||
                window.Display,
 | 
			
		||||
                color, depth, stencil, samples, accum, buffers, stereo, renderable_flags
 | 
			
		||||
                );
 | 
			
		||||
                color, depth, stencil, samples, accum, buffers, stereo, renderableFlags);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public GraphicsMode SelectGraphicsMode(SurfaceType surface_type, 
 | 
			
		||||
        public GraphicsMode SelectGraphicsMode(SurfaceType surfaceType, 
 | 
			
		||||
            IntPtr display, ColorFormat color, int depth, int stencil,
 | 
			
		||||
            int samples, ColorFormat accum, int buffers, bool stereo,
 | 
			
		||||
            RenderableFlags renderable_flags)
 | 
			
		||||
            RenderableFlags renderableFlags)
 | 
			
		||||
        {
 | 
			
		||||
            IntPtr[] configs = new IntPtr[1];
 | 
			
		||||
            int[] attribList = new int[] 
 | 
			
		||||
            { 
 | 
			
		||||
                Egl.SURFACE_TYPE, (int) surface_type,
 | 
			
		||||
                Egl.RENDERABLE_TYPE, (int)renderable_flags,
 | 
			
		||||
                Egl.SURFACE_TYPE, (int) surfaceType,
 | 
			
		||||
                Egl.RENDERABLE_TYPE, (int)renderableFlags,
 | 
			
		||||
 | 
			
		||||
                Egl.RED_SIZE, color.Red, 
 | 
			
		||||
                Egl.GREEN_SIZE, color.Green, 
 | 
			
		||||
| 
						 | 
				
			
			@ -80,28 +77,27 @@ namespace OpenTK.Platform.Egl
 | 
			
		|||
                Egl.NONE,
 | 
			
		||||
            };
 | 
			
		||||
 | 
			
		||||
            int num_configs;
 | 
			
		||||
            if (!Egl.ChooseConfig(display, attribList, configs, configs.Length, out num_configs) || num_configs == 0)
 | 
			
		||||
            int numConfigs;
 | 
			
		||||
            if (!Egl.ChooseConfig(display, attribList, configs, configs.Length, out numConfigs) || numConfigs == 0)
 | 
			
		||||
            {
 | 
			
		||||
                throw new GraphicsModeException(String.Format("Failed to retrieve GraphicsMode, error {0}", Egl.GetError()));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            // See what we really got
 | 
			
		||||
            IntPtr active_config = configs[0];
 | 
			
		||||
            IntPtr activeConfig = configs[0];
 | 
			
		||||
            int r, g, b, a;
 | 
			
		||||
            Egl.GetConfigAttrib(display, active_config, Egl.RED_SIZE, out r);
 | 
			
		||||
            Egl.GetConfigAttrib(display, active_config, Egl.GREEN_SIZE, out g);
 | 
			
		||||
            Egl.GetConfigAttrib(display, active_config, Egl.BLUE_SIZE, out b);
 | 
			
		||||
            Egl.GetConfigAttrib(display, active_config, Egl.ALPHA_SIZE, out a);
 | 
			
		||||
            Egl.GetConfigAttrib(display, activeConfig, Egl.RED_SIZE, out r);
 | 
			
		||||
            Egl.GetConfigAttrib(display, activeConfig, Egl.GREEN_SIZE, out g);
 | 
			
		||||
            Egl.GetConfigAttrib(display, activeConfig, Egl.BLUE_SIZE, out b);
 | 
			
		||||
            Egl.GetConfigAttrib(display, activeConfig, Egl.ALPHA_SIZE, out a);
 | 
			
		||||
            int d, s;
 | 
			
		||||
            Egl.GetConfigAttrib(display, active_config, Egl.DEPTH_SIZE, out d);
 | 
			
		||||
            Egl.GetConfigAttrib(display, active_config, Egl.STENCIL_SIZE, out s);
 | 
			
		||||
            int sample_buffers;
 | 
			
		||||
            Egl.GetConfigAttrib(display, active_config, Egl.SAMPLES, out sample_buffers);
 | 
			
		||||
            Egl.GetConfigAttrib(display, active_config, Egl.SAMPLES, out samples);
 | 
			
		||||
            Egl.GetConfigAttrib(display, activeConfig, Egl.DEPTH_SIZE, out d);
 | 
			
		||||
            Egl.GetConfigAttrib(display, activeConfig, Egl.STENCIL_SIZE, out s);
 | 
			
		||||
            int sampleBuffers;
 | 
			
		||||
            Egl.GetConfigAttrib(display, activeConfig, Egl.SAMPLES, out sampleBuffers);
 | 
			
		||||
            Egl.GetConfigAttrib(display, activeConfig, Egl.SAMPLES, out samples);
 | 
			
		||||
 | 
			
		||||
            return new GraphicsMode(active_config, new ColorFormat(r, g, b, a), d, s, sample_buffers > 0 ? samples : 0, 0, 2, false);
 | 
			
		||||
            return new GraphicsMode(activeConfig, new ColorFormat(r, g, b, a), d, s, sampleBuffers > 0 ? samples : 0, 0, 2, false);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -64,8 +64,8 @@ namespace OpenTK.Platform.Egl
 | 
			
		|||
 | 
			
		||||
            Display = display;
 | 
			
		||||
 | 
			
		||||
            int dummy_major, dummy_minor;
 | 
			
		||||
            if (!Egl.Initialize(Display, out dummy_major, out dummy_minor))
 | 
			
		||||
            int dummyMajor, dummyMinor;
 | 
			
		||||
            if (!Egl.Initialize(Display, out dummyMajor, out dummyMinor))
 | 
			
		||||
            {
 | 
			
		||||
                throw new GraphicsContextException(String.Format("Failed to initialize EGL, error {0}.", Egl.GetError()));
 | 
			
		||||
            }
 | 
			
		||||
| 
						 | 
				
			
			@ -116,7 +116,7 @@ namespace OpenTK.Platform.Egl
 | 
			
		|||
            CreatePbufferSurface(config, width, height, out surface); 
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void CreatePbufferSurface(IntPtr config, int width, int height, out IntPtr surface_)
 | 
			
		||||
        public void CreatePbufferSurface(IntPtr config, int width, int height, out IntPtr bufferSurface)
 | 
			
		||||
        {
 | 
			
		||||
            int[] attribs = new int[]
 | 
			
		||||
            {
 | 
			
		||||
| 
						 | 
				
			
			@ -126,13 +126,12 @@ namespace OpenTK.Platform.Egl
 | 
			
		|||
                Egl.TEXTURE_FORMAT, Egl.TEXTURE_RGBA,
 | 
			
		||||
                Egl.NONE
 | 
			
		||||
            };
 | 
			
		||||
            surface_ = Egl.CreatePbufferSurface(Display, config, attribs);
 | 
			
		||||
            if (surface_ == IntPtr.Zero)
 | 
			
		||||
            bufferSurface = Egl.CreatePbufferSurface(Display, config, attribs);
 | 
			
		||||
            if (bufferSurface == IntPtr.Zero)
 | 
			
		||||
            {
 | 
			
		||||
                throw new GraphicsContextException(String.Format(
 | 
			
		||||
                    "[EGL] Failed to create pbuffer surface, error {0}.", Egl.GetError()));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void DestroySurface()
 | 
			
		||||
| 
						 | 
				
			
			@ -140,19 +139,20 @@ namespace OpenTK.Platform.Egl
 | 
			
		|||
            DestroySurface(ref surface);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void DestroySurface(ref IntPtr surface_)
 | 
			
		||||
        public void DestroySurface(ref IntPtr bufferSurface)
 | 
			
		||||
        {
 | 
			
		||||
            if (surface_ == IntPtr.Zero)
 | 
			
		||||
            if (bufferSurface == IntPtr.Zero)
 | 
			
		||||
            {
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (Egl.GetCurrentSurface(Egl.DRAW) == Surface)
 | 
			
		||||
                Egl.MakeCurrent(Display, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero);
 | 
			
		||||
                    
 | 
			
		||||
            if (Egl.DestroySurface(Display, surface_))
 | 
			
		||||
            {
 | 
			
		||||
                surface_ = IntPtr.Zero;
 | 
			
		||||
                Egl.MakeCurrent(Display, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero);
 | 
			
		||||
            }
 | 
			
		||||
            if (Egl.DestroySurface(Display, bufferSurface))
 | 
			
		||||
            {
 | 
			
		||||
                bufferSurface = IntPtr.Zero;
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
            
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -26,9 +26,7 @@
 | 
			
		|||
#endregion
 | 
			
		||||
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Diagnostics;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using OpenTK.Platform.Egl;
 | 
			
		||||
 | 
			
		||||
namespace OpenTK.Platform
 | 
			
		||||
| 
						 | 
				
			
			@ -40,8 +38,10 @@ namespace OpenTK.Platform
 | 
			
		|||
    {
 | 
			
		||||
        #region Fields
 | 
			
		||||
 | 
			
		||||
        bool disposed;
 | 
			
		||||
        static IPlatformFactory default_implementation, embedded_implementation, angle_implementation;
 | 
			
		||||
        private bool disposed;
 | 
			
		||||
        private static IPlatformFactory defaultImplementation;
 | 
			
		||||
        private static IPlatformFactory embeddedImplementation;
 | 
			
		||||
        private static IPlatformFactory angleImplementation;
 | 
			
		||||
 | 
			
		||||
        #endregion
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -122,20 +122,20 @@ namespace OpenTK.Platform
 | 
			
		|||
 | 
			
		||||
        public static IPlatformFactory Default
 | 
			
		||||
        {
 | 
			
		||||
            get { return default_implementation; }
 | 
			
		||||
            private set { default_implementation = value; }
 | 
			
		||||
            get { return defaultImplementation; }
 | 
			
		||||
            private set { defaultImplementation = value; }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public static IPlatformFactory Embedded
 | 
			
		||||
        {
 | 
			
		||||
            get { return embedded_implementation; }
 | 
			
		||||
            private set { embedded_implementation = value; }
 | 
			
		||||
            get { return embeddedImplementation; }
 | 
			
		||||
            private set { embeddedImplementation = value; }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public static IPlatformFactory Angle
 | 
			
		||||
        {
 | 
			
		||||
            get { return angle_implementation; }
 | 
			
		||||
            private set { angle_implementation = value; }
 | 
			
		||||
            get { return angleImplementation; }
 | 
			
		||||
            private set { angleImplementation = value; }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        #endregion
 | 
			
		||||
| 
						 | 
				
			
			@ -145,60 +145,60 @@ namespace OpenTK.Platform
 | 
			
		|||
        public INativeWindow CreateNativeWindow(int x, int y, int width, int height, string title,
 | 
			
		||||
            GraphicsMode mode, GameWindowFlags options, DisplayDevice device)
 | 
			
		||||
        {
 | 
			
		||||
            return default_implementation.CreateNativeWindow(x, y, width, height, title, mode, options, device);
 | 
			
		||||
            return defaultImplementation.CreateNativeWindow(x, y, width, height, title, mode, options, device);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public IDisplayDeviceDriver CreateDisplayDeviceDriver()
 | 
			
		||||
        {
 | 
			
		||||
            return default_implementation.CreateDisplayDeviceDriver();
 | 
			
		||||
            return defaultImplementation.CreateDisplayDeviceDriver();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public IGraphicsContext CreateGLContext(GraphicsMode mode, IWindowInfo window, IGraphicsContext shareContext, bool directRendering, int major, int minor, GraphicsContextFlags flags)
 | 
			
		||||
        {
 | 
			
		||||
            return default_implementation.CreateGLContext(mode, window, shareContext, directRendering, major, minor, flags);
 | 
			
		||||
            return defaultImplementation.CreateGLContext(mode, window, shareContext, directRendering, major, minor, flags);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public IGraphicsContext CreateGLContext(ContextHandle handle, IWindowInfo window, IGraphicsContext shareContext, bool directRendering, int major, int minor, GraphicsContextFlags flags)
 | 
			
		||||
        {
 | 
			
		||||
            return default_implementation.CreateGLContext(handle, window, shareContext, directRendering, major, minor, flags);
 | 
			
		||||
            return defaultImplementation.CreateGLContext(handle, window, shareContext, directRendering, major, minor, flags);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public GraphicsContext.GetCurrentContextDelegate CreateGetCurrentGraphicsContext()
 | 
			
		||||
        {
 | 
			
		||||
            return default_implementation.CreateGetCurrentGraphicsContext();
 | 
			
		||||
            return defaultImplementation.CreateGetCurrentGraphicsContext();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public IKeyboardDriver2 CreateKeyboardDriver()
 | 
			
		||||
        {
 | 
			
		||||
            return default_implementation.CreateKeyboardDriver();
 | 
			
		||||
            return defaultImplementation.CreateKeyboardDriver();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public IMouseDriver2 CreateMouseDriver()
 | 
			
		||||
        {
 | 
			
		||||
            return default_implementation.CreateMouseDriver();
 | 
			
		||||
            return defaultImplementation.CreateMouseDriver();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public IGamePadDriver CreateGamePadDriver()
 | 
			
		||||
        {
 | 
			
		||||
            return default_implementation.CreateGamePadDriver();
 | 
			
		||||
            return defaultImplementation.CreateGamePadDriver();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public IJoystickDriver2 CreateJoystickDriver()
 | 
			
		||||
        {
 | 
			
		||||
            return default_implementation.CreateJoystickDriver();
 | 
			
		||||
            return defaultImplementation.CreateJoystickDriver();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        [Obsolete]
 | 
			
		||||
        public IJoystickDriver CreateLegacyJoystickDriver()
 | 
			
		||||
        {
 | 
			
		||||
            #pragma warning disable 612,618
 | 
			
		||||
            return default_implementation.CreateLegacyJoystickDriver();
 | 
			
		||||
            return defaultImplementation.CreateLegacyJoystickDriver();
 | 
			
		||||
            #pragma warning restore 612,618
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void RegisterResource(IDisposable resource)
 | 
			
		||||
        {
 | 
			
		||||
            default_implementation.RegisterResource(resource);
 | 
			
		||||
            defaultImplementation.RegisterResource(resource);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        class UnsupportedPlatform : PlatformFactoryBase
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -401,11 +401,11 @@ namespace OpenTK.Platform
 | 
			
		|||
        /// supplied platform window (e.g. a window created with 
 | 
			
		||||
        /// CreateWindowsWindowInfo, or CreateDummyWindowInfo).
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="platform_window"></param>
 | 
			
		||||
        /// <param name="platformWindow"></param>
 | 
			
		||||
        /// <returns></returns>
 | 
			
		||||
        public static IAngleWindowInfo CreateAngleWindowInfo(IWindowInfo platform_window)
 | 
			
		||||
        public static IAngleWindowInfo CreateAngleWindowInfo(IWindowInfo platformWindow)
 | 
			
		||||
        {
 | 
			
		||||
            return new AngleWindowInfo(platform_window);
 | 
			
		||||
            return new AngleWindowInfo(platformWindow);
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        #endregion
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in a new issue