The DarkGDK 2.0 Release Candidate is out! Have fun and go nuts. It's free to try!
The current release is still in release-candidate status. However, the new website provides a download link for the full commercial version (for those accounts who purchase it) which does not expire as the beta releases have.
http://forum.thegamecreators.com/?m=forum_view&t=196865&b=22
Feature highlights:
![](/images/emoticons/cherries.gif)
All of DBP compressed down into a single DLL
![](/images/emoticons/cherries.gif)
Engine customization; basic 3D in less than 800 KB!
![](/images/emoticons/cherries.gif)
Future support is anticipated for additional programming languages.
![](/images/emoticons/cherries.gif)
Language agnostic interface; all exports are C function calls
![](/images/emoticons/cherries.gif)
Internal multithreading support. Go thread crazy!
![](/images/emoticons/cherries.gif)
Enhanced commands including true support for structured parameters
![](/images/emoticons/cherries.gif)
Potential support for rendering in a web browser
![](/images/emoticons/cherries.gif)
Rewritten, extremely fast 3D math library
![](/images/emoticons/cherries.gif)
Improved documentation for all DarkBasic Professional commands
![](/images/emoticons/cherries.gif)
Superior runtime error support that is thread-aware
![](/images/emoticons/cherries.gif)
Easy to use command line tools for automated compiling
![](/images/emoticons/cherries.gif)
Plugin-based parser. Adding support for your own language is a breeze!
Projects supported by DarkGDK out of the box:
![](/images/emoticons/cherries.gif)
Visual Studio 2010
![](/images/emoticons/cherries.gif)
Visual Studio 2008
![](/images/emoticons/cherries.gif)
Visual Studio 2005
![](/images/emoticons/cherries.gif)
Visual Studio .NET 2003
![](/images/emoticons/cherries.gif)
Visual Studio .NET
![](/images/emoticons/cherries.gif)
Visual Studio 6
![](/images/emoticons/cherries.gif)
GNU make/GCC g++
![](/images/emoticons/cherries.gif)
Nmake/VC++
![](/images/emoticons/cherries.gif)
PureBasic 4
This list is not finite! DarkGDK will "just work" with any standards-compliant C++ compiler. This includes any version of Visual Studio Express, g++, Borland, Watcom, Intel, Comeau, etc.
The new engine is extremely lightweight and highly customizable. And best of all, it's fully compatible with DBP's plugins. Now you can enjoy the power of DarkBasic Professional from your favorite language. And if you have multiple favorites-- no problem!
Program using your favorite IDE. Any IDE. Any language!
DarkGDK: Project Setup in Visual Studio 2008
Screenshot of DarkGDK and the PureBasic IDE:
Screenshot of DarkGDK and the Qt Creator C++ IDE:
Here is a video of a C++ example project being run and debugged from the Qt Creator IDE. It also demos the flexibility of DarkGDK by compiling from a UNIX (cygwin) command line using Make and the GNU g++ compiler. It should work with most any C/C++ compiler.
http://darkgdk.com/files/upload/TGCForum/pgdk_cpp_demo_xvid.avi
Brand new language-specific documentation!
Here is a screenshot of the DarkGDK documentation for a comparison:
The documentation is in the excellent .chm format with an index and full text search.
All source code and templates for the documentation builder will be available in the SDK for you to help extend the existing docs and also for you to apply to your own projects if you like.
Many of the commands have been renamed for clarity and others have had their parameters reordered to support default parameters and function polymorphism.
Here is an example of a function which will have its parameters reordered for automatic ID allocation:
Quote: "
dbLoadSound(string fileName [, int soundID])"
The "soundID" parameter is optional and therefore appears at the end of the function. If no ID is specified, one will be returned as the result.
For functions which take advantage of default parameters, the header might look like this:
Quote: "
dbLoadSound(string fileName, int soundID = -1)"
And for others which use function polymorphism, for example:
Quote: "
dbLoadSound(string fileName)
dbLoadSound(string fileName, int soundID)"
Another example where a command might be different is "dbSetDisplayMode".
In DarkGDK you can use these commands to change the resolution:
Quote: "
void dbSetDisplayMode (int iWidth, int iHeight, int iDepth)
bool dbSetDisplayModeEx(int iWidth, int iHeight)
bool dbSetDisplayModeEx(int iWidth, int iHeight, int iDepth)
bool dbSetDisplayModeEx(int iWidth, int iHeight, int iDepth, int iMode)
bool dbSetDisplayModeEx(int iWidth, int iHeight, int iDepth, int iMode, int iVertexProcessing)
bool dbSetDisplayModeEx(int iWidth, int iHeight, int iDepth, int iMode, int iVertexProcessing, int iLockable)
bool dbSetDisplayModeVSync(int iWidth, int iHeight, int iDepth, int iVSyncOn)
bool dbSetDisplayModeAntialias (int iWidth, int iHeight, int iDepth, int iVSyncOn, int iMultisamplingFactor, int iMultimonitorMode)"
In DarkGDK the same command with optional parameters is:
Quote: "
dbSetDisplayMode(int width, int height[, int depth [, int vSync [, int multiSampling [, int multiMonitor [, int backBufferWidth [, int backBufferHeight [, int vrMode]]]]]]])"
In this function each parameter after width and height can be optionally specified.
DarkGDK has built-in support for multithreading by providing function-level critical sections for your convenience behind the scenes as well as thread-aware error handling. Each function can have several possible error codes which can be detected are caught at runtime for you to examine and respond to.
For example, dbMakeMatrix() can throw any of the following errors for you to catch with dbGetLastError():
Quote: "
kGDK_Error_3D_Matrix_ID_Invalid
kGDK_Error_3D_Matrix_Exists
kGDK_Error_3D_Matrix_Segment_Invalid
kGDK_Error_3D_Matrix_Dimension_Invalid
kGDK_Error_3D_Matrix_Too_Large"
dbGetLastError() will return the last error to occur in the current thread. It can safely and accurately be used across multiple threads.
Never have to use a vector or matrix "ID" again! DarkGDK supports vector and matrix datatypes as structures. This means that you can access any part of this data and they can be written to and read from memory:
// Declare variables with pre-defined structures
Vector2 Vector2a;
Vector2 Vector2b;
Vector2 Vector2Result;
// Set vector data
Vector2a.x = 3;
Vector2b.x = 7;
Vector2a.y = 5;
Vector2b.y = 5;
// Add vectors together
dbAddVector2(&Vector2Result, &Vector2a, &Vector2b);
// Output results
cout << Vector2Result.x << endl; // 3 + 7 = 10
cout << Vector2Result.y << endl; // 5 + 5 = 10
How to write a library builder plugin for your language:
The library builder (buildlibs.exe) tool handles all of the template parsing for you and will automatically compile headers for any language which has a plugin to generate it.
Command line parameters for buildlibs.exe are:
Compile language-specific header files from pre-generated templates. These
header files contain function definitions for every command supported by DarkGDK
and associated plugins.
Usage: buildlibs file -plugin <plugin> [options]
Options:
--help Display this information.
--help-plugins Display help information for all plugins.
--ext-header <arg> Set the output extension of the output header file.
--ext-lib <arg> Set the output extension of the output library file.
--header <file> The file name of the primary header file. All header
files created by this tool will be appended to it.
--lcasefile Set the output file name to lower-case.
-o <file/path> Specifies the location and/or name of the header file
to be written to disk. If no file is specified then the
base name will be used.
-q Disable all text output at the command line.
--plugin <plugin> Load a specific plugin for the target language
--plugin-args <arg> Passes a string of additional command line switches to
the plugin for additional processing.
--prefix-header <arg> Set the output prefix of the output header file.
--prefix-lib <arg> Set the output prefix of the output library file.
-v <detail|docs> Specifies additional verbosity for the command line
output. By specifying 'detail', the function name and
its parameters will be displayed. The 'docs' option
will format the output specifically to be parsed by the
documentation builder.
Here is the source code for gdk_purebasic.dll. This plugin has been written in C++. The code should be fairly easy to read but I'll be happy to answer any questions you may have. The "Version 1" specification may change between now and the final release:
Version 1 Plugin Specification:
#ifndef _LIBBUILDER_H
#define _LIBBUILDER_H
#ifdef _MSC_VER
#include <windows.h>
typedef __int32 int32_t;
typedef unsigned __int32 uint32_t;
typedef __int64 int64_t;
typedef unsigned __int32 uint64_t;
#else
#include <stdint.h>
#endif
namespace LibBuilder {
const int32_t kVersion1 = 1;
const int32_t kVersion2 = 2;
const int32_t kVersion3 = 4;
const int32_t kPlugin_Flags_LoadPtr = 1;
const int32_t kPlugin_Flags_Camera = 2;
const int32_t kPlugin_Flags_NoSafeCall = 4;
const int32_t kPlugin_Flags_NoDefaultOverride = 8;
const int32_t kType_Integer = 1;
const int32_t kType_Long = 2;
const int32_t kType_Float = 4;
const int32_t kType_String = 8;
const int32_t kType_Double = 16;
const int32_t kType_Quad = 32;
const int32_t kType_Char = 64;
const int32_t kType_Byte = 128;
const int32_t kType_Word = 256;
const int32_t kType_Pointer = 512;
const int32_t kType_Hex = 1024;
const int32_t kVerbose_Detail = 1;
const int32_t kVerbose_Docs = 2;
// Global structure
struct Glob_LibPlugin {
string programFileName;
};
class Version1 {
public:
struct Command {
struct Element {
int32_t lineNumber;
char* paramString;
char* rParamType;
char* exportName;
char* paramList;
char* paramListAlt;
char* findFreeParam;
char* findFreeType;
char* dllName;
char* flags;
};
char* name;
int32_t elementCount;
LibBuilder::Version1::Command::Element **elements;
};
struct Constant {
int32_t lineNumber;
char* name;
char* value;
int32_t type;
};
struct Structure {
struct Element {
char* name;
int32_t type;
};
int32_t lineNumber;
char* name;
int32_t elementCount;
LibBuilder::Version1::Structure::Element **elements;
};
struct Return {
char* library;
char* header;
char* include;
char* prefixHeader;
char* prefixLib;
char* extHeader;
char* extLib;
};
int32_t version;
char* fileName;
int32_t verbose;
int32_t constantCount;
int32_t structCount;
int32_t commandCount;
LibBuilder::Version1::Constant **constants;
LibBuilder::Version1::Structure **structures;
LibBuilder::Version1::Command **commands;
};
}
#endif /* _LIBBUILDER_H */
How to run the examples:
The DarkGDK installer should automatically generate header files as well as build a complete engine .dll from all of the DarkBasic Professional core libraries. If you need to generate these files again, there are batch files to automate the process in the DarkGDK install directory.
If you cannot run the examples for some reason, try to generate the headers and the engine .dll again using these batch files. If they do not report a success then please submit a report on this board as a bug.
All examples located in the install directory under the examples folder should compile out of the box without modification.
One major difference you must be aware of is that DarkGDK does NOT use "DarkGDK()/LoopGDK()". It can use whatever entry point you want, be it main(), WinMain(), _tWinMain(), etc:
#include <darkgdk.h>
#include <initDarkGDK.h>
#include <simpleWindow.h>
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);
// Set the current directory
SetCurrentDirectory("media1");
..
return 0;
}
Unlike DBP and DarkGDK 1.0, in DarkGDK 2.0, the renderable area is separate from the actual window. As you can see from this example code, dbOpenScreen accepts a target window handle "hWnd" which tells it where to render the output. This allows DarkGDK to render to "any" window owned by the process and is not limited to any one implementation.
For example, you can use DarkGDK with GLUT, Qt, Win32, wxWidgets, etc.
There are a lot of changes compared to DBP and the old DarkGDK. It is not targeted as being 1:1 compatible with older releases of DarkGDK and there will be growing pains while you encounter the differences. However, the idea behind DarkGDK 2.0 is to bring evolution to the engine to streamline it and in the end make it easier to use as well as being portable to other languages.
Don't forget! DarkGDK is also compatible with all DarkBasic Professional plugins and includes many headers to provide support out-of-the-box. An SDK is also provided which allows anyone to add support for additional languages!!