コード例 #1
0
ファイル: Test3.cs プロジェクト: ASPePeX/OpenTKTest
        static void Main()
        {
            var mode = new GraphicsMode(new ColorFormat(8, 8, 8, 8), 24, 0, 0, ColorFormat.Empty, 1);
            var win  = new OpenTK.GameWindow(640, 480, mode, "", OpenTK.GameWindowFlags.Default, OpenTK.DisplayDevice.Default, 3, 0, GraphicsContextFlags.Default);

            win.Visible = false;
            win.MakeCurrent();
            /* START OF YOUR ACTUAL GL CODE */
            GL.ClearColor(0.6f, 1f, 0.6f, 1.0f);
            GL.Clear(ClearBufferMask.ColorBufferBit);
            /* END OF YOUR ACTUAL GL CODE */
            GL.Flush();
            using (var bmp = new Bitmap(640, 480, SDPixelFormat.Format32bppArgb))
            {
                var mem = bmp.LockBits(new Rectangle(0, 0, 640, 480), ImageLockMode.WriteOnly, SDPixelFormat.Format32bppArgb);
                GL.PixelStore(PixelStoreParameter.PackRowLength, mem.Stride / 4);
                GL.ReadPixels(0, 0, 640, 480, PixelFormat.Bgra, PixelType.UnsignedByte, mem.Scan0);
                bmp.UnlockBits(mem);
                bmp.Save(@"Test3.png", ImageFormat.Png);
            }

            string refimg = Path.Combine(Directory.GetCurrentDirectory(), "Test3", "Reference.png");
            string tesimg = Path.Combine(Directory.GetCurrentDirectory(), "Test3.png");

            Helper.CompareTestImages(refimg, tesimg);
        }
コード例 #2
0
ファイル: MonoGame.cs プロジェクト: slagusev/whiskey2d
        protected override void Initialize()
        {
            this.graphics.PreferredBackBufferWidth  = 1280;
            this.graphics.PreferredBackBufferHeight = 720;
            //this.graphics.IsFullScreen = true;

            Type type = typeof(OpenTKGameWindow);

            System.Reflection.FieldInfo field  = type.GetField("window", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
            OpenTK.GameWindow           window = (OpenTK.GameWindow)field.GetValue(this.Window);
            window.X = 50;
            window.Y = 50;
            this.graphics.ApplyChanges();

            gameMan = GameManager.Instance;

            if (gameMan.IsFullScreen)
            {
                graphics.IsFullScreen = true;
            }

            gameMan.Initialize(this, Content, GraphicsDevice,
                               new DefaultInputManager(),
                               new DefaultInputSourceManager(),
                               DefaultLogManager.Instance,
                               new DefaultObjectManager(),
                               new DefaultRenderManager(),
                               DefaultResourceManager.Instance
                               );
            base.Initialize();
        }
コード例 #3
0
        internal override void Initialize(GameContext gameContext)
        {
            this.GameContext = gameContext;

            gameForm     = (OpenTK.GameWindow)gameContext.Control;
            nativeWindow = new WindowHandle(AppContextType.DesktopOpenTK, gameForm);

            // Setup the initial size of the window
            var width = gameContext.RequestedWidth;

            if (width == 0)
            {
                width = gameForm.Width;
            }

            var height = gameContext.RequestedHeight;

            if (height == 0)
            {
                height = gameForm.Height;
            }

            gameForm.ClientSize = new System.Drawing.Size(width, height);

            gameForm.MouseEnter += GameWindowForm_MouseEnter;
            gameForm.MouseLeave += GameWindowForm_MouseLeave;

            gameForm.Resize += OnClientSizeChanged;
        }
コード例 #4
0
        internal static void setWindows(OpenTK.GameWindow window)
        {
            Window = window;

            _mouse       = window.Mouse;
            _mouse.Move += HandleWindowMouseMove;
        }
コード例 #5
0
        public void Connect(
            CurveTool.CurveTool     curveTool,
            IDRenderer              idRenderer,
            LineRenderer            lineRenderer,
            ManipulatorManager      manipulatorManager,
            Operations              operations,
            PhysicsDrag             physicsDrag,
            IRenderer               renderer,
            SceneManager            sceneManager,
            Sounds                  sounds,
            UserInterfaceManager    userInterfaceManager,
            OpenTK.GameWindow       window
        )
        {
            this.curveTool = curveTool;
            this.idRenderer = idRenderer;
            this.lineRenderer = lineRenderer;
            this.manipulatorManager = manipulatorManager;
            this.operations = operations;
            this.physicsDrag = physicsDrag;
            this.renderer = renderer;
            this.sceneManager = sceneManager;
            this.sounds = sounds;
            this.userInterfaceManager = userInterfaceManager;
            this.window = window;

            InitializationDependsOn(manipulatorManager);
        }
コード例 #6
0
        public void Initialize(OpenTK.GameWindow window)
        {
            if (this.isInitialized)
            {
                Error("Trying to double intialize graphics manager!");
            }

            GL.MatrixMode(MatrixMode.Modelview);
            GL.LoadIdentity();
            this.lastClear = Color.CadetBlue;
            this.game      = window;

            GL.Enable(EnableCap.Texture2D);
            GL.BindTexture(TextureTarget.Texture2D, 0);
            GL.Enable(EnableCap.Blend);
            GL.Enable(EnableCap.DepthTest);
            GL.ClearColor(Color.CadetBlue);

            this.fontHandle = GetFontTexture();

            this.isInitialized = true;

            SetScreenSize(this.game.ClientSize.Width, this.game.ClientSize.Height);

            this.game.Load += (sender, e) => {
                this.game.VSync = OpenTK.VSyncMode.On;
            };

            this.game.Resize += (sender, e) => {
                SetScreenSize(this.game.ClientSize.Width, this.game.ClientSize.Height);
            };
        }
コード例 #7
0
ファイル: Game.cs プロジェクト: Mszauer/TileBasedGames
 public void Initialize(OpenTK.GameWindow window)
 {
     this.window = window;
     TextureManager.Instance.UseNearestFiltering = true;
     map = GenerateMap(mapLayout, spriteSheet, spriteSources);
     window.ClientSize = new Size(mapLayout[0].Length * 30, mapLayout.Length * 30);
 }
コード例 #8
0
ファイル: Program.cs プロジェクト: NullandKale/OpenTKTests
        static void Main(string[] args)
        {
            OpenTK.GameWindow window = new OpenTK.GameWindow(1600, 900, new OpenTK.Graphics.GraphicsMode(32, 8, 0, 0));
            Game game = new Game(window);

            window.Run(1.0 / 60.0);
        }
コード例 #9
0
        void window_Resize(object sender, System.EventArgs e)
        {
            OpenTK.GameWindow window = (OpenTK.GameWindow)(sender);

            viewport.Width  = window.Width;
            viewport.Height = window.Height;
        }
コード例 #10
0
        static GraphicsDevice()
        {
            OpenTK.Toolkit.Init(new OpenTK.ToolkitOptions()
            {
                Backend = OpenTK.PlatformBackend.Default
            });
            GraphicsContextFlags flags = GraphicsContextFlags.Default;

#if !DEBUG
            flags |= GraphicsContextFlags.NoError; //Disable error checking
#else
            flags |= GraphicsContextFlags.Debug;
#endif
            Window = new GameWindow(1024, 1024, GraphicsMode.Default, "Game Window", OpenTK.GameWindowFlags.Default, OpenTK.DisplayDevice.Default, 0, 0, flags | GraphicsContextFlags.ForwardCompatible);

            Window.Resize      += Window_Resize;
            Window.Load        += Game_Load;
            Window.RenderFrame += InitRender;
            Window.UpdateFrame += Game_UpdateFrame;

            GameLoop      = new StateGroup();
            Cleanup       = new WeakAction();
            DeletionQueue = new ConcurrentQueue <Tuple <int, GLObjectType> >();

            curProg = null;
        }
コード例 #11
0
ファイル: GameWindowOpenTK.cs プロジェクト: joewan/xenko
        internal override void Initialize(GameContext gameContext)
        {
            this.GameContext = gameContext;

            gameForm = (OpenTK.GameWindow)gameContext.Control;
            nativeWindow = new WindowHandle(AppContextType.DesktopOpenTK, gameForm);

            // Setup the initial size of the window
            var width = gameContext.RequestedWidth;
            if (width == 0)
            {
                width = gameForm.Width;
            }

            var height = gameContext.RequestedHeight;
            if (height == 0)
            {
                height = gameForm.Height;
            }

            gameForm.ClientSize = new System.Drawing.Size(width, height);

            gameForm.MouseEnter += GameWindowForm_MouseEnter;
            gameForm.MouseLeave += GameWindowForm_MouseLeave;

            gameForm.Resize += OnClientSizeChanged;
        }
コード例 #12
0
 public static IFramebuffer Create(OpenTK.GameWindow window)
 {
     if (Configuration.useGl1)
     {
         return(new FramebufferGL1(window));
     }
     return(new FramebufferGL3(window));
 }
コード例 #13
0
ファイル: Program.cs プロジェクト: IvarsProjects/Projects
        static void Main(string[] args)
        {
            OpenTK.GameWindow window = new OpenTK.GameWindow(800, 600);

            Game game = new Game(window);

            window.Run(1.0 / 60.0);
        }
コード例 #14
0
 internal static void UpdateWindow(OpenTK.GameWindow window)
 {
     Mouse.window       = window;
     window.MouseWheel += delegate(object sender, OpenTK.Input.MouseWheelEventArgs e)
     {
         deltaPrecise -= (e.DeltaPrecise);
     };
 }
コード例 #15
0
ファイル: Program.cs プロジェクト: zerot13/GameSandBox
        static void Main(string[] args)
        {
            OpenTK.GameWindow baseWindow = new OpenTK.GameWindow(800, 600, new OpenTK.Graphics.GraphicsMode(32, 8, 0, 0));

            Game game = new Game(baseWindow, 3, 3, 2);

            baseWindow.Run();
        }
コード例 #16
0
ファイル: Window.cs プロジェクト: Daramkun/ProjectLiqueur
 public Window()
 {
     window = new OpenTK.GameWindow ( 800, 600,
         new OpenTK.Graphics.GraphicsMode ( new OpenTK.Graphics.ColorFormat ( 32 ), 16, 8 ),
         "Project Liqueur", OpenTK.GameWindowFlags.Default, OpenTK.DisplayDevice.Default );
     window.ClientSize = new System.Drawing.Size ( 800, 600 );
     window.WindowBorder = OpenTK.WindowBorder.Fixed;
 }
コード例 #17
0
 private void AddImagesFromAllTextureContainers()
 {
     // Reuse the same context to avoid CPU bottlenecks.
     using (OpenTK.GameWindow window = Rendering.OpenTkSharedResources.CreateGameWindowContext(imageWidth, imageHeight))
     {
         RenderTexturesAddToImageList();
     }
 }
コード例 #18
0
ファイル: Program.cs プロジェクト: IvarsProjects/Projects
        static void Main(string[] args)
        {
            OpenTK.GameWindow window = new OpenTK.GameWindow(800, 600);

            Game game = new Game(window);

            window.Run(1.0 / 60.0);
        }
コード例 #19
0
ファイル: Game.cs プロジェクト: Mszauer/TileBasedGames
 public void Initialize(OpenTK.GameWindow window)
 {
     Window = window;
     window.ClientSize = new Size(mapLayout[0].Length * 30, mapLayout.Length * 30);
     TextureManager.Instance.UseNearestFiltering = true;
     map = GenerateMap(mapLayout, spriteSheets, spriteSources);
     hero = new PlayerCharacter(heroSheet, new Point(spawnTile.X * 30, spawnTile.Y * 30));
 }
コード例 #20
0
        public void BufferAntialiasing()
        {
            var window = new OpenTK.GameWindow(graphics.PreferredBackBufferWidth,
                                               graphics.PreferredBackBufferHeight, new OpenTK.Graphics.GraphicsMode(32, 0, 0, MultisampleCount));

            window.Exit();
            window.Dispose();
        }
コード例 #21
0
        public static void Main()
        {
            //Prevent multiple instances from running
            if (Process.GetProcessesByName(Process.GetCurrentProcess().ProcessName).Length > 1)
            {
                System.Windows.Forms.MessageBox.Show("MP Tanks is already open.", "Already running.");
                Logger.Fatal("Already open!");
                return; //Close
            }

            AppDomain.CurrentDomain.UnhandledException   += CurrentDomain_UnhandledException;
            AppDomain.CurrentDomain.FirstChanceException += CurrentDomain_FirstChanceException;

            try
            {
                ClientSettings.Instance.GetAllSettings();
            }
            catch (Exception)
            {
            }
            Logger.Info("Initialized.");
            Logger.Info($".NET Runtime version {Environment.Version} on {Environment.OSVersion} " +
                        (Environment.Is64BitOperatingSystem ? "(64-bit)" : "(32-bit)"));
            Logger.Info($"Process is running in " + (Environment.Is64BitProcess ? "64-bit" : "32-bit") + " mode.");
            Logger.Info($"Number of CPUs: {Environment.ProcessorCount}");
            Logger.Info($"Executed as: {Environment.CommandLine}");
            Logger.Info($"Executing in directory {Environment.CurrentDirectory}");

            try
            {
                var window = new OpenTK.GameWindow();
                window.Visible = false;
                window.ProcessEvents();
                Logger.Info("---GPU INFO---");
                Logger.Info("Extensions: " + OpenTK.Graphics.OpenGL.GL.GetString(OpenTK.Graphics.OpenGL.StringName.Extensions));
                Logger.Info("GLSL Version: " + OpenTK.Graphics.OpenGL.GL.GetString(OpenTK.Graphics.OpenGL.StringName.ShadingLanguageVersion));
                Logger.Info("GPU: " + OpenTK.Graphics.OpenGL.GL.GetString(OpenTK.Graphics.OpenGL.StringName.Vendor) + " "
                            + OpenTK.Graphics.OpenGL.GL.GetString(OpenTK.Graphics.OpenGL.StringName.Renderer));
                Logger.Info("GL Version: " + OpenTK.Graphics.OpenGL.GL.GetString(OpenTK.Graphics.OpenGL.StringName.Version));
                window.Close();
                window.Dispose();
            }
            catch
            {
                Logger.Error("GPU does not support OpenGL or OpenTK could not create GL game window");
            }

            try
            {
                using (var gm = new ClientCore())
                    gm.Run();
            }
            catch (PlatformNotSupportedException)
            {
                System.Windows.Forms.MessageBox.Show("Your computer does not meet the minimum requirements for MP Tanks. Check that up-to-date graphics drivers are installed.",
                                                     "Below requirements", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
            }
        }
コード例 #22
0
ファイル: Form1.cs プロジェクト: wach78/Turbofest
 /// <summary>
 /// 
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void button1_Click(object sender, EventArgs e)
 {
     OpenTK.DisplayDevice dev = OpenTK.DisplayDevice.Default;
     OpenTK.GameWindow asd2 = new OpenTK.GameWindow(1024,768, OpenTK.Graphics.GraphicsMode.Default, "Project X", OpenTK.GameWindowFlags.Default, dev, 3, 0, OpenTK.Graphics.GraphicsContextFlags.Debug);
     //asd2.Run();
     CrashHandler ch = new CrashHandler();
     GLWindow asd3 = new GLWindow(null, "", null, null,ref ch);
     asd3.Run();
 }
コード例 #23
0
 private void AddTextureThumbnails(ImageList imageList)
 {
     // Reuse the same context to avoid CPU bottlenecks.
     using (OpenTK.GameWindow gameWindow = OpenTKSharedResources.CreateGameWindowContext(64, 64))
     {
         NUD.Material mat = currentMaterialList[currentMatIndex];
         RenderMaterialTexturesAddToImageList(imageList, mat);
     }
 }
コード例 #24
0
 public static void SetPosition(this GameWindow window, Point position)
 {
     OpenTK.GameWindow OTKWindow = GetForm(window);
     if (OTKWindow != null)
     {
         OTKWindow.X = position.X;
         OTKWindow.Y = position.Y;
     }
 }
コード例 #25
0
ファイル: Input.cs プロジェクト: tksuoran/renderstack_net
 public void InstallInputEventHandlers()
 {
     OpenTK.GameWindow window = this;
     window.Keyboard.KeyDown += new EventHandler <KeyboardKeyEventArgs>(Keyboard_KeyDown);
     window.Mouse.ButtonDown += new EventHandler <MouseButtonEventArgs>(Mouse_ButtonDown);
     window.Mouse.ButtonUp   += new EventHandler <MouseButtonEventArgs>(Mouse_ButtonUp);
     window.Mouse.Move       += new EventHandler <MouseMoveEventArgs>(Mouse_Move);
     window.MouseLeave       += new EventHandler <EventArgs>(Mouse_MouseLeave);
 }
コード例 #26
0
 public void Connect(
     Renderer.IRenderer renderer,
     TextRenderer textRenderer,
     OpenTK.GameWindow window
     )
 {
     this.renderer     = renderer;
     this.textRenderer = textRenderer;
     this.window       = window;
 }
コード例 #27
0
 public void Initialize(OpenTK.GameWindow window)
 {
     if (isInitialized)
     {
         Error("Trying to double initialize sound manager!");
     }
     context       = new AudioContext();
     managedSounds = new List <SoundInstance>();
     isInitialized = true;
 }
コード例 #28
0
        //public Framebuffer            Linear              { get { return linear; } }
        //public Framebuffer            MultisampleResolve  { get { return multisampleResolve; } }

        public void Connect(
            IRenderer renderer,
            OpenTK.GameWindow window
            )
        {
            this.window   = window;
            this.renderer = renderer;
            InitializationDependsOn(renderer);
            initializeInMainThread = true;
        }
コード例 #29
0
        public void Connect(
            OpenTK.GameWindow window,
            Renderer renderer
            )
        {
            this.window   = window;
            this.renderer = renderer;

            InitializationDependsOn(renderer);
        }
コード例 #30
0
ファイル: Layer.cs プロジェクト: tksuoran/renderstack_net
        public Layer(IUIContext context, OpenTK.GameWindow window)
        {
            //this.context    = context;
            this.window = window;

            Parent        = null;
            DrawOrdering  = AreaOrder.PostSelf;
            EventOrdering = AreaOrder.Separate;

            Update();
        }
コード例 #31
0
ファイル: Mouse.cs プロジェクト: Daramkun/Misty
        public Mouse( IWindow window )
        {
            w = window.Handle as OpenTK.GameWindow;
            w.Mouse.ButtonDown += Mouse_ButtonDown;
            w.Mouse.ButtonUp += Mouse_ButtonUp;
            w.Mouse.Move += Mouse_Move;
            w.Mouse.WheelChanged += Mouse_WheelChanged;

            buttonEvent = new MouseButtonEventArgs ( GetState () );
            wheelEvent = new MouseWheelEventArgs ( 0 );
        }
コード例 #32
0
        public void Shutdown()
        {
            if (!this.isInitialized)
            {
                Error("Trying to shut down a non initialized graphics manager!");
            }

            GL.DeleteTexture(this.fontHandle);
            this.game          = null;
            this.isInitialized = false;
        }
コード例 #33
0
        protected override void Destroy()
        {
            if (gameForm != null)
            {
                gameForm.Context.MakeCurrent(null);
                gameForm.Close();
                gameForm.Dispose();
                gameForm = null;
            }

            base.Destroy();
        }
コード例 #34
0
        public void InitializeFromOpenTK(GameContext gameContext)
        {
            gameWindow = (OpenTK.GameWindow)gameContext.Control;

            gameWindow.Keyboard.KeyDown += Keyboard_KeyDown;
            gameWindow.Keyboard.KeyUp += Keyboard_KeyUp;
            gameWindow.Mouse.ButtonDown += Mouse_ButtonDown;
            gameWindow.Mouse.ButtonUp += Mouse_ButtonUp;
            gameWindow.Mouse.Move += Mouse_Move;
            gameWindow.Resize += GameWindowOnResize;

            GameWindowOnResize(null, EventArgs.Empty);
        }
コード例 #35
0
        /// <summary>
        /// Updates ImGui input and IO configuration state.
        /// </summary>
        public void Update(OpenTK.GameWindow wnd, float deltaSeconds)
        {
            if (_frameBegun)
            {
                ImGui.Render();
            }

            SetPerFrameImGuiData(deltaSeconds);
            UpdateImGuiInput(wnd);

            _frameBegun = true;
            ImGui.NewFrame();
        }
コード例 #36
0
        public void InitializeFromOpenTK(GameContext <OpenTK.GameWindow> gameContext)
        {
            gameWindow = gameContext.Control;

            gameWindow.Keyboard.KeyDown += Keyboard_KeyDown;
            gameWindow.Keyboard.KeyUp   += Keyboard_KeyUp;
            gameWindow.Mouse.ButtonDown += Mouse_ButtonDown;
            gameWindow.Mouse.ButtonUp   += Mouse_ButtonUp;
            gameWindow.Mouse.Move       += Mouse_Move;
            gameWindow.Resize           += GameWindowOnResize;

            GameWindowOnResize(null, EventArgs.Empty);
        }
コード例 #37
0
        static void Main(string[] args)
        {
            //entry point
            Console.WriteLine("Loading.......");

            //create a window and set graphics mode
            OpenTK.GameWindow window = new OpenTK.GameWindow(1600, 900, new OpenTK.Graphics.GraphicsMode(32, 8, 0, 0));
            //create a game singleton
            Game game = new Game(window);

            //set window run speed
            window.Run(1.0 / 60.0);
        }
コード例 #38
0
ファイル: Game.cs プロジェクト: Mszauer/TileBasedGames
        public void Initialize(OpenTK.GameWindow window)
        {
            Window = window;
            window.ClientSize = new Size(mapLayout[0].Length*30, mapLayout.Length*30);
            TextureManager.Instance.UseNearestFiltering = true;
            map = GenerateMap(mapLayout, spriteSheets, spriteSources);
            hero = new Character(heroSheet, new Point(spawnTile.X * 30, spawnTile.Y * 30));

            hero.AddSprite("Down",new Rectangle(59,1,24,30));
            hero.AddSprite("Up", new Rectangle(115,3,22,28));
            hero.AddSprite("Left",new Rectangle(1,1,26,30));
            hero.AddSprite("Right", new Rectangle(195, 1, 26, 30));
            hero.SetSprite("Down");
        }
コード例 #39
0
 // Set up all necesary member variables of the texture manager
 // The argument this manager takes is ignored, we include it to
 // make all managers have a similar interface. Usually you only
 // initialize a manager at the start of the application.
 public void Initialize(OpenTK.GameWindow window)
 {
     if (isInitialized)
     {
         Error("Trying to double intialize texture manager!");
     }
     managedTextures = new List <TextureInstance>();
     // List.Capacity = Vector.Reserve
     // We reserve enough room for 100 textures, if 101
     // textures are loaded, room will be reserved for 200
     // textures. This will keep doubling as vectors do
     managedTextures.Capacity = 100;
     isInitialized            = true;
 }
コード例 #40
0
ファイル: Window.cs プロジェクト: Daramkun/Misty
        public Window()
        {
            toolkit = OpenTK.Toolkit.Init ();

            window = new OpenTK.GameWindow ( 800, 600,
                new OpenTK.Graphics.GraphicsMode ( new OpenTK.Graphics.ColorFormat ( 32 ), 16, 8 ), "Misty Framework" );
            window.ClientSize = new System.Drawing.Size ( 800, 600 );
            window.WindowBorder = OpenTK.WindowBorder.Fixed;
            window.Load += (object sender, EventArgs e ) => { window.Title = "Misty Framework"; };
            window.Resize += ( object sender, EventArgs e ) => { if ( Resize != null ) Resize ( this, e ); };
            window.FocusedChanged += ( object sender, EventArgs e ) =>
            {
                if ( window.Focused && Activated != null ) Activated ( this, e );
                else if ( !window.Focused && Deactivated != null ) Deactivated ( this, e );
            };
            window.Context.SwapInterval = 0;

            window.Context.Update ( window.WindowInfo );
        }
コード例 #41
0
ファイル: Main.cs プロジェクト: merlish/ventis
        public static void Main(string[] args)
        {
            var gw = new OpenTK.GameWindow(1280, 800);
            var mc = new MainClass();
            gw.RenderFrame += delegate(object sender, OpenTK.FrameEventArgs e) {
                mc.RenderFrame();
            };

            // change to data dir
            System.IO.Directory.SetCurrentDirectory(System.IO.Directory.GetCurrentDirectory() + "/../../data/");

            // set up graphics
            Graphics.Init(gw.Context, gw.WindowInfo);

            // set up initial tasks
            Tasks.Add(() => Console.WriteLine("tick"));

            // todo: use input queue?

            gw.Run();
        }
コード例 #42
0
ファイル: GameWindowOpenTK.cs プロジェクト: joewan/xenko
        protected override void Destroy()
        {
            if (gameForm != null)
            {
                gameForm.Context.MakeCurrent(null);
                gameForm.Close();
                gameForm.Dispose();
                gameForm = null;
            }

            base.Destroy();
        }
コード例 #43
0
ファイル: GameWindowOpenTK.cs プロジェクト: joewan/xenko
        internal override void Run()
        {
            Debug.Assert(InitCallback != null);
            Debug.Assert(RunCallback != null);

            // Initialize the init callback
            InitCallback();

            // Make the window visible
            gameForm.Visible = true;

            // Run the rendering loop
            try
            {
                while (!Exiting)
                {
                    gameForm.ProcessEvents();

                    RunCallback();
                }

                if (gameForm != null)
                {
                    if (OpenTK.Graphics.GraphicsContext.CurrentContext == gameForm.Context)
                        gameForm.Context.MakeCurrent(null);
                    gameForm.Close();
                    gameForm.Dispose();
                    gameForm = null;
                }
            }
            finally
            {
                if (ExitCallback != null)
                {
                    ExitCallback();
                }
            }
        }
コード例 #44
0
ファイル: Window.cs プロジェクト: Daramkun/ProjectLiqueur
 protected virtual void Dispose( bool isDisposing )
 {
     if ( isDisposing )
     {
         window.Dispose ();
         window = null;
     }
 }
コード例 #45
0
ファイル: Game.cs プロジェクト: Mszauer/TileBasedGames
        public void Initialize(OpenTK.GameWindow window)
        {
            this.window = window;
            TextureManager.Instance.UseNearestFiltering = true;
            map = GenerateMap(mapLayout, spriteSheets, spriteSources);
            window.ClientSize = new Size(mapLayout[0].Length*30, mapLayout.Length*30);

            hero = new Character(heroSheet, new Point(SpawnTile.X * 30, SpawnTile.Y * 30));
            hero.facingLeftFrame1 = new Rectangle(1,1,26,30);
            hero.facingDownFrame1 = new Rectangle(59,1,24,30);
            hero.facingUpFrame1 = new Rectangle(115,3,22,28);
            hero.facingRightFrame1 = new Rectangle(195,1,26,30);

            hero.displaySourceRect = hero.facingDownFrame1;
        }
コード例 #46
0
ファイル: Keyboard.cs プロジェクト: Daramkun/Misty
 public Keyboard( IWindow window )
 {
     w = window.Handle as OpenTK.GameWindow;
     w.Keyboard.KeyDown += Keyboard_KeyDown;
     w.Keyboard.KeyUp += Keyboard_KeyUp;
 }
コード例 #47
0
ファイル: BackBuffer.cs プロジェクト: Daramkun/Misty
 public BackBuffer( OpenTK.GameWindow window )
 {
     this.window = window;
 }
コード例 #48
0
ファイル: Window.cs プロジェクト: Daramkun/Misty
        protected override void Dispose( bool isDisposing )
        {
            if ( isDisposing )
            {
                window.Dispose ();
                window = null;

                toolkit.Dispose ();
            }
            base.Dispose ( isDisposing );
        }
コード例 #49
0
        public void Initialize(OpenTK.GameWindow window) {
            if (isInitialized) {
                Error("Trying to double intialize graphics manager!");
            }

            GL.MatrixMode(MatrixMode.Modelview);
            GL.LoadIdentity();
            lastClear = Color.CadetBlue;
            game = window;
            currentDepth = zNear;
            depthStepValue = (zFar - zNear) / numberOfSprites;
            depthStep = depthStepValue;

            GL.Enable(EnableCap.Texture2D);
            GL.BindTexture(TextureTarget.Texture2D, 0);
            GL.Enable(EnableCap.Blend);
            GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);
            GL.Enable(EnableCap.DepthTest);
            GL.ClearColor(Color.CadetBlue);

            GL.AlphaFunc(AlphaFunction.Greater, 0.1f);
            GL.Enable(EnableCap.AlphaTest);

            fontHandle = GetFontTexture();

            isInitialized = true;

            SetScreenSize(game.ClientSize.Width, game.ClientSize.Height);

            game.Load += (sender, e) => {
                game.VSync = OpenTK.VSyncMode.On;
            };

            game.Resize += (sender, e) => {
                SetScreenSize(game.ClientSize.Width, game.ClientSize.Height);
            };

        }
コード例 #50
0
ファイル: Program.cs プロジェクト: DocSohl/DrenchAI
 static void Main(string[] args) {
     OpenTK.GameWindow window = new OpenTK.GameWindow(1280, 720);
     VisualDisplay display = new VisualDisplay(window);
     window.Run();
 }
コード例 #51
0
        public void Initialize(OpenTK.GameWindow window)
        {
            game = window;

            int numKeys = (int)OpenTK.Input.Key.LastKey;
            int numMouseButtons = (int)OpenTK.Input.MouseButton.LastButton;

            prevKeysDown = new bool[numKeys];
            curKeysDown = new bool[numKeys];
            for (int i = 0; i < numKeys; ++i) {
                prevKeysDown[i] = curKeysDown[i] = false;
            }

            prevMouseDown = new bool[numMouseButtons];
            curMouseDown = new bool[numMouseButtons];
            for (int i = 0; i < numMouseButtons; ++i) {
                prevMouseDown[i] = curMouseDown[i] = false;
            }

            numJoysticks = game.Joysticks.Count;
            joyMapping = new ControllerMapping[numJoysticks];
            prevJoyDown = new ControllerState[numJoysticks];
            curJoyDown = new ControllerState[numJoysticks];
            joyDeadZone = new float[numJoysticks];
            for (int i = 0; i < numJoysticks; ++i) {
                joyMapping[i] = new ControllerMapping();
                prevJoyDown[i] = new ControllerState();
                curJoyDown[i] = new ControllerState();
                joyDeadZone[i] = 0.25f;
            }

            isInitialized = true;
        }
コード例 #52
0
 public void Shutdown() {
     if (!isInitialized) {
         Error("Trying to shut down a non initialized graphics manager!");
     }
     GL.DeleteTexture(fontHandle);
     game = null;
     isInitialized = false;
 }