DarkGDK 2.0, a full-featured game engine for PureBasic!

Developed or developing a new product in PureBasic? Tell the world about it.
Mistrel
Addict
Addict
Posts: 3415
Joined: Sat Jun 30, 2007 8:04 pm

DarkGDK 2.0, a full-featured game engine for PureBasic!

Post by Mistrel »

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=for ... 96865&b=22

Image

Feature highlights:

Image All of DBP compressed down into a single DLL
Image Engine customization; basic 3D in less than 800 KB!
Image Future support is anticipated for additional programming languages.
Image Language agnostic interface; all exports are C function calls
Image Internal multithreading support. Go thread crazy!
Image Enhanced commands including true support for structured parameters
Image Potential support for rendering in a web browser
Image Rewritten, extremely fast 3D math library
Image Improved documentation for all DarkBasic Professional commands
Image Superior runtime error support that is thread-aware
Image Easy to use command line tools for automated compiling
Image Plugin-based parser. Adding support for your own language is a breeze!

Projects supported by DarkGDK out of the box:

Image Visual Studio 2010
Image Visual Studio 2008
Image Visual Studio 2005
Image Visual Studio .NET 2003
Image Visual Studio .NET
Image Visual Studio 6
Image GNU make/GCC g++
Image Nmake/VC++
Image 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

http://youtube.com/watch?v=bupKrN5VHm4

Screenshot of DarkGDK and the PureBasic IDE:

Image

Screenshot of DarkGDK and the Qt Creator C++ IDE:

Image

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/TGCForu ... o_xvid.avi

Brand new language-specific documentation!

Image

Image

Here is a screenshot of the DarkGDK documentation for a comparison:

Image

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:

Code: Select all

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:

Code: Select all

dbLoadSound(string fileName, int soundID = -1)
And for others which use function polymorphism, for example:

Code: Select all

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:

Code: Select all

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:

Code: Select all

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():

Code: Select all

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:

Code: Select all

// 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:

Code: Select all

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:

Code: Select all

#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:

Code: Select all

#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!!
User avatar
[blendman]
Enthusiast
Enthusiast
Posts: 297
Joined: Thu Apr 07, 2011 1:14 pm
Location: 3 arks
Contact:

Re: DarkGDK 2.0, a full-featured game engine for PureBasic!

Post by [blendman] »

HI

I have tried the DarkGdk examples (exe, in the bin directory : examples\bin).
But some examples are not working as they do. They works fine in dbpro (the same examples) :
- basic3d-4.exe
- light.exe

The Pb of the same file doesn't work either (light.pb.

I don't have the textures or shaders for theses examples.

Winxp sp x86.
Dbpro free version
Darkgdk
GMS0012
New User
New User
Posts: 4
Joined: Sat Jul 03, 2010 6:45 am

Re: DarkGDK 2.0, a full-featured game engine for PureBasic!

Post by GMS0012 »

does this work with the latest PB version (4.61)?

when not, will there be an update SOON?

thanks
Olby
Enthusiast
Enthusiast
Posts: 461
Joined: Mon Jan 12, 2009 10:33 am
Contact:

Re: DarkGDK 2.0, a full-featured game engine for PureBasic!

Post by Olby »

GMS0012 wrote:does this work with the latest PB version (4.61)?
DarkGDK is dynamically linked wrapper so, yes, it works with all recent PB versions.
[blendman] wrote:But some examples are not working as they do. They works fine in dbpro (the same examples) :
- basic3d-4.exe
- light.exe
What exactly is not working? Is it crashing or not displaying anything? I just tested and it works fine under PB4.60 with DGDK 2.0 RC4.
Intel Core i7 Quad 2.3 Ghz, 8GB RAM, GeForce GT 630M 2GB, Windows 10 (x64)
User avatar
[blendman]
Enthusiast
Enthusiast
Posts: 297
Joined: Thu Apr 07, 2011 1:14 pm
Location: 3 arks
Contact:

Re: DarkGDK 2.0, a full-featured game engine for PureBasic!

Post by [blendman] »

Olby wrote:
[blendman] wrote:But some examples are not working as they do. They works fine in dbpro (the same examples) :
- basic3d-4.exe
- light.exe
What exactly is not working? Is it crashing or not displaying anything? I just tested and it works fine under PB4.60 with DGDK 2.0 RC4.
It isn't crashing, it's only a matter of display :
- there is no texture in the scene light, and some shaders are not displayed in the basic3D-4. I don't know why, because, all works in dbpro (the same scene), and the texture and shaders exist and are in the good directory.
Olby
Enthusiast
Enthusiast
Posts: 461
Joined: Mon Jan 12, 2009 10:33 am
Contact:

Re: DarkGDK 2.0, a full-featured game engine for PureBasic!

Post by Olby »

Mistrel said that disappearing shaders in basic4 example is fixed for next RC. It's because internal FX files where not "baked" into DLL. Meanwhile you can fix basic4 by copying necessary FX files from DarkGDK\engine\effects to executable folder.
[blendman] wrote:there is no texture in the scene light
If you're talking about the one in DarkGDK\examples\projects\purebasic\src\light\light-1.pb then it works fine here.
Intel Core i7 Quad 2.3 Ghz, 8GB RAM, GeForce GT 630M 2GB, Windows 10 (x64)
tj1010
Enthusiast
Enthusiast
Posts: 716
Joined: Mon Feb 25, 2013 5:51 pm

Re: DarkGDK 2.0, a full-featured game engine for PureBasic!

Post by tj1010 »

hnoor0055 wrote:some examples are not working as they do. They works fine in dbpro (the same examples)
Speaking as a long time follower of TGC(over a decade) don't look for fixes soon if at all.. I think a third of their products are technically abandoned now.

The only thing you get out of this anyway is the DirectX format which has better animation and level tools. PB is way better you just have a less supported format and all the converters are buggy.
Post Reply