Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / DBPro Commands in DarkGDK ?

Author
Message
Mista Wilson
16
Years of Service
User Offline
Joined: 27th Aug 2008
Location: Brisbane, Australia
Posted: 27th Jul 2009 05:17
Hey All, Im actually wondering if it is possible to load and call DarkBasic Pro commands from inside C++ (DarkGDK) ?

Let me explain my reason for wanting to do this :

There are a number of commands that are available in DarkBasic Pro and have been for awhile, but they are either missing declerations or missing altogether from DarkGDK. These commands include(the ones im interested in getting at) :

dbSetObjectMask()
dbSetEffectConstantVectorElement()
dbGetObjectEffect()

I am able to "emulate" these commands in my programs, if getting at the DBPro equivilants is impossible. Its just that doing so is slightly painful and introducing more overhead that I would like, as for example, to emulate the Get Object Effect command, I need to track an array of object data - object numbers in relation to the effect applied and if it has one applied or not, and update/search it as the object is updated. The same with Set Object Mask, I can track the object in an array and know if the object needs to be masked and what masking value it is assigned by tracking its array entry(which would be a simple user type representing the data), then manually ecxlude the object before render and unexclude after render, but again, its alot more work to do and if there is a way around it I would like to know.

I believe that IanM wrote, many years ago now, a C++ Interface library for DBPro that allowed DBPro commands to be called from C++ before the time of DarkGDK(or DarkSDK as it was known). That interface library was discontinued and is no longer available, but im fairly sure that the techniques it used to get at the commands are what im looking for.

Any help is greatly appreciated, even if it is just to tell me that im barking up a dead end tree

If it ain't broke.... DONT FIX IT !!!
prasoc
15
Years of Service
User Offline
Joined: 8th Oct 2008
Location:
Posted: 27th Jul 2009 05:32
Try declaring them at the top of the file with the parameters, see if that works. It might be that they "gimp"ed dgdk and left out some commands tho...


Your signature has been erased by a mod
Mista Wilson
16
Years of Service
User Offline
Joined: 27th Aug 2008
Location: Brisbane, Australia
Posted: 27th Jul 2009 05:52
hehe yeah you are right there prasoc, there are a few that can be used if you add the forward decleration, and some that can be overloaded in the same way...

they include :

int dbCameraExist(int)
void dbAddLODToObject(int, float)
int dbGet3DMathsExist(int)
void dbSetShadowShadingOn(int, int, int, int)

and a few others that I cant remember off the top of my head, Ive actually asked in the GDK7.3 thread if anybody has a complete list at all of the missing commands.

The commands that I listed in my above post dont have an entry in the static library, and if you try to declare them it throws a missing external error when you call them(I havent tried too many capitalizations of the commands though yet, maybe ill find a few when i play with them some more).

My thoughts about my original question were kind of related to calling the DarkBasic Pro functions directly from their DLL's.

If it ain't broke.... DONT FIX IT !!!
Mista Wilson
16
Years of Service
User Offline
Joined: 27th Aug 2008
Location: Brisbane, Australia
Posted: 27th Jul 2009 08:37
I have a slightly more specific question aswell that I would appreciate if anybody could answer.

It has to do with the DBPro command :

Set Object Mask

The command itself, as far as I can tell, works on Objects in the same way that the command dbSyncMask(sync mask) works on cameras.

My question is, does anybody know of any way of emulating that functionality inside DarkGDK, either by a similar command or accessing the actual object internals via it's pointer and setting a flag or something..

So far, the only way I can think of emulating this command would be iterate through an object array(that would store if the object is masked and what its mask value is) with each camera being synced and check the object array's value against the camera sync value, then excludeOn or excludeOff manually as appropriate. I feel that doing it that way is going to introduce alot of unneeded overhead, having to iterate through an array entirely for multiple camera passes multiple times every game loop(or update cycle) is gonna hit somewhere...

And another specific command question about :

Set Effect Constant Vector Element

This command seems to just set a vector element that belongs to an effect, rather than the whole vector itself. Firstly, is that what it's doing, and if it is, is there an easy way to emulate that functionality ? Im thinking along the lines of getting the vector elements that are not going to be changed and sending the entire vecotor back to the shader , with just the changed element changed and the other elements left how they were.

If it ain't broke.... DONT FIX IT !!!
prasoc
15
Years of Service
User Offline
Joined: 8th Oct 2008
Location:
Posted: 27th Jul 2009 13:26
What are the parameters in dbp for set effect constant vector element?


Your signature has been erased by a mod
Mista Wilson
16
Years of Service
User Offline
Joined: 27th Aug 2008
Location: Brisbane, Australia
Posted: 27th Jul 2009 13:44
in DBPRO :

set effect constant vector element (string, integer, integer)

without the braces, it doesnt return a value...

in GDK i assume it would be something like :

dbSetEffectConstantVectorElement(char*, int, int);

If it ain't broke.... DONT FIX IT !!!
prasoc
15
Years of Service
User Offline
Joined: 8th Oct 2008
Location:
Posted: 27th Jul 2009 13:54
In the deffered lighting, what does the "set effect constant vector" actually set inside the .fx file?


Your signature has been erased by a mod
Mista Wilson
16
Years of Service
User Offline
Joined: 27th Aug 2008
Location: Brisbane, Australia
Posted: 27th Jul 2009 15:20
well, it depends on the actual shader that you are sending it to of course... and whether it is a vector4 or a vector3 or whatever type...

Basically a vector can be thought of as a data structure that contains sets of numbers... 3 in the case of a vector3 and 4 nithe case of a vector 4....

They are usually named - x, y, z, w -- with "w" being the 4th in a vector4.

They are generally used to set variables inside shaders that represent angles that something is looking at or pointing at, or where something is positioned, aswell as things like texture co-ordinates...

For example, in one of the Advanced Terrain shaders that I use(it was written by Green Gandalf btw) there is an effect constant called "lightDir" which tells the shader which direction the light is coming from on the terrain, you set that constant with the call to dbSetEffectConstantVector .. passing it a vector..

you might make a vector like so :

int iNull = dbMakeVector4(1);

then you would set it's values :

dbSetVector4(1, 1.0, 1.0, 1.0, 1.0); - notice the first integer value is the "ID" of the vector(in GDK 3D maths objects like vectors and matrices have ID's like 3d objects do), the following 4 paramerters represent the x, y, z and w values.

once the vector is set, it is passed to a function like so :

dbSetEffectConstantVector(1, "lightDir", 1); the parameters for that command are :

the first integer is the ID of the effect
the second character array is the contant name within the shader
the third and last parameter is the ID of the vector you are sending to the shader.

It is not only Vectors that are used with shaders though, we can also send them Matrix values from a matrix object with :

dbSetEffectConstantMatrix(); it has similar syntax to the vector one, it just takes a matrix object instead, however, matrices in shaders are generally used for things like projection matrix calculations and things...

Hope this answers your question, im pretty new to shaders myself so i may be off on some of the info.

If it ain't broke.... DONT FIX IT !!!
prasoc
15
Years of Service
User Offline
Joined: 8th Oct 2008
Location:
Posted: 27th Jul 2009 15:43
Couldn't instead of just setting 1 vector element, set all of the values (and just change the element needing changing) and using dbSetEffectConstantVector(), thus not needing to update one part of the vector?


Your signature has been erased by a mod
Mista Wilson
16
Years of Service
User Offline
Joined: 27th Aug 2008
Location: Brisbane, Australia
Posted: 27th Jul 2009 15:52 Edited at: 27th Jul 2009 16:05
Yep, that was my thought exactly on how to emulate it Great minds think alike hey

from my above post buried somewhere near the bottom lol :
Quote: "Im thinking along the lines of getting the vector elements that are not going to be changed and sending the entire vector back to the shader , with just the changed element changed and the other elements left how they were.
"


EDIT : was thinking of using a function like this :



That function I pulled from Jason Sage's JGC library in the form of "GetMatrixElement" .. but the same logic can be applied to get an element of any kind of vector or matrix. The function works to pull an element value from a vector or matrix(depending on the element clamps) - I think ill re-write it to be more generic and operate on whatever I pass it based on clamping values that will be passed to it instead of hardcoded like they are.

From there it's just a matter of setting the vector's changed element and sending it back to the shader. I hope lol..

btw, I have finished the code port of the deferred shading library, im just working on getting all the systems of it working now, need to get object masking implemented and sort out this vector element thing. hopefully then it should all be working

If it ain't broke.... DONT FIX IT !!!
prasoc
15
Years of Service
User Offline
Joined: 8th Oct 2008
Location:
Posted: 27th Jul 2009 16:19
Whoops. Didn't notice that line I don't really know about that object mask problem because I have never used the camera sync mask before, but it looks like you are making lots of progress with the shade so big up


Your signature has been erased by a mod
Mista Wilson
16
Years of Service
User Offline
Joined: 27th Aug 2008
Location: Brisbane, Australia
Posted: 27th Jul 2009 18:42
I should post this here aswell as we were discussing it, but I was completely mistaken in my assumption about how the command works :

set effect constant vector element

It has nothing at all to do with setting individual vector elements.
DarkShader shaders that are for lighting store multiple lights in arrays of float4's.
the "element" that is being set is one of the array elements, which hoses my idea about setting it manually.

Although, ive come up with a couple of workaround that will let me get done what I need, one way or another lol.. I posted details in my shader thread.

Apologies if I misled anybody with my incorrect assumption about the above command.

If it ain't broke.... DONT FIX IT !!!
prasoc
15
Years of Service
User Offline
Joined: 8th Oct 2008
Location:
Posted: 27th Jul 2009 19:04
Eee WHY did they not put these commands in?! I guess it would be in there if it was a paid for product, but it's free...


Your signature has been erased by a mod
Phosphoer
16
Years of Service
User Offline
Joined: 8th Dec 2007
Location: Seattle
Posted: 27th Jul 2009 19:14
Well it didn't have the commands back when it was a paid product.

Login to post a reply

Server time is: 2024-10-01 08:38:18
Your offset time is: 2024-10-01 08:38:18