예제 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ExampleWindow"/> class.
        /// </summary>
        /// <param name="width">The window width.</param>
        /// <param name="height">The window height.</param>
        /// <param name="updateRenderRate">The update and render rate.</param>
        public ExampleWindow(int width = 1024, int height = 1024, double updateRenderRate = 60)
        {
            gameWindow = new GameWindow
            {
                X          = 200,                     //DPI scaling screws everything up, so use some hacked values
                Y          = 50,
                ClientSize = new Size(width, height), //do not set extents in the constructor, because windows 10 with enabled scale != 100% scales our given sizes in the constructor of GameWindow
            };

            CreateIOCcontainer();

            RenderContext = new RenderContextGL();

            ProcessCommandLineArguments(ref updateRenderRate);

            gameWindow.TargetUpdateFrequency = updateRenderRate;
            gameWindow.TargetRenderFrequency = updateRenderRate;
            gameWindow.VSync = VSyncMode.On;
            //register callback for resizing of window
            gameWindow.Resize += GameWindow_Resize;
            //register callback for keyboard
            gameWindow.KeyDown += INativeWindowExtensions.DefaultExampleWindowKeyEvents;
            gameWindow.KeyDown += GameWindow_KeyDown;

            var contentLoader = new ContentLoader();

            beforeRenderingCallbacks.Add(contentLoader);
            ContentLoader = contentLoader;
        }
예제 #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ExampleWindow"/> class.
        /// </summary>
        /// <param name="width">The window width.</param>
        /// <param name="height">The window height.</param>
        /// <param name="updateRenderRate">The update and render rate.</param>
        /// <param name="samples">Anit-aliasing sample count</param>
        /// <param name="debug">Activate OpenGL debug mode (probably slower)</param>
        public ExampleWindow(int width = 1024, int height = 1024, double updateRenderRate = 60, int samples = 1, bool debug = false)
        {
            var graphicsMode = new GraphicsMode(new ColorFormat(8, 8, 8, 8), 24, 0, samples, ColorFormat.Empty, 2);

            gameWindow = new GameWindow(width, height, graphicsMode, Assembly.GetEntryAssembly().ManifestModule.Name
                                        , GameWindowFlags.Default, DisplayDevice.Default, 0, 0, debug ? GraphicsContextFlags.Debug : GraphicsContextFlags.Default)
            {
                X          = 200,                            //DPI scaling screws everything up, so use some hacked values
                Y          = 10,
                ClientSize = new OpenTK.Size(width, height), //do not set extents in the constructor, because windows 10 with enabled scale != 100% scales our given sizes in the constructor of GameWindow
            };

            Input = new Input(gameWindow);

            if (debug)
            {
                debugger = new DebuggerGL();
            }
            CreateIOCcontainer();

            RenderContext = new RenderContextGL();

            ProcessCommandLineArguments(ref updateRenderRate);

            gameWindow.TargetUpdateFrequency = updateRenderRate;
            gameWindow.TargetRenderFrequency = updateRenderRate;
            gameWindow.VSync = VSyncMode.On;
            //register callback for keyboard
            gameWindow.KeyDown += INativeWindowExtensions.DefaultExampleWindowKeyEvents;
            gameWindow.KeyDown += GameWindow_KeyDown;
            //register a callback for updating the game logic
            gameWindow.UpdateFrame += GameWindow_UpdateFrame;
            //registers a callback for drawing a frame
            gameWindow.RenderFrame += GameWindow_RenderFrame;
            //register callback for resizing of window
            gameWindow.Resize += GameWindow_Resize;

            var contentLoader = new ContentLoader();

            beforeRenderingCallbacks.Add(contentLoader);
            ContentLoader = contentLoader;
        }
예제 #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ExampleWindow"/> class.
        /// </summary>
        /// <param name="width">The window width.</param>
        /// <param name="height">The window height.</param>
        /// <param name="updateRenderRate">The update and render rate.</param>
        public ExampleWindow(int width = 1024, int height = 1024, double updateRenderRate = 60)
        {
            gameWindow = new GameWindow()
            {
                X          = 200,                     //DPI scaling screws everything up, so use some hacked values
                Y          = 10,
                ClientSize = new Size(width, height), //do not set extents in the constructor, because windows 10 with enabled scale != 100% scales our given sizes in the constructor of GameWindow
            };

            CreateIOCcontainer();

            RenderContext = new RenderContextGL();

            ProcessCommandLineArguments(ref updateRenderRate);

            gameWindow.TargetUpdateFrequency = updateRenderRate;
            gameWindow.TargetRenderFrequency = updateRenderRate;
            gameWindow.VSync = VSyncMode.On;
            gameWindow.Title = Assembly.GetEntryAssembly().ManifestModule.Name;
            //register callback for keyboard
            gameWindow.KeyDown += INativeWindowExtensions.DefaultExampleWindowKeyEvents;
            gameWindow.KeyDown += GameWindow_KeyDown;
            //register a callback for updating the game logic
            gameWindow.UpdateFrame += GameWindow_UpdateFrame;
            //registers a callback for drawing a frame
            gameWindow.RenderFrame += GameWindow_RenderFrame;
            //register callback for resizing of window
            gameWindow.Resize             += GameWindow_Resize;
            gameWindow.FocusedChanged     += GameWindow_FocusedChanged;
            gameWindow.WindowStateChanged += GameWindow_WindowStateChanged;

            var contentLoader = new ContentLoader();

            beforeRenderingCallbacks.Add(contentLoader);
            ContentLoader = contentLoader;
        }