Message loops 'n stuff

Started by
0 comments, last by eagleboy 19 years, 10 months ago
Hi, When I execute the following code a strange thing happens; The window appears and behaves as expected, however nothing is drawn, despite the window seeming to recieve and process windows messages. If the window looses focus the client rect exposes what appears to be the drawn surface! It reminds me of the time I forgot to set the parent property of a control... All source code can be found here



		public void q8Main()
		{
			
			loadingform = new LoadingForm();
			Q8Window GameWindow = new Q8Window();
			
			// initialisation thread
			Thread InitialisationThread = new Thread(new ThreadStart(Initialise));
			InitialisationThread.Name = "Q8 Initialisation Thread";			
			InitialisationThread.Start();
			
			// this will happily sit here waiting for the end
			Application.Run(loadingform);

			// did we load our settings?
			if (!Loaded) return;

			// lets create a new window
			GameWindow = new Q8Window();
			GameWindow.Activated += new EventHandler(GameWindow_Activated);
			GameWindow.Closing += new System.ComponentModel.CancelEventHandler(GameWindow_Closing);
			GameWindow.Closed += new EventHandler(GameWindow_Closed);	

			engine.Console.Print("I have no idea why it won''t work straight up");
			engine.Console.Print("I guess I''ll find out soon enough");

			GameWindow.ClientSize = new Size(640, 480);
			engine.Init(GameWindow);


			engine.SetViewPort(640, 480);

			GameWindow.Show();

			while(Running)
			{				
				engine.BeginScene();				
				// guts goes here
				engine.EndScene();

				Application.DoEvents();	
				
				Thread.Sleep(50);			
			}

			Application.Exit();

		
			
			
		}

		/// 
		/// The main entry point for the application.
		/// 
		[STAThread]
		static void Main() 
		{			
			q8 Game = new q8();
			// logic goes in a different thread
			Thread GameMainThread = new Thread(new ThreadStart(Game.q8Main));
			GameMainThread.Name = "Q8 Main Thread";
			GameMainThread.Start();

			Thread.CurrentThread.Name = "Main";

			// new message pump please
			//Application.Run();
		}

Advertisement
Cross-post. Closed.

This topic is closed to new replies.

Advertisement