module main;
import simpleWindow;
import core.dgdk_darkgdk;
import core.dgdk_display;
import core.dgdk_core;
import core.dgdk_3d;
import std.c.windows.windows;
import std.stdio;
import core.runtime;
import core.sys.windows.windows;
import std.string;
import core.runtime;
import core.sys.windows.windows;
import std.string;
import std.stdio;
extern (Windows)
int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow)
{
int result;
void exceptionHandler(Throwable e) {
throw e;
}
try
{
Runtime.initialize(&exceptionHandler);
result = myWinMain(hInstance, hPrevInstance, lpCmdLine, nCmdShow);
Runtime.terminate(&exceptionHandler);
}
catch (Throwable e) // catch any uncaught exceptions
{
MessageBoxA(null, e.toString().toStringz(), "Error",
MB_OK | MB_ICONEXCLAMATION);
result = 0; // failed
}
return result;
}
int myWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow)
{
stdout = File("test.txt", "w");
stdout.flush();
writeln("%s", "Creating Swindow");
stdout.flush();
Swindow GDKwindow;
writeln("%s", "Initializing DarkGDK");
stdout.flush();
if (!initDarkGDK("gdkengine.dll")) {
writeln("failed");
stdout.flush();
return 1;
}
writeln("%s", "Starting the window");
stdout.flush();
if (!GDKwindow.start(hInstance, 0, 0, 800, 600, "simpleWindow")) {
writeln("failed");
stdout.flush();
return 1;
}
HWND hWnd = GDKwindow.hWnd;
writeln("%s", "Hanind the window to DarkGDK");
stdout.flush();
dbOpenScreen(hWnd, 0, 0, 800, 600, 0, 0);
writeln("%s", "Activating the window");
stdout.flush();
ShowWindow(hWnd, nCmdShow);
writeln("%s", "setting the dbSyncRate");
dbSyncRate(60);
writeln("%s", "Creating cube");
int objectCube = dbCreateObjectCube(3, -1);
float x = 0;
float y = 0;
float z = 0;
do{
x += 0.2;
y += 0.4;
z += 0.8;
dbRotateObject(objectCube, x, y, z);
dbSync(0,0);
}while (GDKwindow.windowEvent() != WM_CLOSE);
writeln("%s", "Window Closed");
dbCloseScreen();
stdout.flush();
return 0;
}