Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Jun 12th, 2012  |  syntax: None  |  size: 2.24 KB  |  views: 15  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. module main;
  2.  
  3. import simpleWindow;
  4. import core.dgdk_darkgdk;
  5. import core.dgdk_display;
  6. import core.dgdk_core;
  7. import core.dgdk_3d;
  8.  
  9. import std.c.windows.windows;
  10. import std.stdio;
  11. import core.runtime;
  12. import core.sys.windows.windows;
  13. import std.string;
  14.  
  15. import core.runtime;
  16. import core.sys.windows.windows;
  17. import std.string;
  18. import std.stdio;
  19.  
  20. extern (Windows)
  21. int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
  22.             LPSTR lpCmdLine, int nCmdShow)
  23. {
  24.     int result;
  25.  
  26.     void exceptionHandler(Throwable e) {
  27.         throw e;
  28.     }
  29.  
  30.     try
  31.     {
  32.         Runtime.initialize(&exceptionHandler);
  33.         result = myWinMain(hInstance, hPrevInstance, lpCmdLine, nCmdShow);
  34.         Runtime.terminate(&exceptionHandler);
  35.     }
  36.     catch (Throwable e) // catch any uncaught exceptions
  37.     {
  38.         MessageBoxA(null, e.toString().toStringz(), "Error",
  39.                     MB_OK | MB_ICONEXCLAMATION);
  40.         result = 0;     // failed
  41.     }
  42.  
  43.   return result;
  44. }
  45.  
  46. int myWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
  47.               LPSTR lpCmdLine, int nCmdShow)
  48. {
  49.         stdout = File("test.txt", "w");
  50.        
  51.         stdout.flush();
  52.        
  53.        
  54.             writeln("%s", "Creating Swindow");
  55.                 stdout.flush();
  56.         Swindow GDKwindow;
  57.        
  58.         writeln("%s", "Initializing DarkGDK");
  59.         stdout.flush();
  60.         if (!initDarkGDK("gdkengine.dll")) {
  61.                 writeln("failed");
  62.                 stdout.flush();
  63.                 return 1;
  64.         }
  65.        
  66.         writeln("%s", "Starting the window");
  67.         stdout.flush();
  68.         if (!GDKwindow.start(hInstance, 0, 0, 800, 600, "simpleWindow")) {
  69.                 writeln("failed");
  70.                 stdout.flush();
  71.                 return 1;
  72.         }
  73.        
  74.         HWND hWnd = GDKwindow.hWnd;
  75.         writeln("%s", "Hanind the window to DarkGDK");
  76.         stdout.flush();
  77.         dbOpenScreen(hWnd, 0, 0, 800, 600, 0, 0);
  78.         writeln("%s", "Activating the window");
  79.         stdout.flush();
  80.         ShowWindow(hWnd, nCmdShow);
  81.        
  82.         writeln("%s", "setting the dbSyncRate");
  83.         dbSyncRate(60);
  84.        
  85.         writeln("%s", "Creating cube");
  86.         int objectCube = dbCreateObjectCube(3, -1);
  87.        
  88.         float x = 0;
  89.         float y = 0;
  90.         float z = 0;
  91.        
  92.         do{
  93.                 x += 0.2;
  94.                 y += 0.4;
  95.                 z += 0.8;
  96.                
  97.                 dbRotateObject(objectCube, x, y, z);
  98.                 dbSync(0,0);
  99.         }while (GDKwindow.windowEvent() != WM_CLOSE);
  100.         writeln("%s", "Window Closed");
  101.         dbCloseScreen();
  102.        
  103.         stdout.flush();
  104.        
  105.     return 0;
  106. }