PureGDK - 3D Programming 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

Post by Mistrel »

Check out the help file from the IDE: Help -> External Help -> PureGDK.chm.

Then look at: How to... -> How to use TCP plugins with PureGDK
PureGDK is distributed with a number of pre-compiled framework libraries for commercial and popular user plugins. These libraries will not work without copying the original plugin DLL to the PureGDK application data folder.

To install a commercial plugin for use with PureGDK you may be required to have DarkBasic Professional installed. After the installation simply copy the plugin DLLs from the DarkBasic Professional compiler folder into its corresponding plugin folder (plugins-licensed or plugins-user) in the PureGDK appication data folder. You can also install them for DarkBasic Professional and run the PureGDK installer to copy them over. Plugins will work with PureGDK only if they have a corresponding framework library installed as a PureBasic userlibrary. For more information about how to create a userlibrary see the How to... -> How to use the PureGDK plugin framework section of the PureGDK documentation.

GDKTables and sources for the plugins supported by PureGDK are provided in the plugin-sdk\Supported Plugins folder of your PureGDK installation.

A command list for each plugin is provided in its corresponding Syntax.txt. See the plugin's folder in the plugin-sdk\Supported Plugins folder of your PureGDK installation for more information.

PureGDK provides framework user libraries for the following plugins:

Licensed Plugins:

2D Plugin Kit 1.1
3D Cloth & Particles Physics 6.2
Advanced Terrain
Dark Physics Beta 14-12-07
Dark AI 1.05
Dark Lights 1.02
Enhanced Animations 19-11-07
eXtends 1.4
EZ Rotate Enhanced 19-11-07
STYX 2.0
TextureMax 17-05-07
Unity 3.0

Free Plugins:

D3DFunc 3.6.6
DarkSide Starburst
DBP Collisions 2.04
DKAVM 12-07-06
DKSHOP 12-07-06
EZ Rotate Basic
Multisync 1.4.1
Newton Game Dynamics 1.3.2
zParticles 1.11

These user libraries may not include a conversion of the entire command set. Please refer to the Changes.txt and Syntax.txt for a list of supported commands and information on those commands which might have changed.

Each of these command libraries has been tested for functionality. Not every command has been tested and functionality of every command is not guaranteed. If you do encounter a problem getting any of these plugins to work with PureGDK please contact support@puregdk.com.
There is a problem with the Newton Game Dynamics plugin where it causes corruption in memory when calling NDB_NewtonDestroy(). I've been bending over backwards trying to make it work with PureGDK but I'm considering removing support for it if I can't find a work-around. I think the problem is in Newton.dll rather than the wrapper itself.

Newton works with the current release of PureGDK, if you still want to play with it. But it might cause your executable to crash on exit.
ale870
Enthusiast
Enthusiast
Posts: 180
Joined: Wed Jul 09, 2008 7:02 am
Contact:

Post by ale870 »

Newton works with the current release of PureGDK, if you still want to play with it. But it might cause your executable to crash on exit.
I work in Win Vista and I found a demo of newton and happened what you said: the program crashes when it quits.

I can use Ageia since I hve registered verions of Dark Basic Physics module, but my only problem is sometimes ago I tried to make a good vehicle (with good suspensions, dampers, etc... plus vehicles with more than 4 tires) but I found many problems and bad behaviours. Instead I know that Newton works great with vehicles.

Can you give me some hints how to make a god vehicle in Ageia (darkbasic physics module)?

Generally speaking, have you any example to see how to use PureGDK for physics Ageia? (I downloaded the examples in the homepage of PureGDK but I could not find anything related to physics).

Thank you!
Mistrel
Addict
Addict
Posts: 3415
Joined: Sat Jun 30, 2007 8:04 pm

Post by Mistrel »

The executable may crash when it's closing. It's perfectly stable while it's running. I believe this is due to heap corruption somewhere when the library frees its resources. This is not actually a PureGDK issue. It's a bug in either NDB or Newton.dll.

Here is the FPS example converted to PureGDK. You'll need to install NDB.dll as a plugin to compile (see help documentation).

http://puregdk.com/files/upload/NGDdemo05.zip
Lykaestria
User
User
Posts: 76
Joined: Wed Sep 17, 2008 3:10 am
Location: New Zealand

Post by Lykaestria »

need any more beta testers? :)
Give a man a fire, and he’ll be warm for a day. Set a man on fire, and he’ll be warm for the rest of his life.
ale870
Enthusiast
Enthusiast
Posts: 180
Joined: Wed Jul 09, 2008 7:02 am
Contact:

Post by ale870 »

I made some tests with the last demo.
I noticed that the program crash when exit, but it works very well during execution.
Later I will check how to create a vehicle, and I will compare it with Ageia. This is very important since I'm creating an indie game developer framwork and I need to decide which physics engine to support.

I will send you any feedback/bugs found.

One question: do I post all problems in this area or you prefer to create another area about PureGDK?
ale870
Enthusiast
Enthusiast
Posts: 180
Joined: Wed Jul 09, 2008 7:02 am
Contact:

Post by ale870 »

Well, I have one question, plu I noticed a strange behaviour.

QUESTION:

How can I do to make a fullscreen program? In DarkGDK they use dbSetDisplayMode(640, 480, 32) but PureBasic crash. Instead if I use it after OpenDBWnd I get a window (not fullscreen).

STRANGE BEHAVIOUR:

dbSyncRate() does not work when I'm in window.

=========
EDIT:
=========
It seems in DBPro they use dbSetWindowOff() but this function does not exist in PureGDK.
Mistrel
Addict
Addict
Posts: 3415
Joined: Sat Jun 30, 2007 8:04 pm

Post by Mistrel »

ale870 wrote:One question: do I post all problems in this area or you prefer to create another area about PureGDK?
According to the PureGDK manual: 'All DarkBasic commands will be ignored at runtime until OpenDBWnd() has been called.'

This is under the 'Known Issues' section, which isn't really a good place for it, since you can't call any DBP function until after opening the window by design.
ale870 wrote:How can I do to make a fullscreen program? In DarkGDK they use dbSetDisplayMode(640, 480, 32) but PureBasic crash. Instead if I use it after OpenDBWnd I get a window (not fullscreen).
You can't call DBP commands until after you open the window with OpenDBWnd. The reason for this is that PureGDK needs to initialize everything internally. It also needs to know what resolution to open the window with. This is a bug that it crashes, it should just return silently.

In the manual you'll see that dbSetWindowOff()\On is obsolete. If you need a borderless window either open the DBP window with #GDK_Window_BorderLess or change its style with SetWindowLong_ and #GWL_STYLE and #GWL_EXSTYLE. To make it fullscreen set it to the desktop height/width and use window API to move it OnTop. I should probably make a function for that, since it's a little obscure.
dbSyncRate() does not work when I'm in window.
This is a known issue and it being looked into. I think it works in with the debugger and not without or vice-versa. If you need a sync rate you can make your own by counting the elapsed milliseconds and use Delay() until maximum number of frames has been reached.
ale870 wrote:One question: do I post all problems in this area or you prefer to create another area about PureGDK?
You can post it here or e-mail me at support@puregdk.com. Normally e-mail is better but I'm checking these posts more often because of the upcoming release.
ale870
Enthusiast
Enthusiast
Posts: 180
Joined: Wed Jul 09, 2008 7:02 am
Contact:

Post by ale870 »

In the manual you'll see that dbSetWindowOff()\On is obsolete. If you need a borderless window either open the DBP window with #GDK_Window_BorderLess or change its style with SetWindowLong_ and #GWL_STYLE and #GWL_EXSTYLE. To make it fullscreen set it to the desktop height/width and use window API to move it OnTop. I should probably make a function for that, since it's a little obscure.
I'm sorry but this is not a full screen. Full screen is not a window as large as the screen (if I understood well what you said).
I need (and most games need it) a real fullscreen system.
Furthermore imagine that I usually work at 1680x1050, but a real game, on my videocard, cannot run to that resolution (too high for my card! My card cannot get me good performance at that resolution).
Mistrel
Addict
Addict
Posts: 3415
Joined: Sat Jun 30, 2007 8:04 pm

Post by Mistrel »

PureGDK supports fullscreen but not in exclusive mode. Exclusive mode means that the application is the only one receiving the events and has exclusive control of the machine.

You'll notice that even with DBP you can't use debug mode and fullscreen exclusive at the same time.

Depending on driver support windowed mode can perform the same as fullscreen. There are very few advantages to exclusive mode, none of which are taken advantage of by DBP.

Code: Select all

Procedure SetResolution(Width, Height, Depth, Flag=#CDS_FULLSCREEN)
  Protected Result,dmScreenSettings.DEVMODE
  dmScreenSettings\dmSize=SizeOf(DEVMODE)
  dmScreenSettings\dmPelsWidth=Width
  dmScreenSettings\dmPelsHeight=Height
  dmScreenSettings\dmBitsPerPel=Depth
  dmScreenSettings\dmFields=#DM_PELSWIDTH|#DM_PELSHEIGHT|#DM_BITSPERPEL
  If ChangeDisplaySettings_(@dmScreenSettings, Flag)=#DISP_CHANGE_SUCCESSFUL
    Result=#True
  EndIf
  ProcedureReturn Result
EndProcedure

SetResolution(1280,1024,32)
Delay(3000)
The screen resolution will change back when your program ends.
Last edited by Mistrel on Mon Nov 10, 2008 11:46 pm, edited 3 times in total.
ale870
Enthusiast
Enthusiast
Posts: 180
Joined: Wed Jul 09, 2008 7:02 am
Contact:

Post by ale870 »

I'm sorry but, do you mean I cannot run my game in 800x600x32 fullscreen even in DBP?! If my windows is set to 1680x1050 I need a way to get a fullscreen to (for example) at 800x600x32 (or other compatible resolution).
Game fullscreen (not in debug) should be set independently from Windows resolution (like in any game).
How can I do that?
Mistrel
Addict
Addict
Posts: 3415
Joined: Sat Jun 30, 2007 8:04 pm

Post by Mistrel »

Code: Select all

Procedure SetResolution(Width, Height, Depth, Flag=#CDS_FULLSCREEN)
  Protected Result,dmScreenSettings.DEVMODE
  dmScreenSettings\dmSize=SizeOf(DEVMODE)
  dmScreenSettings\dmPelsWidth=Width
  dmScreenSettings\dmPelsHeight=Height
  dmScreenSettings\dmBitsPerPel=Depth
  dmScreenSettings\dmFields=#DM_PELSWIDTH|#DM_PELSHEIGHT|#DM_BITSPERPEL
  If ChangeDisplaySettings_(@dmScreenSettings, Flag)=#DISP_CHANGE_SUCCESSFUL
    Result=#True
  EndIf
  ProcedureReturn Result
EndProcedure

; Set the display resolution
SetResolution(800,600,32)

; Show the PureGDK render window
hDBWnd=OpenDBWnd(0,0,800,600,32,#GDK_Window_BorderLess)

; Set the window to the to the top of the z-order
SetWindowPos_(hDBWnd,#HWND_TOPMOST,0,0,0,0,#SWP_NOREPOSITION|#SWP_NOSIZE)

; Set the sync rate
dbSyncRate(60)

dbMakeObjectCube(1,3)

; Rotate the cube and update the screen
Repeat: Delay(1)
 x.f+0.2: y.f+0.4: z.f+0.8
 dbRotateObject(1,x.f,y.f,z.f)
 dbSync()
Until Not dbInKey()=""
End
You'll want to use EnumDisplaySettings_() to identify supported resolutions. See here for more examples:

http://www.purebasic.fr/english/viewtopic.php?t=32030
ale870
Enthusiast
Enthusiast
Posts: 180
Joined: Wed Jul 09, 2008 7:02 am
Contact:

Post by ale870 »

Thank you!
This trick is very good!
Even if this is not a real full screen, but it is used by many games :wink:

Well, this is a good starting point, I'm satisfied.
I didn't know the structure DEVMODE. Thank you for this too.

Thank you even for your quick reply and for your help.
I'm confident that I will be able to successfully continue with my project using PureGDK :D since your support is very good and responsive, and you really help the people to solve their technical problems.
I think this is a great value for a product!

========
EDIT
========

I'm sorry if I pushed some "pressure", but I cannot imagine a real game (e.g. an FPS) running only in a window (and not in a kind of fullscreen).
ale870
Enthusiast
Enthusiast
Posts: 180
Joined: Wed Jul 09, 2008 7:02 am
Contact:

Post by ale870 »

Hello again!
I found another "problem": it is not possible to make a DLL if PureGDk is included :cry:

Is there any way to eliminate this problem? I really need to make game engine as DLL.

Thank you.
ale870
Enthusiast
Enthusiast
Posts: 180
Joined: Wed Jul 09, 2008 7:02 am
Contact:

Post by ale870 »

Solved!

I discovered that only initialization system cannot stay inside a DLL, instead I can include PureGDK functions inside a DLL.

See the following example.

This is my DLL (I called it my_dll.dll):

Code: Select all

Global x.f
Global y.f
Global z.f

ProcedureDLL rotateMyObject(argObjID.l, *coord)
    x+0.1
    y+0.2
    z+0.3
    dbRotateObject(argObjID, x, y, z)
    
    PokeF(*coord, x)
EndProcedure
Main code (in order to load and call the procedure f1() ):

Code: Select all

Global coord1.f

OpenLibrary(1, "my_dll.dll")
CallFunction(1, "rotateMyObject", 1, @coord1)
My example even show how to return a value (float) from the DLL to the main program (coord1).

PureGDK rocks!
Mistrel
Addict
Addict
Posts: 3415
Joined: Sat Jun 30, 2007 8:04 pm

Post by Mistrel »

Actually, I never tried that before. I'm really surprised it even worked. But I guess technically it would work.. ? :shock:

You're calling the DLL from inside of PureBasic, right?

This is a really interesting side-effect. The PureGDK compiler will only warn you that you cannot compile to a DLL if OpenDBWnd is not found. This is because I only search for that string in a single pass rather than checking against all of the available db commands to speed up the pre-parser.

I just ignore normal db functions because if OpenDBWnd is never called then these functions return harmlessly. But if you manage to get them into a DLL.. I guess it would work.

This is complete luck and a brilliant find.

Just as an FYI you can't use this method to build actual DBP plugins. So don't even try. :)

Just know that there is no dependency checking when compiling to a DLL so if the plugin required by the function is not found it will return harmlessly but may cause your code to do something strange if you expected it to work.

For example, you wouldn't be able to use dbMakeObjectCube without the 3D library being included.
Last edited by Mistrel on Tue Nov 11, 2008 10:35 pm, edited 1 time in total.
Post Reply