SwapBuffers() public méthode

Swaps the front and back buffer, presenting the rendered scene to the user.
public SwapBuffers ( ) : void
Résultat void
Exemple #1
0
		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 ();
		}
Exemple #2
0
        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);
        }
Exemple #3
0
        void renderF(object o, EventArgs e)
        {
            GL.LoadIdentity();
            GL.Clear(ClearBufferMask.ColorBufferBit);

            GL.Rotate(theta, 0.0, 0.0, -1.0);
            GL.Begin(BeginMode.Triangles);

            GL.Color3(0.0, 0.0, 0.0);

            GL.Vertex2(1.0, 1.0);
            GL.Color3(0.0, 255.0, 255.0);
            GL.Vertex2(25.0, 49.0);
            GL.Color3(255.0, 0.0, 255.0);
            GL.Vertex2(49.0, 1.0);

            GL.End();
            window.SwapBuffers();

            theta += 1.0;
            if (theta > 360)
            {
                theta -= 360;
            }
        }
Exemple #4
0
        public override void OnRenderFrame(OpenTK.FrameEventArgs e, GameWindow window)
        {
            GL.MatrixMode(MatrixMode.Projection);
            GL.LoadIdentity();
            GL.Ortho(0, 1280, 0,720,0,1);
            GL.Disable(EnableCap.DepthTest);
            GL.MatrixMode(MatrixMode.Modelview);
            GL.LoadIdentity();
            GL.ClearColor(0.2f , 0.2f, 0.2f, 0);
            GL.Clear(ClearBufferMask.ColorBufferBit);

            for (int y=0;y<720;y++)
            {
                for (int x = 0; x < 1280; x++)
                {
                    var c = (int) (Math.Floor(Math.Sin(x/35d)*128 + Math.Sin(y/28d)*32f + Math.Sin((x + y)/16d)*64));
                    c = mod(c, 256);
                    var r = cols[0, c] % 256;
                    var g = cols[1, c] % 256;
                    var b = cols[2, c] % 256;
                    GL.Color3(r/256, g/256, b/256);
                    GL.Begin(BeginMode.Points);
                        GL.Vertex2(x, y);
                    GL.End();
                }

            }
            window.SwapBuffers();
        }
Exemple #5
0
        private MyApplication()
        {
            //setup
            gameWindow = new GameWindow(700, 700);
            gameWindow.KeyDown += (s, arg) => gameWindow.Close();
            gameWindow.Resize += (s, arg) => GL.Viewport(0, 0, gameWindow.Width, gameWindow.Height);
            gameWindow.RenderFrame += GameWindow_RenderFrame;
            gameWindow.RenderFrame += (s, arg) => gameWindow.SwapBuffers();
            //animation using a single SpriteSheet
            explosion = new SpriteSheetAnimation(new SpriteSheet(TextureLoader.FromBitmap(Resourcen.explosion), 5), 0, 24, 1);
            //animation using a bitmap for each frame
            alienShip = new AnimationTextures(.5f);
            //art from http://millionthvector.blogspot.de/p/free-sprites.html
            alienShip.AddFrame(TextureLoader.FromBitmap(Resourcen.alien10001));
            alienShip.AddFrame(TextureLoader.FromBitmap(Resourcen.alien10002));
            alienShip.AddFrame(TextureLoader.FromBitmap(Resourcen.alien10003));
            alienShip.AddFrame(TextureLoader.FromBitmap(Resourcen.alien10004));
            alienShip.AddFrame(TextureLoader.FromBitmap(Resourcen.alien10005));
            alienShip.AddFrame(TextureLoader.FromBitmap(Resourcen.alien10006));
            alienShip.AddFrame(TextureLoader.FromBitmap(Resourcen.alien10007));
            alienShip.AddFrame(TextureLoader.FromBitmap(Resourcen.alien10008));
            alienShip.AddFrame(TextureLoader.FromBitmap(Resourcen.alien10009));
            alienShip.AddFrame(TextureLoader.FromBitmap(Resourcen.alien10010));
            alienShip.AddFrame(TextureLoader.FromBitmap(Resourcen.alien10011));
            alienShip.AddFrame(TextureLoader.FromBitmap(Resourcen.alien10012));
            alienShip.AddFrame(TextureLoader.FromBitmap(Resourcen.alien10013));
            alienShip.AddFrame(TextureLoader.FromBitmap(Resourcen.alien10014));
            alienShip.AddFrame(TextureLoader.FromBitmap(Resourcen.alien10015));

            //for transparency in textures
            GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);
            //start game time
            timeSource.Start();
        }
Exemple #6
0
		static void Main ()
		{
			// OpenGL 창
			GameWindow window = new GameWindow ();

			float [] vertices = new float []
			{
				+0.0f, +0.5f,
				+0.5f, -0.5f,
				-0.5f, -0.5f,
			};

			// 창이 처음 생성됐을 때 
			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 3.2부터 Deprecated, OpenGL ES 2.0부터 Deprecated
				GL.VertexPointer<float> ( 2, VertexPointerType.Float, 0, vertices );
				GL.EnableClientState ( ArrayCap.VertexArray );

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

				GL.DrawArrays ( PrimitiveType.Triangles, 0, 3 );

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

			};

			// 창을 띄우고 창이 종료될 때까지 메시지 펌프 및 무한 루프 처리
			window.Run ();
		}
		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);
			}
		}
Exemple #8
0
 private MyApplication()
 {
     gameWindow = new GameWindow(800, 800);
     //gameWindow.WindowState = WindowState.Fullscreen;
     gameWindow.KeyDown += GameWindow_KeyDown;
     gameWindow.Resize += (s, arg) => GL.Viewport(0, 0, gameWindow.Width, gameWindow.Height);
     gameWindow.RenderFrame += (s, arg) => visual.Render();
     gameWindow.RenderFrame += (s, arg) => gameWindow.SwapBuffers();
     visual = new MainVisual();
 }
Exemple #9
0
 private MyApplication()
 {
     var mode = new GraphicsMode(new ColorFormat(32), 24, 8, 0);
     gameWindow = new GameWindow(1024, 1024, mode, "Example", GameWindowFlags.Default, DisplayDevice.Default, 4, 3, GraphicsContextFlags.ForwardCompatible);
     gameWindow.WindowState = WindowState.Fullscreen;
     gameWindow.KeyDown += GameWindow_KeyDown;
     gameWindow.Resize += (s, arg) => GL.Viewport(0, 0, gameWindow.Width, gameWindow.Height);
     gameWindow.RenderFrame += (s, arg) => visual.Render();
     gameWindow.RenderFrame += (s, arg) => gameWindow.SwapBuffers();
     visual = new MainVisual();
 }
Exemple #10
0
 private MyApplication()
 {
     //setup
     gameWindow = new GameWindow(700, 700);
     gameWindow.VSync = VSyncMode.On;
     gameWindow.KeyDown += (s, arg) => gameWindow.Close();
     gameWindow.Resize += (s, arg) => GL.Viewport(0, 0, gameWindow.Width, gameWindow.Height);
     gameWindow.RenderFrame += GameWindow_RenderFrame;
     gameWindow.RenderFrame += (s, arg) => gameWindow.SwapBuffers();
     //background clear color
     GL.ClearColor(1, 1, 1, 1);
 }
Exemple #11
0
 private MyApplication()
 {
     //setup
     gameWindow = new GameWindow(512, 512);
     gameWindow.KeyDown += (s, arg) => gameWindow.Close();
     gameWindow.Resize += (s, arg) => GL.Viewport(0, 0, gameWindow.Width, gameWindow.Height);
     gameWindow.RenderFrame += GameWindow_RenderFrame;
     gameWindow.RenderFrame += (s, arg) => gameWindow.SwapBuffers();
     texBackground = TextureLoader.FromBitmap(Resourcen.mountains);
     //background clear color
     GL.ClearColor(Color.White);
 }
        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);
            }
        }
Exemple #13
0
        protected override void HandleFrame(GameWindow window)
        {
            GL.ClearColor (Color4.Black);
            GL.Clear (ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
            GL.Enable (EnableCap.Blend);
            GL.BlendFunc (BlendingFactorSrc.SrcAlpha, BlendingFactorDest.One);
            GL.BlendEquation (BlendEquationMode.FuncAdd);

            SetCamera (window);
            PrepareState ();
            GL.DrawArraysInstanced (BeginMode.TriangleFan, 0, 4, PARTICLES_COUNT);

            window.SwapBuffers ();
        }
Exemple #14
0
        public MyApplication()
        {
            shootCoolDown.OnPeriodElapsed += (s, t) => shootCoolDown.Stop();

            gameWindow = new GameWindow();
            gameWindow.WindowState = WindowState.Fullscreen;
            CreateEnemies();
            gameWindow.Resize += (sender, e) => GL.Viewport(0, 0, gameWindow.Width, gameWindow.Height);
            gameWindow.UpdateFrame += GameWindow_UpdateFrame;
            gameWindow.RenderFrame += GameWindow_RenderFrame;
            gameWindow.RenderFrame += (sender, e) => gameWindow.SwapBuffers();
            timeSource.Start();
            gameWindow.Run(60.0);
        }
Exemple #15
0
 private MyApplication()
 {
     gameWindow = new GameWindow(800, 800);
     //gameWindow.LoadLayout();
     //gameWindow.WindowState = WindowState.Fullscreen;
     gameWindow.MouseMove += GameWindow_MouseMove;
     gameWindow.MouseWheel += GameWindow_MouseWheel;
     gameWindow.KeyDown += GameWindow_KeyDown;
     gameWindow.Resize += (s, arg) => GL.Viewport(0, 0, gameWindow.Width, gameWindow.Height);
     gameWindow.RenderFrame += (s, arg) => visual.Render();
     gameWindow.RenderFrame += (s, arg) => gameWindow.SwapBuffers();
     gameWindow.UpdateFrame += (s, arg) => visual.Update((float)timeSource.Elapsed.TotalSeconds);
     visual = new MainVisual();
     timeSource.Start();
 }
Exemple #16
0
 public MyApplication()
 {
     gameWindow = new GameWindow(800, 800);
     string basePath = "../../media/";
     levelFileNamePrefix = basePath + "level";
     visual = new Visual();
     gameWindow.Load += GameWindow_Load;
     gameWindow.Resize += GameWindow_Resize;
     gameWindow.KeyDown += GameWindow_KeyDown;
     gameWindow.UpdateFrame += GameWindow_UpdateFrame;
     gameWindow.RenderFrame += GameWindow_RenderFrame;
     gameWindow.RenderFrame += (sender, e) => { gameWindow.SwapBuffers(); };
     LoadLevel();
     gameWindow.Run(60.0);
 }
Exemple #17
0
 private MyApplication()
 {
     //setup
     gameWindow = new GameWindow(700, 700);
     gameWindow.KeyDown += (s, arg) => gameWindow.Close();
     gameWindow.Resize += (s, arg) => GL.Viewport(0, 0, gameWindow.Width, gameWindow.Height);
     gameWindow.RenderFrame += GameWindow_RenderFrame;
     gameWindow.RenderFrame += (s, arg) => gameWindow.SwapBuffers();
     texShip = TextureLoader.FromBitmap(Resourcen.redship4);
     texBackground = TextureLoader.FromBitmap(Resourcen.water);
     //background clear color
     GL.ClearColor(Color.White);
     //for transparency in textures we use blending
     GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);
 }
Exemple #18
0
 private MyApplication()
 {
     //setup
     gameWindow = new GameWindow(700, 700);
     gameWindow.KeyDown += (s, arg) => gameWindow.Close();
     gameWindow.Resize += (s, arg) => GL.Viewport(0, 0, gameWindow.Width, gameWindow.Height);
     gameWindow.RenderFrame += GameWindow_RenderFrame;
     gameWindow.RenderFrame += (s, arg) => gameWindow.SwapBuffers();
     //load font
     font = new TextureFont(TextureLoader.FromBitmap(Resourcen.Blood_Bath_2), 10, 32, .8f, 1, .7f);
     //background clear color
     GL.ClearColor(Color.Black);
     //for transparency in textures
     GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);
 }
Exemple #19
0
 public void TestClear()
 {
     var pixel = new Pixel();
     _window = new GameWindow();
     _window.RenderFrame += (caller, args) =>
     {
         GL.ReadBuffer(ReadBufferMode.Front);
         GL.ClearColor(0.4f, 0.2f, 1.0f, 1.0f);
         GL.Clear(ClearBufferMask.ColorBufferBit);
         _window.SwapBuffers();
         pixel.ReadBuffer(0, 0);
         _window.Close();
     };
     _window.Run();
     Assert.AreEqual(new Pixel(0.4f, 0.2f, 1.0f), pixel);
 }
Exemple #20
0
        private MyApplication()
        {
            //setup
            gameWindow = new GameWindow(700, 700);
            gameWindow.KeyDown += (s, arg) => gameWindow.Close();
            gameWindow.Resize += (s, arg) => GL.Viewport(0, 0, gameWindow.Width, gameWindow.Height);
            gameWindow.UpdateFrame += GameWindow_UpdateFrame;
            gameWindow.RenderFrame += GameWindow_RenderFrame;
            gameWindow.RenderFrame += (s, arg) => gameWindow.SwapBuffers();

            queryA = new QueryObject();
            queryB = new QueryObject();

            //for query to work
            GL.Enable(EnableCap.DepthTest);
        }
Exemple #21
0
        public static void Main(string[] args)
        {
            using (var game = new GameWindow(1024, 768))
            {
                // Load event - fired once before entering the mainLoop
                game.Load += (object sender, EventArgs e) =>
                {
                    game.Title = "OpenGL in C#";                    // Set the window title;
                    GL.Enable(EnableCap.Blend);                     // Enable OpenGL alpha blending
                    GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha); // Set the default blending calculation
                };

                // Resize event - fires when the window changes size
                // Using it to reset the Viewport on resize
                game.Resize += (object sender, EventArgs e) =>
                {
                    GL.Viewport(0, 0, game.Width, game.Height);     // Set the OpenGL ViewPort(the area that it will draw to)
                };

                // Called once every N frames set by the Run method
                game.RenderFrame += (object sender, FrameEventArgs e) =>
                {
                    GL.ClearColor(Color.CornflowerBlue);            // Sets the default color of the color buffer
                    GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); // Clears individual buffers, fills the color buffer with the set clearColor

                    GL.MatrixMode(MatrixMode.Projection);           // Tells OpenGL that we will use the Projection Matrix
                    GL.LoadIdentity();                              // Replaces the selected matrix with a Identity matrix
                    GL.Ortho(-1.5, 1.5, -1.5, 1.5, 0.0, 4.0);       // Create an Orthographic matrix(parallel view with no depth(3rd dimension)

                    GL.Begin(PrimitiveType.Polygon);                // Tells OpenGL that we want to draw Verticies with the given mode, this case Polygon(deprecated, dont use it in real applications)
                    GL.Color3(Color.Blue);                          // Tells OpenGL that the Vertex Colors after this call will be Blue
                    GL.Vertex2(-1, 1);                              // Sets a Vertex at the set position
                    GL.Color3(Color.Red);
                    GL.Vertex2(1, 1);
                    GL.Color3(Color.Yellow);
                    GL.Vertex2(1, -1);
                    GL.Color3(Color.White);
                    GL.Vertex2(-1, -1);

                    GL.End();                                       // Tells OpenGL that we are done passing our data.

                    game.SwapBuffers();                             // Swaps the back buffer with the front buffer. We draw on the back buffer while the front buffer is on the screen.
                };

                game.Run();                                         // Starts the mainLoop and fires onetime events
            }
        }
Exemple #22
0
 public MyApplication()
 {
     try
     {
         gameState = (GameState)Serialize.ObjFromBinFile(GetGameStateFilePath()); //try to load from file
     }
     catch
     {
         gameState = new GameState(); //loading failed -> reset
     }
     gameWindow = new GameWindow();
     gameWindow.Closing += GameWindow_Closing;
     gameWindow.KeyDown += GameWindow_KeyDown;
     gameWindow.MouseDown += GameWindow_MouseDown;
     gameWindow.RenderFrame += GameWindow_RenderFrame;
     gameWindow.RenderFrame += (sender, e) => gameWindow.SwapBuffers();
 }
Exemple #23
0
		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 );



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

			};

			// 창을 띄우고 창이 종료될 때까지 메시지 펌프 및 무한 루프 처리
			window.Run ();
		}
Exemple #24
0
 private MyApplication()
 {
     //setup
     gameWindow = new GameWindow(700, 700);
     gameWindow.KeyDown += (s, arg) => gameWindow.Close();
     gameWindow.Resize += (s, arg) => GL.Viewport(0, 0, gameWindow.Width, gameWindow.Height);
     //callback for updating http://gameprogrammingpatterns.com/game-loop.html
     gameWindow.UpdateFrame += GameWindow_UpdateFrame;
     gameWindow.RenderFrame += GameWindow_RenderFrame;
     gameWindow.RenderFrame += (s, arg) => gameWindow.SwapBuffers();
     texPlayer = TextureLoader.FromBitmap(Resourcen.bird1);
     //two landscape resources are available in the Resourcen.resx file
     texBackground = TextureLoader.FromBitmap(Resourcen.forest);
     //set how texture coordinates outside of [0..1] are handled
     texBackground.WrapMode(TextureWrapMode.Repeat);
     //background clear color
     GL.ClearColor(Color.White);
     //for transparency in textures
     GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);
 }
Exemple #25
0
        public MyApplication()
        {
            gameWindow = new GameWindow();
            logic = new GameLogic();
            Texture texPlayer = TextureLoader.FromBitmap(Resourcen.blueships1);
            Texture texEnemy = TextureLoader.FromBitmap(Resourcen.redship4);
            Texture texBullet = TextureLoader.FromBitmap(Resourcen.blueLaserRay);
            visual = new Visual(texEnemy, texBullet, texPlayer);
            sound = new Sound();
            logic.OnShoot += (sender, args) => { sound.Shoot(); };
            logic.OnEnemyDestroy += (sender, args) => { sound.DestroyEnemy(); };
            logic.OnLost += (sender, args) => { sound.Lost(); gameWindow.Exit(); };

            gameWindow.Load += GameWindow_Load;
            gameWindow.Resize += GameWindow_Resize;
            gameWindow.UpdateFrame += GameWindow_UpdateFrame;
            gameWindow.RenderFrame += GameWindow_RenderFrame;
            gameWindow.RenderFrame += (sender, e) => { gameWindow.SwapBuffers(); };
            sound.Background();
            timeSource.Start();
            gameWindow.Run(60.0);
        }
Exemple #26
0
        public MyApplication()
        {
            gameWindow = new GameWindow();
            gameWindow.Load += GameWindow_Load;
            gameWindow.Resize += GameWindow_Resize;
            gameWindow.UpdateFrame += GameWindow_UpdateFrame;
            gameWindow.RenderFrame += GameWindow_RenderFrame;
            gameWindow.RenderFrame += (sender, e) => { gameWindow.SwapBuffers(); };

            renderer = new Renderer();
            //private static TextureFont font = new TextureFont("../../media/bitmap_fonts/OpenTKTextureFont.png", 16, 0, 0.8f, 0.8f, 0.8f);
            //private static TextureFont font = new TextureFont("../../media/bitmap_fonts/Orange with Shadow.png", 10, 32, 1.0f, 1.0f, 0.9f);
            //private static TextureFont font = new TextureFont("../../media/bitmap_fonts/LED Green.png", 10, 32, 0.9f, 0.7f, 0.8f);
            //private static TextureFont font = new TextureFont("../../media/bitmap_fonts/Bamboo.png", 10, 32, 0.8f, 0.7f, 1.0f);
            renderer.RegisterFont(new TextureFont(TextureLoader.FromBitmap(Resourcen.Video_Phreak), 10, 32));
            renderer.Register("player", TextureLoader.FromBitmap(Resourcen.blueships1));
            renderer.Register("enemy", TextureLoader.FromBitmap(Resourcen.redship4));
            renderer.Register("bulletPlayer", TextureLoader.FromBitmap(Resourcen.blueLaserRay));
            renderer.Register("bulletEnemy", TextureLoader.FromBitmap(Resourcen.redLaserRay));
            renderer.Register("explosion", TextureLoader.FromBitmap(Resourcen.explosion));

            this.galaxyBirds = new GameLogic(renderer);
            timeSource.Start();
        }
Exemple #27
0
 private MyApplication()
 {
     //setup
     gameWindow = new GameWindow(700, 700);
     gameWindow.VSync = VSyncMode.On;
     gameWindow.KeyDown += (s, arg) => gameWindow.Close();
     gameWindow.Resize += (s, arg) => GL.Viewport(0, 0, gameWindow.Width, gameWindow.Height);
     gameWindow.UpdateFrame += GameWindow_UpdateFrame;
     gameWindow.RenderFrame += GameWindow_RenderFrame;
     gameWindow.RenderFrame += (s, arg) => gameWindow.SwapBuffers();
     texBird = TextureLoader.FromBitmap(Resourcen.bird1);
     //background clear color
     GL.ClearColor(Color.DarkGreen);
     //for transparency in textures
     GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);
     //generate birds
     for(float delta = .1f; delta < .5f; delta += .1f)
     {
         birds.Add(Box2D.CreateFromCenterSize(rotCenter.X - delta, rotCenter.Y - delta, .1f, .1f));
         birds.Add(Box2D.CreateFromCenterSize(rotCenter.X - delta, rotCenter.Y + delta, .1f, .1f));
         birds.Add(Box2D.CreateFromCenterSize(rotCenter.X + delta, rotCenter.Y - delta, .1f, .1f));
         birds.Add(Box2D.CreateFromCenterSize(rotCenter.X + delta, rotCenter.Y + delta, .1f, .1f));
     }
 }
Exemple #28
0
 public void TestDrawQuad()
 {
     var pixel = new Pixel();
     _window = new GameWindow {Width = 200, Height = 200};
     _window.RenderFrame += (caller, args) =>
     {
         GL.ReadBuffer(ReadBufferMode.Front);
         GL.Clear(ClearBufferMask.ColorBufferBit);
         GL.Begin(PrimitiveType.Quads);
         {
             GL.Color3(1.0f, 1.0f, 1.0f);
             GL.Vertex2(0.0f, 0.0f);
             GL.Vertex2(-1.0f, 0.0f);
             GL.Vertex2(-1.0f, -1.0f);
             GL.Vertex2(0.0f, -1.0f);
         }
         GL.End();
         _window.SwapBuffers();
         pixel.ReadBuffer(0, 0);
         _window.Close();
     };
     _window.Run();
     Assert.AreEqual(new Pixel(1.0f, 1.0f, 1.0f), pixel);
 }
Exemple #29
0
        public static void Main(int resX, int resY)
        {

            Graphics.Sprite sprite = new Graphics.Sprite();
            Graphics.Mesh mesh = new Graphics.Mesh();
            using (var game = new GameWindow())
            {
                game.VSync = VSyncMode.On;
                game.Width = resX;
                game.Height = resY;
                
                game.Load += (sender, e) =>
                {
                    Console.WriteLine("Using OpenGL version: " + GL.GetString(StringName.Version));

                    
                    Graphics.TextureManager.LoadTexture("F:/DestWa/Pictures/artkleiner.png", "art");

                    // setup settings, load textures, sounds


                    sprite = new Graphics.Sprite("art", Vector3.Zero, Vector3.Zero, Vector3.One);
                    sprite.scale = new Vector3(1280, 720, 1);
                    sprite.position.X = 10;


                    mesh = Graphics.Mesh.CreateMeshFromOBJ("C:/Users/DestWa/Desktop/man.obj");
                    mesh.scale = new Vector3(1, 1, 1);
                    mesh.position.Z = 100;

                    GL.ClearColor(Color.Cornsilk);
                };

                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();
                    }
                };
                
                game.RenderFrame += (sender, e) =>
                {
                    // render graphics
                    GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);

                    Graphics.Renderer.DrawSprite(sprite);
                    //mesh.rotation.X += 0.01f;
                    //mesh.rotation.Y += 0.01f;

                    Graphics.Renderer.activeCamera.location.Z -= 0.1f;
                    Graphics.Renderer.DrawMesh(mesh);

                    game.SwapBuffers();
                };

                // Run the game at 60 updates per second
                game.Run(60.0);
            }
        }
Exemple #30
0
        public static void Main()
        {
            using(var game = new GameWindow())
            {
                game.Load += (sender, e) =>
                {

                    // Setup settings, load textures, sound etc.
                    game.VSync	= VSyncMode.On;
                    game.Width	= 1280;
                    game.Height	= 720;

                    // Center window to desktop
                    game.Location = new Point(	OpenTK.DisplayDevice.Default.Width/2 - game.Width/2,
                                                OpenTK.DisplayDevice.Default.Height/2 - game.Height/2);

                    GL.ClearColor(0.4f, 0.4f, 0.4f, 1);
                    GraphicsManager.init_text_writer(game.ClientSize, game.ClientSize);
                    _skeletons.Add(new Skeleton());
                };

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

                game.UpdateFrame += (sender, e) =>
                {
                    // Add game logic, input handling
                    if(game.Keyboard[Key.Escape])
                    {
                        game.Exit();
                    }
                    if(game.Keyboard[Key.R])
                    {
                        reset();
                        Nearest.release_check();
                    }
                    if(game.Keyboard[Key.A] && _active_time < DateTime.Now.Ticks)
                    {
                        add_doll();
                        if(_active_time < DateTime.Now.Ticks + 2000000)
                            _active_time = DateTime.Now.Ticks + 2000000;
                    }
                    if(game.Keyboard[Key.P] && _active_time < DateTime.Now.Ticks)
                    {
                        _pause = !_pause;
                        if(_active_time < DateTime.Now.Ticks + 2000000)
                            _active_time = DateTime.Now.Ticks + 2000000;
                    }
                    if(game.Keyboard[Key.F] && _active_time < DateTime.Now.Ticks)
                    {
                        for(int i = 0; i < _skeletons.Count; ++i)
                            _skeletons[i].toggle_forces();
                        if(_active_time < DateTime.Now.Ticks + 2000000)
                            _active_time = DateTime.Now.Ticks + 2000000;
                    }
                    if(game.Keyboard[Key.B] && _active_time < DateTime.Now.Ticks)
                    {
                        for(int i = 0; i < _skeletons.Count; ++i)
                            _skeletons[i].toggle_bones();
                        if(_active_time < DateTime.Now.Ticks + 2000000)
                            _active_time = DateTime.Now.Ticks + 2000000;
                    }
                    if(game.Keyboard[Key.G] && _active_time < DateTime.Now.Ticks)
                    {
                        for(int i = 0; i < _skeletons.Count; ++i)
                            _skeletons[i].toggle_graphics();
                        if(_active_time < DateTime.Now.Ticks + 2000000)
                            _active_time = DateTime.Now.Ticks + 2000000;
                    }
                    if(game.Keyboard[Key.C] && _active_time < DateTime.Now.Ticks)
                    {
                        for(int i = 0; i < _skeletons.Count; ++i)
                            _skeletons[i].toggle_climbing_mode();
                        if(_active_time < DateTime.Now.Ticks + 2000000)
                            _active_time = DateTime.Now.Ticks + 2000000;
                    }
                    if(game.Keyboard[Key.M] && _active_time < DateTime.Now.Ticks)
                    {
                        for(int i = 0; i < _skeletons.Count; ++i)
                            _skeletons[i].toggle_christmas_mode();

                        _snow.toggle();

                        if(_active_time < DateTime.Now.Ticks + 2000000)
                            _active_time = DateTime.Now.Ticks + 2000000;
                    }
                    if(game.Mouse[MouseButton.Right] && _active_time < DateTime.Now.Ticks)
                    {
                        for(int i = 0; i < _skeletons.Count; ++i)
                            _skeletons[i].pin_point();
                        if(_active_time < DateTime.Now.Ticks + 2000000)
                            _active_time = DateTime.Now.Ticks + 2000000;
                    }
                    if(game.Mouse[MouseButton.Left])
                    {
                        // Finds the nearest ragdoll to mouse
                        Nearest.check_nearest(_skeletons, new Vector2D(game.Mouse.X, game.Mouse.Y));
                        if(_ragdoll_release_time < DateTime.Now.Ticks + 2000000)
                            _ragdoll_release_time = DateTime.Now.Ticks + 2000000;

                        // Adds a mouse drag force.
                        for(int i = 0; i < _skeletons.Count; ++i)
                            _skeletons[i].mouse_force(new Vector2D(game.Mouse.X, game.Mouse.Y));
                    }
                    else
                    {
                        // Makes it possible to drag around another ragdoll
                        if(_ragdoll_release_time < DateTime.Now.Ticks)
                            Nearest.release_check();

                        for(int i = 0; i < _skeletons.Count; ++i)
                            _skeletons[i].release_point_lock();
                    }

                    // Update skeleton
                    if(!_pause)
                    {
                        for(int i = 0; i < _skeletons.Count; ++i)
                            _skeletons[i].update(1.0/10.0);
                        _snow.update(1.0/10.0);
                    }
                };

                game.RenderFrame += (sender, e) =>
                {
                    // Render graphics
                    GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);

                    GL.MatrixMode(MatrixMode.Projection);
                    GL.LoadIdentity();
                    GL.Ortho(0, game.Width, game.Height, 0, -1, 1);

                    // Render ragdolls
                    for(int i = 0; i < _skeletons.Count; ++i)
                            _skeletons[i].draw(new Vector2D(game.Mouse.X, game.Mouse.Y));

                    // Render snow
                    _snow.draw();

                    // Some user friendly info
                    if(_fps_timer < DateTime.Now.Ticks)
                    {
                        _fps_timer = DateTime.Now.Ticks + 800000;
                        _fps = Math.Round(game.RenderFrequency, 2);
                    }

                    // Render help text
                    draw_info();

                    game.SwapBuffers();
                };

                // Run the game at 60 updates per second
                game.Run(60.0);
            }
        }
        private void Task3Btn_Click(object sender, RoutedEventArgs e)
        {
            using (var visualWindow = new VisualWindow())
            {
                visualWindow.Load += (s, args) =>
                {
                    visualWindow.VSync = VSyncMode.On;
                };
                visualWindow.Resize += (s, args) =>
                {
                    GL.Viewport(0, 0, visualWindow.Width, visualWindow.Height);
                };
                visualWindow.UpdateFrame += (s, args) =>
                {
                };
                visualWindow.RenderFrame += (s, args) =>
                {
                    float left  = 0,
                          right = 300,
                          down  = 0,
                          up    = 100;


                    GL.ClearColor(255, 255, 255, 255);
                    GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);

                    GL.MatrixMode(MatrixMode.Projection);
                    GL.LoadIdentity();
                    GL.Ortho(left, right, down, up, 0, 100);

                    // T
                    GL.Begin(PrimitiveType.LineLoop);

                    GL.Color3(Color.DarkBlue);
                    GL.Vertex2(10, 80);
                    GL.Vertex2(90, 80);
                    GL.Vertex2(90, 70);
                    GL.Vertex2(55, 70);
                    GL.Vertex2(55, 20);
                    GL.Vertex2(45, 20);
                    GL.Vertex2(45, 70);
                    GL.Vertex2(10, 70);

                    GL.End();

                    // S
                    GL.Begin(PrimitiveType.LineLoop);

                    GL.Color3(Color.DarkBlue);
                    GL.Vertex2(190, 80);
                    GL.Vertex2(110, 80);
                    GL.Vertex2(110, 45);
                    GL.Vertex2(180, 45);
                    GL.Vertex2(180, 30);
                    GL.Vertex2(110, 30);
                    GL.Vertex2(110, 20);
                    GL.Vertex2(190, 20);
                    GL.Vertex2(190, 55);
                    GL.Vertex2(120, 55);
                    GL.Vertex2(120, 70);
                    GL.Vertex2(190, 70);

                    GL.End();

                    // I
                    GL.Begin(PrimitiveType.LineLoop);

                    GL.Color3(Color.DarkBlue);
                    GL.Vertex2(235, 80);
                    GL.Vertex2(265, 80);
                    GL.Vertex2(265, 70);
                    GL.Vertex2(255, 70);
                    GL.Vertex2(255, 30);
                    GL.Vertex2(265, 30);
                    GL.Vertex2(265, 20);
                    GL.Vertex2(235, 20);
                    GL.Vertex2(235, 30);
                    GL.Vertex2(245, 30);
                    GL.Vertex2(245, 70);
                    GL.Vertex2(235, 70);

                    GL.End();

                    visualWindow.SwapBuffers();
                };

                visualWindow.Run(60.0);
            }
        }
Exemple #32
0
        private void Task2Btn_Click(object sender, RoutedEventArgs e)
        {
            using (var visualWindow = new VisualWindow())
            {
                double angle = 0, selfAngle = 0, xOffset = 0, yOffset = 0, scale = 1;
                visualWindow.Load += (s, args) =>
                {
                    visualWindow.Width  = 600;
                    visualWindow.Height = 200;
                    visualWindow.VSync  = VSyncMode.On;
                };
                visualWindow.Resize += (s, args) =>
                {
                    GL.Viewport(0, 0, visualWindow.Width, visualWindow.Height);
                };
                visualWindow.UpdateFrame += (s, args) =>
                {
                    var keyboardState = OpenTK.Input.Keyboard.GetState();

                    if (keyboardState.IsKeyDown(OpenTK.Input.Key.Escape))
                    {
                        visualWindow.Exit();
                    }

                    GL.MatrixMode(MatrixMode.Modelview);

                    if (keyboardState.IsKeyDown(OpenTK.Input.Key.Up))
                    {
                        yOffset += 10;
                    }
                    if (keyboardState.IsKeyDown(OpenTK.Input.Key.Down))
                    {
                        yOffset -= 10;
                    }
                    if (keyboardState.IsKeyDown(OpenTK.Input.Key.Left))
                    {
                        xOffset -= 10;
                    }
                    if (keyboardState.IsKeyDown(OpenTK.Input.Key.Right))
                    {
                        xOffset += 10;
                    }

                    if (keyboardState.IsKeyDown(OpenTK.Input.Key.Plus))
                    {
                        scale += 0.1;
                    }
                    if (keyboardState.IsKeyDown(OpenTK.Input.Key.Minus))
                    {
                        scale -= 0.1;
                    }

                    if (keyboardState.IsKeyDown(OpenTK.Input.Key.Home))
                    {
                        angle += 5;
                    }
                    if (keyboardState.IsKeyDown(OpenTK.Input.Key.End))
                    {
                        angle -= 5;
                    }

                    if (keyboardState.IsKeyDown(OpenTK.Input.Key.Q))
                    {
                        selfAngle += 3;
                    }

                    if (keyboardState.IsKeyDown(OpenTK.Input.Key.E))
                    {
                        selfAngle -= 3;
                    }
                };
                visualWindow.RenderFrame += (s, args) =>
                {
                    float left  = 0,
                          right = 300,
                          down  = 0,
                          up    = 100;

                    GL.ClearColor(255, 255, 255, 255);
                    GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);

                    GL.MatrixMode(MatrixMode.Projection);
                    GL.LoadIdentity();
                    GL.Ortho(left, right, down, up, 0, 100);

                    // Translations
                    GL.Translate(xOffset, yOffset, 0);
                    GL.Translate(150, 50, 0);
                    GL.Scale(scale, scale, 0);
                    GL.Rotate(angle, 0, 0, 1);
                    GL.Translate(-150, -50, 0);


                    GL.Color3(255.0, 0, 0);

                    // T
                    GL.PushMatrix();
                    GL.Translate(50, 50, 0);
                    GL.Rotate(selfAngle, 0, 0, 1);
                    GL.Translate(-50, -50, 0);

                    GL.Begin(BeginMode.LineLoop);
                    GL.Vertex2(10, 80);
                    GL.Vertex2(90, 80);
                    GL.Vertex2(90, 70);
                    GL.Vertex2(55, 70);
                    GL.Vertex2(55, 20);
                    GL.Vertex2(45, 20);
                    GL.Vertex2(45, 70);
                    GL.Vertex2(10, 70);
                    GL.End();

                    GL.PopMatrix();


                    // S
                    GL.PushMatrix();
                    GL.Translate(150, 50, 0);
                    GL.Rotate(-selfAngle, 0, 0, 1);
                    GL.Translate(-150, -50, 0);

                    GL.Begin(BeginMode.LineLoop);
                    GL.Vertex2(190, 80);
                    GL.Vertex2(110, 80);
                    GL.Vertex2(110, 45);
                    GL.Vertex2(180, 45);
                    GL.Vertex2(180, 30);
                    GL.Vertex2(110, 30);
                    GL.Vertex2(110, 20);
                    GL.Vertex2(190, 20);
                    GL.Vertex2(190, 55);
                    GL.Vertex2(120, 55);
                    GL.Vertex2(120, 70);
                    GL.Vertex2(190, 70);
                    GL.End();

                    GL.PopMatrix();

                    // I
                    GL.PushMatrix();
                    GL.Translate(250, 50, 0);
                    GL.Rotate(selfAngle, 0, 0, 1);
                    GL.Translate(-250, -50, 0);

                    GL.Begin(BeginMode.LineLoop);
                    GL.Vertex2(265, 80);
                    GL.Vertex2(265, 70);
                    GL.Vertex2(255, 70);
                    GL.Vertex2(255, 30);
                    GL.Vertex2(265, 30);
                    GL.Vertex2(265, 20);
                    GL.Vertex2(235, 20);
                    GL.Vertex2(235, 30);
                    GL.Vertex2(245, 30);
                    GL.Vertex2(245, 70);
                    GL.Vertex2(235, 70);
                    GL.Vertex2(235, 80);
                    GL.End();

                    GL.PopMatrix();

                    visualWindow.SwapBuffers();
                };

                visualWindow.Run(60.0);
            }
        }
        static void Main(string[] args)
        {
            Game.ClientSize = new Size(1280, 720);

            //load textures
            TextureManager.LoadTexture("face", "./Assets/face.tif");
            TextureManager.LoadTexture("face_alpha", "./Assets/face_alpha.tif");

            //create state system
            System.AddState("splash", new SplashScreenState(System));
            System.AddState("title_menu", new TitleScreenState());
            System.AddState("sprite_test", new DrawSpriteState(TextureManager));
            System.AddState("test_sprite_class", new TestSpriteClassState(TextureManager));

            //set init state
            System.ChangeState("test_sprite_class");

            //set up events
            Game.Load += (sender, e) =>
            {
                Game.VSync = VSyncMode.On;
            };
            Setup2D(Game.Width, Game.Height);

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

            Game.UpdateFrame += (sender, e) =>
            {
                // add game logic, input handling
                if (Game.Keyboard[Key.Escape])
                {
                    Game.Exit();
                }
                if (Game.Keyboard[Key.AltRight] && Game.Keyboard[Key.Enter])
                {
                    if (Game.WindowState == WindowState.Normal)
                    {
                        Game.WindowState = WindowState.Fullscreen;
                    }
                    else
                    {
                        Game.WindowState = WindowState.Normal;
                    }
                }

                System.Update(e.Time);
            };

            Game.RenderFrame += (sender, e) =>
            {
                System.Render();
                Game.SwapBuffers();
            };

            // Run the game at 60 updates per second
            Game.Run(60.0);
            Game.Dispose();
        }
Exemple #34
0
 void RenderF(object o, EventArgs e)
 {
     GL.Clear(ClearBufferMask.ColorBufferBit);
     window.SwapBuffers();
 }
Exemple #35
-1
 private MyApplication()
 {
     //set waypoints of enemy
     wayPoints.Add(new Vector2(-.5f, -.5f));
     wayPoints.Add(new Vector2(.5f, -.5f));
     wayPoints.Add(new Vector2(.5f, .5f));
     wayPoints.Add(new Vector2(-.5f, .5f));
     //wayPoints.Add(new Vector2(.6f, -.7f));
     //wayPoints.Add(new Vector2(.5f, .8f));
     //wayPoints.Add(new Vector2(-.5f, .4f));
     //wayPoints.Add(new Vector2(0, 0));
     wayTangents = CatmullRomSpline.FiniteDifferenceLoop(wayPoints);
     //setup
     gameWindow = new GameWindow(700, 700);
     gameWindow.VSync = VSyncMode.On;
     gameWindow.KeyDown += (s, arg) => gameWindow.Close();
     gameWindow.Resize += (s, arg) => GL.Viewport(0, 0, gameWindow.Width, gameWindow.Height);
     gameWindow.UpdateFrame += GameWindow_UpdateFrame;
     gameWindow.RenderFrame += GameWindow_RenderFrame;
     gameWindow.RenderFrame += (s, arg) => gameWindow.SwapBuffers();
     texBird = TextureLoader.FromBitmap(Resourcen.bird1);
     //background clear color
     GL.ClearColor(Color.White);
     //for transparency in textures
     GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);
     timeSource.Start();
 }