The program is slow! -_-'

When I run this code it go slow to compile and then I cannot close the program! I think there is something wrong with the Thread..

  1. using System;
  2. using System.Collections.Generic;
  3. using AgateLib;
  4. using AgateLib.DisplayLib;
  5. using AgateLib.Geometry;
  6. using AgateLib.InputLib;
  7.  
  8. namespace Pong
  9. {
  10.     class Program
  11.     {
  12.         [STAThread]
  13.         static void Main(string[] args)
  14.         {
  15.             new Program().Run(args);
  16.         }
  17.  
  18.         void Run(string[] args)
  19.         {
  20.             using (AgateSetup setup = new AgateSetup(args))
  21.             {
  22.                 setup.Initialize(true, false, false);
  23.                 if (setup.WasCanceled)
  24.                     return;
  25.  
  26.                 DisplayWindow wind = DisplayWindow.CreateWindowed
  27.                     ("Window", 300, 300);
  28.  
  29.                 FontSurface font = new FontSurface("Sans Serif", 14);
  30.  
  31.                 while (wind.IsClosed == false)
  32.                 {
  33.                     Display.BeginFrame();
  34.                     Display.Clear(Color.DarkGray);
  35.  
  36.                     font.Color = Color.Black;
  37.                     font.DrawText(32, 32, "Hello World!");
  38.                     Display.EndFrame();
  39.                 }
  40.             }
  41.         }
  42.  
  43.     }
  44. }

Great! Maybe I can put a

Great! Maybe I can put a loading screen when the program is starting? Because it is ugly to see a white window with a blue border when the program loads..

AgateLib will certainly take

AgateLib will certainly take more time to load than OpenTK, since when using AgateLib you have to load AgateLib and OpenTK instead of just OpenTK. Your code may also be taking more time to load because of the FontSurface you are creating. Constructors which use an OS font have to measure and rasterize the glyphs to a surface. You can get around this by generating a font ahead of time using the included font creator application. The next version of AgateLib will include a couple of prerasterized fonts for use.

For a big game, the bottleneck with loading will be reading images and sounds from the hard disk. The additional overhead of initializing AgateLib won't scale with the amount of data that needs to be loaded.

But OpenTK is so hard.. :(

But OpenTK is so hard.. :( And you maybe don't think 1 second is much, but if I make a big game I think it takes minutes to load...

Then write it in OpenTK?

Then write it in OpenTK? Agatelib is going to add some load time, because it well, has to load.

Thank you! Now I can close

Thank you! Now I can close the program but it still take time to load it (maybe 1 second or something). I make a similar Hello World code with OpenTK and it goes faster to load.

After the call to

After the call to Display.EndFrame, you need to insert a call to Core.KeepAlive. KeepAlive processes events and "plays nice" with the OS. Without it the program won't respond to events, like clicking the close box.