PureGDK - 3D Programming for PureBasic

Developed or developing a new product in PureBasic? Tell the world about it.
ale870
Enthusiast
Enthusiast
Posts: 180
Joined: Wed Jul 09, 2008 7:02 am
Contact:

Post by ale870 »

I think I found another problem: it seems the function dbPhySetAutoFixedTiming() but general movement seems acting slowly, like a "slow-motion" effect.
Gravity seems set as if I were on the moon :D

Please give me a feedback about it.

NOTE: I made the following function as a workaround to sync rate issue (and it works very well):

Code: Select all


Repeat 
    QueryPerformanceCounter_(@counter)
    millisecs = ( (counter - oldCounter) / freq )
    Delay(0)
  Until millisecs >= 0.0166667
Setup, before main loop isthe following:

Code: Select all

Global counter.q
Global oldCounter.q

Global freq.q

Global millisecs.f

QueryPerformanceFrequency_(@freq)
Thank you.
Mistrel
Addict
Addict
Posts: 3415
Joined: Sat Jun 30, 2007 8:04 pm

Post by Mistrel »

Are you certain that the Dark Physics issue is related to PureGDK?
ale870
Enthusiast
Enthusiast
Posts: 180
Joined: Wed Jul 09, 2008 7:02 am
Contact:

Post by ale870 »

I think so, since I made a test on an existing demo in DBPro (there is a demo just to show this feature: apply physics even with different frame rates) and it seems it works,.

I don't know if there could be problems related to DLL version (maybe DBPro uses updated DLL?), or similar.

If you can, check DBPro example in "DarkPhysics" folder. There is a demo for frame rate test.

If you want I can send you my texst, source code included, and you can use it to make some tests.
Please let me know,

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

Post by Mistrel »

That would be find but I don't need it right this minute. Now that the compiler is done I need to go back and cleanup all of the little things I have here in a list. Then I'll recompile everything for the beta and I'll be ready for more bugs like these.

I'm trying to wrap things up for a beta release before adding new bugs to my list which may have already been fixed.
ale870
Enthusiast
Enthusiast
Posts: 180
Joined: Wed Jul 09, 2008 7:02 am
Contact:

Post by ale870 »

Ok, tell me if (and when!) you will be able to check it.
I will keep my demo in case you will need it.

I'll wait for good news :wink:

Thank you.
Olby
Enthusiast
Enthusiast
Posts: 461
Joined: Mon Jan 12, 2009 10:33 am
Contact:

Post by Olby »

Very nice to see you Mistrel working heavily on this! I am going to port my engine from DBPro to PureGDK so there should be definitely some real bulletproof test for PureGDK. I will try to report all bugs I encounter with it. But I can only start when I get support for version 7.1 of DBPro as I use some of the features from the latest releases.
ale870
Enthusiast
Enthusiast
Posts: 180
Joined: Wed Jul 09, 2008 7:02 am
Contact:

Post by ale870 »

Hello,

I wish to show you my first advanced terrain + Dark Physics enabled, realized in PureBasic & PureGDK:

Image

Image

Image

Image

Image

The ball is physics enabled.

Thank you Mistrel for your help!

One suggestion: I think you need to open a wiki, so everybody could participate to fill the documentation, send tips & tricks, demos, tutorials, etc...
ale870
Enthusiast
Enthusiast
Posts: 180
Joined: Wed Jul 09, 2008 7:02 am
Contact:

Post by ale870 »

Hello,

I need to modify the vertex of a terrain:

Code: Select all

dbMakeObjectTerrain(terrainId)        
   <more code...>
dbBuildTerrain(terrainId)
I need to change vertex since I need to attach many terrains one near each other. So I need to "align" vertex on the edges (boundaries).
The problem is when I use dbLockVertexDataForMesh(terrainId) my program crash!

Can you suggest me a way to change vertex?

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

Post by Mistrel »

A wiki is a good idea but I'm not sure there are enough PureGDK users who will actually take part in a community documentation.

Look at: "dbLockVertexDataForMesh(terrainId)". It requires a mesh ID but you're passing a terrain ID. The crash is probably a DBP crash and not a PureGDK one. Always try using functions like dbMeshExist() to confirm that you're passing the correct type to a function like this.

I'm glad to see you got DarkPhysics and Advanced Terrain to work. What was the problem specifically?
Last edited by Mistrel on Sat Jan 17, 2009 8:05 pm, edited 1 time in total.
ale870
Enthusiast
Enthusiast
Posts: 180
Joined: Wed Jul 09, 2008 7:02 am
Contact:

Post by ale870 »

Ok, thank you! I didn't see wrong argument parameters. Sorry!
Olby
Enthusiast
Enthusiast
Posts: 461
Joined: Mon Jan 12, 2009 10:33 am
Contact:

Post by Olby »

Hey Mistrel, how far are you with releasing the latest version of PGDK? I am eagerly waiting to start coding! :P
Mistrel
Addict
Addict
Posts: 3415
Joined: Sat Jun 30, 2007 8:04 pm

Post by Mistrel »

I just finished adding all of the new commands introduced by 6.9 and 7.0.

There are also a few tweaks like the mouse button command now supporting 5 buttons instead of 3 and dbMouseX() and dbMouseY() now work outside the bounds of the DBP window.
ale870
Enthusiast
Enthusiast
Posts: 180
Joined: Wed Jul 09, 2008 7:02 am
Contact:

Post by ale870 »

Thank you Mistrel! Updated information are always welcome :D
ale870
Enthusiast
Enthusiast
Posts: 180
Joined: Wed Jul 09, 2008 7:02 am
Contact:

Post by ale870 »

Hi,

I'm starting to use shaders, but as soon as I use the function dbSetObjectEffect(terrainId, myEffect) the program crash.
Since I'm new in shaders, and I'm using a pre-made shader, can you help me to find the problem?

This is my code:


Code: Select all

Global myEffect.l = 1
dbLoadEffect("BasicLightMapping.fx", myEffect, 0)

.. load models, and do something else...

    If dbEffectExist(myEffect)
      dbSetObjectEffect(terrainId, myEffect)
      dbTextureObject(terrainId, 0, 100001)
      dbTextureObject(terrainId, 1, 100002)
    Else
      MessageRequester("d", "Error. Cannot load/use the shader.")
    EndIf



This is the shader:

Code: Select all

//
// Very basic shader for blending a diffuse texture with ambient light and a
// lightmap written by Green Gandalf 31 March 2007.
//

float4x4 wvp    : WorldViewProjection;

float4  ambient = {1.0, 1.0, 1.0, 1.0};
float4  blend1  = {0.3, 0.3, 0.3, 1.0};
float4  blend2  = {0.7, 0.7, 0.7, 1.0};

texture diffuseTex < string ResourceName=""; >;
texture lightMap   < string ResourceName=""; >;

sampler2D diffuseSamp = sampler_state { texture = <diffuseTex>; };
sampler2D lightMapSamp = sampler_state { texture = <lightMap>; };

struct VSInput
{ float4 pos : Position;
  float2 UV0 : Texcoord0;
  float2 UV1 : Texcoord1;
};

struct VSOutput
{ float4 pos : Position;
  float2 UV0 : Texcoord0;
  float2 UV1 : Texcoord1;
};

struct PSInput
{ float2 UV0 : Texcoord0;
  float2 UV1 : Texcoord1;
};

struct PSOutput
{ float4 col : Color;
};

VSOutput VShader(VSInput In, VSOutput Out)
{ Out.pos = mul(In.pos, wvp);
  Out.UV0 = In.UV0;
  Out.UV1 = In.UV1;
  return Out;
}

PSOutput PShader(PSInput In, PSOutput Out)
{ float4 diffuse = tex2D(diffuseSamp, In.UV0);
  float4 lighting = tex2D(lightMapSamp, In.UV1);
  Out.col = diffuse * (ambient * blend1 + lighting * blend2);
  return Out;
}

technique basicLightMap
{ pass p0
  { vertexShader = compile vs_1_1 VShader();
    pixelShader = compile ps_1_4 PShader();
  }
}
[/code]
Olby
Enthusiast
Enthusiast
Posts: 461
Joined: Mon Jan 12, 2009 10:33 am
Contact:

Post by Olby »

As it seems you are trying to apply a shader on terrain. And if you used internal terrain generating commands terrains differ from standard objects and thus cannot have effects on them. Best way to achieve this is to use DBO objects instead of internal terrains.
Post Reply