Esempio n. 1
0
 public void ResetBackBuffer(PresentationParameters presentationParameters,
                             Framework.Graphics.GraphicsAdapter adapter)
 {
     //if (UseFauxBackbuffer(presentationParameters, adapter.CurrentDisplayMode))
     //{
     //	if (Backbuffer is NullBackbuffer)
     //	{
     //		if (!supportsFauxBackbuffer)
     //		{
     //			throw new NoSuitableGraphicsDeviceException(
     //				"Your hardware does not support the faux-backbuffer!" +
     //				"\n\nKeep the window/backbuffer resolution the same."
     //			);
     //		}
     //		Backbuffer = new OpenGLBackbuffer(
     //			this,
     //			presentationParameters.BackBufferWidth,
     //			presentationParameters.BackBufferHeight,
     //			presentationParameters.DepthStencilFormat,
     //			presentationParameters.MultiSampleCount
     //		);
     //	}
     //	else
     //	{
     //		Backbuffer.ResetFramebuffer(
     //			presentationParameters
     //		);
     //	}
     //}
     //else
     //{
     //	if (Backbuffer is OpenGLBackbuffer)
     //	{
     //		(Backbuffer as OpenGLBackbuffer).Dispose();
     //		Backbuffer = new NullBackbuffer(
     //			presentationParameters.BackBufferWidth,
     //			presentationParameters.BackBufferHeight,
     //			windowDepthFormat
     //		);
     //	}
     //	else
     //	{
     //		Backbuffer.ResetFramebuffer(presentationParameters);
     //	}
     //}
 }
Esempio n. 2
0
        public static Framework.Graphics.GraphicsAdapter[] GetGraphicsAdapters()
        {
            if (_adapters != null)
            {
                return(_adapters);
            }

            _adapters = new Framework.Graphics.GraphicsAdapter[SDL.SDL_GetNumVideoDisplays()];
            for (int i = 0; i < _adapters.Length; i += 1)
            {
                List <DisplayMode> modes = new List <DisplayMode>();
                int numModes             = SDL.SDL_GetNumDisplayModes(i);
                for (int j = numModes - 1; j >= 0; j -= 1)
                {
                    SDL.SDL_GetDisplayMode(i, j, out var filler);

                    // Check for dupes caused by varying refresh rates.
                    bool dupe = false;
                    foreach (DisplayMode mode in modes)
                    {
                        if (filler.w == mode.Width && filler.h == mode.Height)
                        {
                            dupe = true;
                        }
                    }
                    if (!dupe)
                    {
                        modes.Add(
                            new DisplayMode(
                                filler.w,
                                filler.h,
                                SurfaceFormat.Color                                 // FIXME: Assumption!
                                )
                            );
                    }
                }

                _adapters[i] = new GraphicsAdapter(modes, $@"\\.\DISPLAY{(i + 1)}", SDL.SDL_GetDisplayName(i));
            }
            return(_adapters);
        }
Esempio n. 3
0
        public GraphicsDevice(PresentationParameters presentationParameters, Framework.Graphics.GraphicsAdapter adapter)
        {
            PresentationParameters = presentationParameters;
            Adapter = adapter;

            _glContext = SDL.SDL_GL_CreateContext(presentationParameters.DeviceWindowHandle);

            SDL.SDL_GL_GetAttribute(SDL.SDL_GLattr.SDL_GL_CONTEXT_PROFILE_MASK, out var flags);

            // Check for a possible Core context
            _useCoreProfile = IsSet(flags, (int)SDL.SDL_GLprofile.SDL_GL_CONTEXT_PROFILE_CORE);

            // UIKit needs special treatment for back buffer behavior
            var wmInfo = new SDL.SDL_SysWMinfo();

            SDL.SDL_VERSION(out wmInfo.version);
            SDL.SDL_GetWindowWMInfo(presentationParameters.DeviceWindowHandle, ref wmInfo);

            if (wmInfo.subsystem == SDL.SDL_SYSWM_TYPE.SDL_SYSWM_UIKIT)
            {
                _realBackbufferFBO = wmInfo.info.uikit.framebuffer;
                _realBackbufferRBO = wmInfo.info.uikit.colorbuffer;
            }
            else
            {
                _realBackbufferFBO = 0;
                _realBackbufferRBO = 0;
            }


            GL.LoadEntryPoints();

            string renderer = GL.GetString(GL.StringName.Renderer);
            string version  = GL.GetString(GL.StringName.Version);
            string vendor   = GL.GetString(GL.StringName.Vendor);
            string shadingLanguageVersion = GL.GetString(GL.StringName.ShadingLanguageVersion);
            var    extensions             = GL.GetString(GL.StringName.Extensions);
        }
Esempio n. 4
0
        public override void Reset(PresentationParameters presentationParameters,
                                   Framework.Graphics.GraphicsAdapter graphicsAdapter)
        {
            PresentationParameters =
                presentationParameters ?? throw new ArgumentNullException(nameof(presentationParameters));
            Adapter = graphicsAdapter;

            // Verify MSAA before we really start...
            //PresentationParameters.MultiSampleCount = Math.Min(
            //	MathHelper.ClosestMSAAPower(
            //		PresentationParameters.MultiSampleCount
            //	),
            //	GLDevice.MaxMultiSampleCount
            //);

            // We're about to reset, let the application know.
            OnDeviceResetting();

            /* FIXME: Why are we not doing this...? -flibit
             * lock (resourcesLock)
             * {
             *      foreach (WeakReference resource in resources)
             *      {
             *              object target = resource.Target;
             *              if (target != null)
             *              {
             *                      (target as GraphicsResource).GraphicsDeviceResetting();
             *              }
             *      }
             *
             *      // Remove references to resources that have been garbage collected.
             *      resources.RemoveAll(wr => !wr.IsAlive);
             * }
             */

            /* Reset the backbuffer first, before doing anything else.
             * The GLDevice needs to know what we're up to right away.
             * -flibit
             */
            ResetBackBuffer(PresentationParameters, Adapter);

            // The mouse needs to know this for faux-backbuffer mouse scaling.
            //Input.Mouse.INTERNAL_BackBufferWidth = PresentationParameters.BackBufferWidth;
            //Input.Mouse.INTERNAL_BackBufferHeight = PresentationParameters.BackBufferHeight;

            //// The Touch Panel needs this too, for the same reason.
            //Input.Touch.TouchPanel.DisplayWidth = PresentationParameters.BackBufferWidth;
            //Input.Touch.TouchPanel.DisplayHeight = PresentationParameters.BackBufferHeight;

            // Now, update the viewport
            Viewport = new Viewport(0, 0, PresentationParameters.BackBufferWidth,
                                    PresentationParameters.BackBufferHeight);

            // Update the scissor rectangle to our new default target size
            ScissorRectangle = new Rectangle(0, 0,
                                             PresentationParameters.BackBufferWidth,
                                             PresentationParameters.BackBufferHeight);

            // Finally, update the swap interval
            SetPresentationInterval(PresentationParameters.PresentationInterval);

            // We just reset, let the application know.
            OnDeviceReset();
        }