I can almost guarantee that most of the issues you're experiencing are due to programming errors.
You'll need to create a function that will run for every error. The header should look like this:
Quote: "void __cdecl runtimeCallback(int errorID, void* runtimeParam)"
In this function you can do something like this:
Quote: "MessageBox(0, dbGetErrorString(runtimeParam).c_str(), "Custom Error",
MB_OK);"
Use dbSetRuntimeErrorCallback() to point to your runtime error trapping function (described above).
Now every time you perform an illegal action and GDK encounters an error you should get a message box describing the error. Otherwise instead of crashing you game continues and random unpredictable things can happen. Your best solution is to terminate the game after an error.
This example here shows you how to retrieve information about most recent error:
#include <darkgdk.h>
#include <initDarkGDK.h>
#include <simpleWindow.h>
using namespace std;
int __stdcall WinMain(HINSTANCE, HINSTANCE, LPSTR, int) {
HWND hWnd;
if (!initDarkGDK("gdkengine.dll", "../../../../../"))
return 1;
hWnd = openWindow(0, 0, 640, 480, "DarkGDK - Game Developer's Toolkit",
WS_OVERLAPPED | WS_CLIPSIBLINGS | WS_CAPTION | WS_SYSMENU |
WS_CLIPCHILDREN, true);
dbOpenScreen(hWnd, 0, 0, 640, 480);
ShowWindow(hWnd, SW_SHOW);
// Test last error
dbLoadObject("models\\statue.x", 0, kGDK_3D_DBPro, -1);
MessageBox(0, dbGetErrorString(dbGetLastError()).c_str(), "Custom Error",
MB_OK);
dbLoadMusic("music\\hero.mp3", 1);
MessageBox(0, dbGetErrorString(dbGetLastError()).c_str(), "Custom Error",
MB_OK);
// Attempt to perform the cleanest possible shutdown. Some compilers are
// less forgiving than others
dbCloseScreen();
return 0;
}
Intel Core2Duo 2.2GHZ, 2GB, GeForce 8600M GT 1280MB, Windows Vista Ultimate SP2, PureBasic 4.61 + DarkGDK 2.0