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 »

All plugins compiled by third-parties that utilised GDKLib Builder.exe should recompile using the new version to ensure that all functions are built properly.
The new GDKLib Builder produces code that utilizes the same thread safety code that the Core DBP functions use.

Here is an example of how it works:

Code: Select all

PrototypeC ProtodbPhyUpdate()
ProcedureDLL dbPhyUpdate()
	Static Ptr
	;/ Synchronous mutex lock is done here in GDKLoadPtr
	If Not GDKLoadPtr(@Ptr,"DarkPhysics.dll","?dbPhyUpdate@@YAXXZ")
		ProcedureReturn 0
	EndIf
	If Not GDKDebuggerPresent()
		Function.ProtodbPhyUpdate=Ptr
		Function()
		GDKCheckRuntimeError()
		GDKCleanupFunctionCall()
		ProcedureReturn 0
	EndIf
	GDKMsgLong(Ptr, #Null)
	GDKCheckRuntimeError()
	;/ Mutex lock is released here
	GDKCleanupFunctionCall()
EndProcedure
Last edited by Mistrel on Thu Feb 12, 2009 9:30 pm, edited 1 time in total.
ale870
Enthusiast
Enthusiast
Posts: 180
Joined: Wed Jul 09, 2008 7:02 am
Contact:

Post by ale870 »

Thank you!
Thread safe will be one of the best features for me, since I don't like Dark Basic since there are huge problems in multithreading, and now multi-threading is a key-feature for a SDK for games (multi-CPU and multi-core usage).

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

Post by Mistrel »

ale870, if you want to do some thorough testing of compiling dlls with PureGDK I'll consider adding it as an official feature. The most important aspects are would be to ensure that error handling and thread safety work. I also need to know if it crashes if you do something unexpected, like call a dll function before OpenDBWnd, etc.
ale870
Enthusiast
Enthusiast
Posts: 180
Joined: Wed Jul 09, 2008 7:02 am
Contact:

Post by ale870 »

Mistrel, please explain me what can I do to help you.

Basically, my game will include HEAVY multithreading usage, parallel processes (I need to connect several separate processes to connect main game with newLisp engine). Furthermore, every newLisp engine is used as a DLL.

So...

Code: Select all

MAIN_GAME ->thread || --process-->SCRIPT_CORE-->newLisp.dll
1) "MAIN_GAME" is the "core" (rendering/sync() will run in a separated thread).

2) "thread" is a thread to manage connections with "SCRIPT_CORE" (separated PureBasic application, executed as a separate process).
There will be one thread per process. So If I will execute 4 newLisp virtual machines, then I will create 4 "threads" (they have a complex structure to work in parallel).

3) "SCRIPT_CORE" is the master application that will open/manage newLisp dll.

It is not so easy to be explained, but it works well (much better when thread-safe will become a reality :wink: )

I made a deep job to create a fast communication system between the processes (two-way async communication).
if you want to do some thorough testing of compiling dlls with PureGDK I'll consider adding it as an official feature.
Sorry for my english, but I cannot understand very well what you mean. But consider that I "moved" PureGDK engine from a DLL to the main application, but in a parallel thread.
Mistrel
Addict
Addict
Posts: 3415
Joined: Sat Jun 30, 2007 8:04 pm

Post by Mistrel »

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

Post by ale870 »

Ok, I see.
Now I have no more main loop - sync() inside a DLL.

But I will be able to test heavily concurrency, since my game is heavily multi-thread (multi core) based on.
ale870
Enthusiast
Enthusiast
Posts: 180
Joined: Wed Jul 09, 2008 7:02 am
Contact:

Post by ale870 »

Hello,

I made a demo but I cannot distribute the program. It seems something (like dll) is missing, but I cannot detect which is missing.
Consider I'm using advanced terrain and dark physics.

Do I need to distribute dll?
Mistrel
Addict
Addict
Posts: 3415
Joined: Sat Jun 30, 2007 8:04 pm

Post by Mistrel »

You'll need to be more specific. An example and an error would help.

You may be confusing a required dll with missing media files.
ale870
Enthusiast
Enthusiast
Posts: 180
Joined: Wed Jul 09, 2008 7:02 am
Contact:

Post by ale870 »

I'm sorry but I cannot reproduce it now, since I have no other pc (clean).
I'm sure no media is missing, since I made everything inside current dir, and if I copy program + other files in a new dir (in my computer) everything works.
Now I'm asking to a friend of mine to make a test.
I hope he will answer me soon.

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

Post by Mistrel »

Here it is! PureGDK 1.1 Beta1, finally. :)

This is an open beta so anyone who owns DarkBasic Professional 7.1. There is no nag screen like in the demo but it will expire after a couple of weeks.

http://PureGDK.com/files/upload/PureGDK ... 1-4.30.zip
http://PureGDK.com/files/upload/PureGDK ... es-7_1.zip

This release of PureGDK does not contain any documentation for the new commands added since 6.7. Please refer to your DarkBasic Professional documentation and the status bar hints instead.

There have been a lot of fundamental changes. Projects will need to be tweaked before they will compile with the new release. Please refer to the PureGDK documentation and also the example projects provided here.

Please uninstall your existing version of PureGDK first! There ARE conflicting files which will most likely cause projects not to compile.
PureGDK 1.1.0 Beta 1
====================

DarkBasic Professional 7.1 is the version officially supported by this release of PureGDK.

Bug Fixes:
- Several errors were corrected in the Styx framework library that prevented it from working properly.
- The PureGDK compiler will no longer get stuck due to an infinite include loop.
- Fixed a bug where a PureGDK application would fail to run on certain hardware configurations and crash silently at startup. This affects all previously compiled executables.
- Rewrote the PureGDK's cleanup routines to end more gracefully.
- Fixed a bug in dbHideMouse which caused it to fail.
- Runtime errors caused by PureGDK's internal functions will now call the PureBasic debugger or, if the debugger is off, identify the line number of the offending function in your PureBasic source code.
- Fixed a bug in GDKLib Builder.exe where it would build the function incorrectly if it returned a value and had only one parameter.
- Fixed bugs in various vector functions that caused problems when calling from threads and catching runtime errors.
- Updates have been made to GDKLib Builder.exe to support the new internal threadsafe functions. All third-party libraries must be rebuilt and recompiled using this new version to be compatible with PureGDK.
- Fixed a bug where commands with the parameters SSLL, SSL, and SS that returned a long would crash the executable.
- Fixed a bug where the PureGDK did not end cleanly, causing the PureBasic IDE to continue debugging after the program had already ended.
- Fixed a bug in dbSetObjectToObjectOrientation which caused it to fail. Also added missing parameter and updated documentation.
- dbMouseX() and dbMouseY() now work beyond the extents of the 3D screen. Some code may need to be modified to support the new values which can extend in the negative and positive outside the screen resolution.
- Fixed a bug in SyncRate which caused it to fail.
- Show/hide mouse will no longer lag when entering/exiting the client area of the render window.
- Fixed a bug which caused dbLightExist, dbLightType, and dbLightVisible to fail to return a value with the debugger off.

Updates:
- Removed redundant dbMessage command.
- The PureGDK functions for handling errors have changed. Please consult the 'How to... -> Reference Manual -> PureGDK' section of the documentation to see a list of revised commands.
- Most input commands for the keyboard and mouse are no longer limited to the client area of the render window. Some code may require changes to support this behavior.
- dbScanCode() is obsolete and has been removed. Use GetKeyState_() and MapVirtualKeyEx_() instead to obtain multiple scancodes asynchronously.
- dbCLS2 (Basic2D) has been renamed to dbCLSFill to prevent cross-library include conflicts with dbCLS from DBProCore.dll.
- PureGDK now supports changing the mouse using the SetCursor function of the Win32 API.
- The command dbSyncDelay has been removed to facilitate the changes made to OpenDBWnd which now require use of PureBasic's window event functions.
- Added missing command dbSetObjectMask
- DBP 6.9 Added new optional parameters to dbSetDisplayMode and dbCheckDisplayMode.
- DBP 6.9 Added new stereoscopic command dbSetCamerasStereoscopic.
- DBP 7.0 Added additional parameter Orientation to dbMakeObjectPlain
- DBP 7.0 Removed the obsolete commands dbTextureBackdrop and dbScrollBackdrop
- The compiler has been completely re-written and now includes a compile-time GUI
- Updated Newton Game Dynamics plugin commands for consistency where those that were preceded by NDB_Newton now begin with just NDB_
- DBP Added additional parameter SilentFail to dbLoadSound and dbLoad3DSound
- All PureGDK commands now use the same threadsafety code. Previously commands were only threadsafe while the debugger was off when compiling to a threadsafe executable.
- Added a new function dbGetActiveFunctions which will return the sum of all PureGDK functions currently waiting in queue. This is useful for debugging threadsafe executables that use PureGDK commands.
- Sounds are now loaded with the global flag set. This allows sounds to be played while the render window is a child of another window or changes parents during runtime. Unlike DBP's native command, this flag is not optional in PureGDK.
- Added mouse button 5 to dbMouseClick().
- dbSync functionality has been restored. It previously used only FastSync internally. Each Sync type should now function as expected.
- PureGDK no longer supports automatic thread cleanup. You must end all of your threads before ending the program or it will crash on exit. Additionally, exiting from within a user-defined thread is not supported by PureBasic and will also crash your executable.
- The following commands have been moved to the GameFX library:
* dbSetGlobalShadowsOn
* dbSetGlobalShadowsOff
* dbSetGlobalShadowColor
* dbSetShadowShades
* dbSetShadowPosition
* dbPerformCSGUnion
* dbPerformCSGDifference
* dbPerformCSGIntersection
* dbPerformCSGClip
- Revised command names (Commands moved to GameFX library included):
* dbPerformCSGUnion -> dbCSGUnion
* dbPerformCSGDifference -> dbCSGDifference
* dbPerformCSGIntersection -> dbCSGIntersection
* dbPerformCSGClip -> dbCSGClip
* dbPerformCSGUnionOnVertexData -> dbCSGUnionOnVertexData
* dbPerformCSGDifferenceOnVertexData -> dbCSGDifferenceOnVertexData
* dbPerformCSGIntersectionOnVertexData -> dbCSGIntersectionOnVertexData
* dbPerformCSGUnionOnVertexData -> dbCSGUnionOnVertexData
* dbPerformCSGDifferenceOnVertexData -> dbCSGDifferenceOnVertexData
* dbPerformCSGIntersectionOnVertexData -> dbCSGIntersectionOnVertexData
- New commands added for DBP 7.0
* dbMakeStaticObject
* dbMakeStaticLimb
* dbDeleteStaticObjects
* dbDeleteStaticObject
* dbSetStaticPortalsOn
* dbSetStaticPortalsOff
* dbBuildStaticPortals
* dbSetStaticObjectsWireframeOn
* dbSetStaticObjectsWireframeOff
* dbStaticLineOfSight
* dbGetStaticCollisionHit
* dbStaticRayCast
* dbStaticVolume
* dbGetStaticCollisionX
* dbGetStaticCollisionY
* dbGetStaticCollisionZ
* dbGetStaticCollisionCount
* dbGetStaticCollisionValue
* dbGetStaticCollisionFloor
* dbAddStaticObjectsToLightMapPool
* dbAddObjectToLightMapPool
* dbAddLightMapLight
* dbCreateLightMapS
* dbAddLimbToLightMapPool
* dbDeleteLightMapLightS
* dbAddStaticScorch
* dbLoadStaticObjects
* dbSetStaticScorch
* dbSetShadowLight
* dbReduceMesh
* dbAttachObjectToStatic
* dbDetachObjectFromStatic
* dbAddLODToObject
* dbSaveStaticObjects
* dbMakeStaticCollisionBox
* dbSetStaticUniverse
* dbFlushLightMaps
* dbCSGUnionOnVertexData
* dbCSGDifferenceOnVertexData
* dbCSGIntersectionOnVertexData

It is highly recommended that projects be recompiled with this update to ensure compatibility across all systems.

All plugins compiled by third-parties that utilized GDKLib Builder.exe should recompile using the new version to ensure that all functions are built properly.
Olby
Enthusiast
Enthusiast
Posts: 461
Joined: Mon Jan 12, 2009 10:33 am
Contact:

Post by Olby »

Hey these are excellent news! I am currently at work, so I cannot test it right away but have you included all the new commands from update 7.1 ? Like: TEXTURE SCREEN, SET SCREEN EFFECT or ADD MEMBLOCK TO OBJECT, GET MEMBLOCK FROM OBJECT, DELETE MEMBLOCK FROM OBJECT.
Intel Core i7 Quad 2.3 Ghz, 8GB RAM, GeForce GT 630M 2GB, Windows 10 (x64)
Mistrel
Addict
Addict
Posts: 3415
Joined: Sat Jun 30, 2007 8:04 pm

Post by Mistrel »

It would seem that I missed these commands since they were listed under the "help" section of the 7.1 changelog. I didn't do much research on the help changes since it wasn't a priority for the beta. I've made a note of this and will add them for the next release.

You've spotted the first bug and you haven't even downloaded it yet. :P

Only the commands listed here in the changelog have been added. I did my best to find them all.
Olby
Enthusiast
Enthusiast
Posts: 461
Joined: Mon Jan 12, 2009 10:33 am
Contact:

Post by Olby »

Nah man it's okay, I just know that it takes time to return to a project after some time so I just want to know that it contains everything required to work with it. As we dont know when you will have time to update it next time.

Okay no more talking going to test it out later today.
Intel Core i7 Quad 2.3 Ghz, 8GB RAM, GeForce GT 630M 2GB, Windows 10 (x64)
Olby
Enthusiast
Enthusiast
Posts: 461
Joined: Mon Jan 12, 2009 10:33 am
Contact:

Post by Olby »

Hey, I just installed it on my computer and run 'custom error handler' example. And after receiving the correct message box application just hung up and did not respond. As far as I can see it should terminate it self.. instead I focused on PureBasic IDE window and then the example spit out this message box:

Image

Oh and one more thing, is it okay that the command prompt is visible along with the GUI of the GDK compiler like this (I don't see a reason to show them both as the information displayed is duplicate):

Image
Intel Core i7 Quad 2.3 Ghz, 8GB RAM, GeForce GT 630M 2GB, Windows 10 (x64)
ale870
Enthusiast
Enthusiast
Posts: 180
Joined: Wed Jul 09, 2008 7:02 am
Contact:

Post by ale870 »

Hello,
first of all: thank you!
I just downloaded it and upgraded PureBasic.

Now I tried to install it but I get an installation error:

Couldn't copy the file.
c:\program files\The game creators\Dark basic online\compiler\effects\quad.fx


EDIT: I have no "quad.fx" file inside.
Post Reply