public override INativeWindow CreateNativeWindow(int x, int y, int width, int height, string title,
                                                  GraphicsMode mode,
                                                  GameWindowFlags options, DisplayDevice device)
 {
     return(_platform_factory.CreateNativeWindow(x, y, width, height, title,
                                                 mode, options, device));
 }
示例#2
0
        /// <summary>Constructs a new NativeWindow with the specified attributes.</summary>
        /// <param name="x">Horizontal screen space coordinate of the NativeWindow's origin.</param>
        /// <param name="y">Vertical screen space coordinate of the NativeWindow's origin.</param>
        /// <param name="width">The width of the NativeWindow in pixels.</param>
        /// <param name="height">The height of the NativeWindow in pixels.</param>
        /// <param name="title">The title of the NativeWindow.</param>
        /// <param name="options">GameWindow options specifying window appearance and behavior.</param>
        /// <param name="mode">The OpenTK.Graphics.GraphicsMode of the NativeWindow.</param>
        /// <param name="device">The OpenTK.Graphics.DisplayDevice to construct the NativeWindow in.</param>
        /// <exception cref="System.ArgumentOutOfRangeException">If width or height is less than 1.</exception>
        /// <exception cref="System.ArgumentNullException">If mode or device is null.</exception>
        public NativeWindow(int x, int y, int width, int height, string title, GameWindowFlags options, GraphicsMode mode, DisplayDevice device)
        {
            // TODO: Should a constraint be added for the position?
            if (width < 1)
            {
                throw new ArgumentOutOfRangeException("width", "Must be greater than zero.");
            }
            if (height < 1)
            {
                throw new ArgumentOutOfRangeException("height", "Must be greater than zero.");
            }
            if (mode == null)
            {
                throw new ArgumentNullException("mode");
            }

            this.options = options;
            this.device  = device;

            this.thread_id = System.Threading.Thread.CurrentThread.ManagedThreadId;

            IPlatformFactory factory = Factory.Default;

            implementation = factory.CreateNativeWindow(x, y, width, height, title, mode, options, this.device);
            factory.RegisterResource(this);

            if ((options & GameWindowFlags.Fullscreen) != 0)
            {
                if (this.device != null)
                {
                    this.device.ChangeResolution(width, height, mode.ColorFormat.BitsPerPixel, 0);
                }
                WindowState = WindowState.Fullscreen;
            }

            if ((options & GameWindowFlags.FixedWindow) != 0)
            {
                WindowBorder = WindowBorder.Fixed;
            }
        }
示例#3
0
 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));
 }
示例#4
0
        public static void Init()
        {
            ToolkitOptions optionsToolkit = new ToolkitOptions()
            {
                Backend = PlatformBackend.PreferNative //for eglSwapBuffers to SwapBuffers
            };

            Toolkit.Init(optionsToolkit);

            GraphicsContextFlags flags = GraphicsContextFlags.Embedded;
            int             width      = 854;                           //800;
            int             height     = 480;                           //600;
            GraphicsMode    mode       = GraphicsMode.Default;
            string          title      = "PlayStation Suite Simulator"; //"Simple ES 2.0";
            GameWindowFlags options    = GameWindowFlags.FixedWindow;   //GameWindowFlags.Default;
            DisplayDevice   device     = DisplayDevice.Default;
            int             major      = 2;
            int             minor      = 0;

            if (mode == null)
            {
                mode = GraphicsMode.Default;
            }
            if (device == null)
            {
                device = DisplayDevice.Default;
            }
            int x = (device != null ? device.Bounds.Left + (device.Bounds.Width - width) / 2 : 0);
            int y = (device != null ? device.Bounds.Top + (device.Bounds.Height - height) / 2 : 0);

            if (width < 1)
            {
                throw new ArgumentOutOfRangeException("width", "Must be greater than zero.");
            }
            if (height < 1)
            {
                throw new ArgumentOutOfRangeException("height", "Must be greater than zero.");
            }
            if (mode == null)
            {
                throw new ArgumentNullException("mode");
            }

            g_ctx.options = options;
            g_ctx.device  = device;

            IPlatformFactory factory = Factory.Default;

            g_ctx.implementation = factory.CreateNativeWindow(x, y, width, height, title, mode, options, g_ctx.device);
            factory.RegisterResource(g_ctx);

            if ((options & GameWindowFlags.Fullscreen) != 0)
            {
                if (g_ctx.device != null)
                {
                    g_ctx.device.ChangeResolution(width, height, mode.ColorFormat.BitsPerPixel, 0);
                }
                setWindowState(WindowState.Fullscreen);
            }

            if ((options & GameWindowFlags.FixedWindow) != 0)
            {
                setWindowBorder(WindowBorder.Fixed);
            }

            try
            {
                g_ctx.glContext = new GraphicsContext(mode == null ? GraphicsMode.Default : mode, getWindowInfo(), major, minor, flags);
                g_ctx.glContext.MakeCurrent(getWindowInfo());
                (g_ctx.glContext as IGraphicsContextInternal).LoadAll();

                setVSync(VSyncMode.On);
            }
            catch (Exception e)
            {
                Debug.Print(e.ToString());
                baseDispose();
                throw;
            }

            Run_1();
        }