当前位置: 首页>>代码示例>>C#>>正文


C# GameWindow.Run方法代码示例

本文整理汇总了C#中OpenTK.GameWindow.Run方法的典型用法代码示例。如果您正苦于以下问题:C# GameWindow.Run方法的具体用法?C# GameWindow.Run怎么用?C# GameWindow.Run使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OpenTK.GameWindow的用法示例。


在下文中一共展示了GameWindow.Run方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

        public static void Main()
        {
            // Create static (global) window instance
            Window = new OpenTK.GameWindow();

            // Hook up the initialize callback
            Window.Load += new EventHandler<EventArgs>(Initialize);
            // Hook up the update callback
            Window.UpdateFrame += new EventHandler<FrameEventArgs>(Update);
            // Hook up the render callback
            Window.RenderFrame += new EventHandler<FrameEventArgs>(Render);
            // Hook up the shutdown callback
            Window.Unload += new EventHandler<EventArgs>(Shutdown);

            // Set window title and size
            Window.Title = "Game Name";
            Window.ClientSize = new Size(30*8, 30*6);
            Window.VSync = VSyncMode.On;
            // Run the game at 60 frames per second. This method will NOT return
            // until the window is closed.
            Window.Run(60.0f);

            // If we made it down here the window was closed. Call the windows
            // Dispose method to free any resources that the window might hold
            Window.Dispose();

            #if DEBUG
            Console.WriteLine("\nFinished executing, press any key to exit...");
            Console.ReadKey();
            #endif
        }
开发者ID:Mszauer,项目名称:TileBasedGames,代码行数:31,代码来源:Program.cs

示例2: Main

        private static void Main(string[] args)
        {
            var sprites = new List<Sprite>();

            Window = new GameWindow(800, 600, GraphicsMode.Default, "Blunder Buzz");

            Window.Load += (sender, e) => {
                Window.VSync = VSyncMode.On;

                sprites.Add(new Sprite(new Shader("Shaders/basicVertex.glsl", "Shaders/basicFragment.glsl")));
            };

            Window.UpdateFrame += (sender, e) => {
                if (Window.Keyboard[Key.Escape]) {
                    Window.Exit();
                }

                foreach (var sprite in sprites) {
                    sprite.Update();
                }
            };

            Window.RenderFrame += (sender, e) => {
                GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
                GL.ClearColor(Color.CornflowerBlue);

                foreach (var sprite in sprites) {
                    sprite.Render();
                }

                Window.SwapBuffers();
            };

            Window.Run(DisplayDevice.Default.RefreshRate);
        }
开发者ID:Herbstein,项目名称:BlunderBuzz,代码行数:35,代码来源:Program.cs

示例3: Main

		static void Main ()
		{
			// OpenGL 창
			GameWindow window = new GameWindow ();
			
			// 창이 처음 생성됐을 때 
			window.Load += ( sender, e ) =>
			{
				
			};
			// 업데이트 프레임(연산처리, 입력처리 등)
			window.UpdateFrame += ( sender, e ) =>
			{
				
			};
			// 렌더링 프레임(화면 표시)
			window.RenderFrame += ( sender, e ) =>
			{
				// 화면 초기화 설정
				//> 화면 색상은 검정색(R: 0, G: 0, B: 0, A: 255)
				GL.ClearColor ( 0, 0, 0, 1 );
				//> 깊이 버퍼는 1(쓸 수 있는 깊이)
				GL.ClearDepth ( 1 );
				//> 스텐실 버퍼는 0
				GL.ClearStencil ( 0 );
				// 화면 초기화(색상 버퍼, 깊이 버퍼, 스텐실 버퍼에 처리)
				GL.Clear ( ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit | ClearBufferMask.StencilBufferBit );

				// OpenGL 1.0 삼각형 그리기 시작
				// OpenGL 3.2부터 Deprecated, OpenGL ES 2.0부터 Deprecated
				GL.Begin ( PrimitiveType.Triangles );

				// 삼각형의 세 꼭지점 설정
				// OpenGL 3.2부터 Deprecated, OpenGL ES 2.0부터 Deprecated
				GL.Vertex2 ( +0.0, +0.5 );
				GL.Vertex2 ( +0.5, -0.5 );
				GL.Vertex2 ( -0.5, -0.5 );

				// 삼각형 색상은 마젠타(R: 255, G: 0, B: 255)
				// OpenGL 3.2부터 Deprecated, OpenGL ES 2.0부터 Deprecated
				GL.Color3 ( 1.0f, 0, 1.0f );

				// OpenGL 1.0 삼각형 그리기 끝
				// OpenGL 3.2부터 Deprecated, OpenGL ES 2.0부터 Deprecated
				GL.End ();
				// 버퍼에 출력
				GL.Flush ();

				// 백 버퍼와 화면 버퍼 교환
				window.SwapBuffers ();
			};
			// 창이 종료될 때
			window.Closing += ( sender, e ) =>
			{
				
			};

			// 창을 띄우고 창이 종료될 때까지 메시지 펌프 및 무한 루프 처리
			window.Run ();
		}
开发者ID:GROWrepo,项目名称:OpenGL.Study,代码行数:60,代码来源:Program.cs

示例4: Main

        public static void Main()
        {
            //create static(global) window instance
            Window = new OpenTK.GameWindow();

            //hook up the initialize callback
            Window.Load += new EventHandler<EventArgs>(Initialize);
            //hook up the update callback
            Window.UpdateFrame += new EventHandler<FrameEventArgs>(Update);
            //hook up render callback
            Window.RenderFrame += new EventHandler<FrameEventArgs>(Render);
            //hook up shutdown callback
            Window.Unload += new EventHandler<EventArgs>(Shutdown);
            Window.VSync = VSyncMode.On;

            //set window title and size
            Window.Title = "Game Name";
            Window.ClientSize = new Size(800, 600);
            //run game at 60fps. will not return until window is closed
            Window.Run(60.0f);

            Window.Dispose();
            #if DEBUG
            Console.ReadLine();
            #endif
        }
开发者ID:Mszauer,项目名称:2DOpenTkFrameWork,代码行数:26,代码来源:MainWindow.cs

示例5: Main

        public static void Main(string[] args)
        {
            var win = new OpenTK.GameWindow (200, 200, GraphicsMode.Default, "", OpenTK.GameWindowFlags.Default);

            var form1 = new Form ();
            form1.Size = new Size(400, 1000);
            PropertyGrid propertyGrid1 = new PropertyGrid ();
            propertyGrid1.CommandsVisibleIfAvailable = true;
            propertyGrid1.Location = new Point (10, 20);
            propertyGrid1.TabIndex = 1;
            propertyGrid1.Text = "Property Grid";
            propertyGrid1.Dock = DockStyle.Fill;
            propertyGrid1.Font = new Font("URW Gothic L", 10.25f, GraphicsUnit.Point);
            propertyGrid1.CategoryForeColor = SystemColors.ControlLight;
            propertyGrid1.ViewForeColor = SystemColors.ControlText;
            propertyGrid1.ViewBackColor = SystemColors.Control;
            propertyGrid1.LineColor = SystemColors.ControlLight;
            form1.Controls.Add (propertyGrid1);
            form1.Show ();

            win.RenderFrame += (sender, aaa) => { Application.DoEvents (); };

            using(var system = (new System6.System6()).GetInstance (win))
            {
                //system.PropertyChanged += (sender, e) => propertyGrid1.Refresh();
                propertyGrid1.SelectedObject = system;
                win.Run ();
            }
        }
开发者ID:smalld,项目名称:particle_system,代码行数:29,代码来源:Main.cs

示例6: Main

        static void Main(string[] args)
        {
            GameWindow window = new GameWindow(800, 600, new OpenTK.Graphics.GraphicsMode(32, 8, 0, 8));

            Game game = new Game(window);

            window.Run(1.0 / 60.0);
        }
开发者ID:Lullul,项目名称:DeathStarProject,代码行数:8,代码来源:Program.cs

示例7: LaunchGameWindow

 void LaunchGameWindow()
 {
     hidden = new GameWindow(320, 240, GraphicsMode.Default, "OpenTK | Hidden input window");
     hidden.Load += hidden_Load;
     hidden.Unload += hidden_Unload;
     hidden.RenderFrame += hidden_RenderFrame;
     hidden.Run(60.0, 0.0);
 }
开发者ID:jpespartero,项目名称:OpenGlobe,代码行数:8,代码来源:InputLogger.cs

示例8: Main

 static void Main(string[] args)
 {
     window = new GameWindow(800, 600, GraphicsMode.Default, "Cube");
     window.RenderFrame += Window_RenderFrame;
     window.KeyDown += Window_KeyDown;
     GL.Enable(EnableCap.DepthTest);
     window.Run();
 }
开发者ID:oe2dlo,项目名称:GitProjects,代码行数:8,代码来源:Program.cs

示例9: Main

		public static void Main (string[] args)
		{
			Console.WriteLine ("Hello World!");

			using (var game = new GameWindow ())
			{
				const int kVertsPerParticle = 6;
				const int kParticleCountX = 500;
				const int kParticleCountY = 320;

				var solution = new MapPersistent (kVertsPerParticle, game.Width, game.Height);
				var problem = new DynamicStreamingProblem (solution, kVertsPerParticle, kParticleCountX, kParticleCountY);

				game.Load += (sender, e) =>
				{
					// setup settings, load textures, sounds
					game.VSync = VSyncMode.On;

					problem.Init();
				};

				game.Unload += (sender, e) => 
				{
					problem.Shutdown();
				};

				game.KeyDown += (object sender, KeyboardKeyEventArgs e) => 
				{
					if (e.Key == Key.Space)
					{
						game.Exit();
					}
				};

				game.UpdateFrame += (sender, e) =>
				{
					// add game logic, input handling

					// update shader uniforms

					// update shader mesh
				};

				game.RenderFrame += (sender, e) =>
				{
					game.SwapBuffers();
				};

				game.Resize += (sender, e) =>
				{
					//GL.Viewport(0, 0, game.Width, game.Height);
					solution.SetSize(game.Width, game.Height);
				};

				game.Run(60.0);
			}
		}
开发者ID:tgsstdio,项目名称:BirdNest.QuickFont,代码行数:57,代码来源:Program.cs

示例10: Game

        public Game()
        {
            _win = new GameWindow();
            _win.Load += (s, e) => { Load(s, e); };
            _win.UpdateFrame += (s, e) => { Update(s, e); };
            _win.Resize += (s, e) => { Resize(s, e); };
            _win.RenderFrame += (s, e) => { Render(s, e); };

            _win.Run(60.0);
        }
开发者ID:klockr,项目名称:Vitrus,代码行数:10,代码来源:Game.cs

示例11: Form1_Load

 private void Form1_Load(object sender, EventArgs e)
 {
     game = new GameWindow(800, 600, GraphicsMode.Default, "Primitive Draw");
     game.Load += Game_Load;
     game.Resize += Game_Resize;
     game.RenderFrame += Game_RenderFrame;
     game.UpdateFrame += Game_UpdateFrame;
     game.KeyDown += Game_KeyDown;
     game.Run();
 }
开发者ID:oe2dlo,项目名称:GitProjects,代码行数:10,代码来源:Form1.cs

示例12: Main

 private static void Main()
 {
     using (window = new GameWindow(1024, 600, GraphicsMode.Default, "PhysicsEngine"))
     {
         CreateRectangles();
         window.Resize += Resize;
         window.UpdateFrame += Update;
         window.RenderFrame += Draw;
         window.Run();
     }
 }
开发者ID:BenjaminNitschke,项目名称:PhysicsCourse,代码行数:11,代码来源:Program2D.cs

示例13: Main

 private static void Main()
 {
     using (window = new GameWindow(1024, 600, GraphicsMode.Default, "PhysicsEngine"))
     {
         window.Load += Initialize;
         window.Resize += Resize;
         window.UpdateFrame += Update;
         window.RenderFrame += Draw;
         window.Run();
     }
 }
开发者ID:BenjaminNitschke,项目名称:PhysicsCourse,代码行数:11,代码来源:Program.cs

示例14: Main

        static void Main(string[] args)
        {
            using (var game = new GameWindow())
            {
                game.Load += (sender, e) =>
                {
                    // setup settings, load textures, sounds
                    game.VSync = VSyncMode.On;
                };

                game.Resize += (sender, e) =>
                {
                    GL.Viewport(0, 0, game.Width, game.Height);
                };

                game.UpdateFrame += (sender, e) =>
                {
                    // add game logic, input handling
                    if (game.Keyboard[Key.Escape])
                    {
                        game.Exit();
                    }
                };
                double rotation = 0;
                game.RenderFrame += (sender, e) =>
                {
                    rotation += 1;
                    rotation %= 360;
                    // render graphics
                    GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);

                    GL.MatrixMode(MatrixMode.Projection);
                    GL.LoadIdentity();
                    GL.Ortho(-1.0, 1.0, -1.0, 1.0, 0.0, 4.0);
                    GL.Rotate(rotation, 0, 0, 1);
                    GL.Begin(PrimitiveType.Triangles);

                    GL.Color3(Color.MidnightBlue);
                    GL.Vertex3(-1.0f, 1.0f,-1.0f);
                    GL.Color3(Color.SpringGreen);
                    GL.Vertex3(0.0f, -1.0f,-1.0f);
                    GL.Color3(Color.Ivory);
                    GL.Vertex3(1.0f, 1.0f,-1.0f);

                    GL.End();

                    game.SwapBuffers();
                };

                // Run the game at 60 updates per second
                game.Run(60.0);
            }
        }
开发者ID:piokra,项目名称:crispy-octo-garbanzo,代码行数:53,代码来源:Program.cs

示例15: Run

        public void Run()
        {
            Instance = this;

            Window = new GameWindow();

            Window.Load += Window_Load;
            Window.Resize += Window_Resize;
            Window.UpdateFrame += Window_UpdateFrame;
            Window.RenderFrame += Window_RenderFrame;

            Window.Run();
        }
开发者ID:Phyyl,项目名称:LudumDare33,代码行数:13,代码来源:Game.Core.cs


注:本文中的OpenTK.GameWindow.Run方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。