A tip for anybody who will use this to call functions directly, it shouldn't benefit if you call a few functions, use it to replace a script or something as the DLL calling is still slow.
Yes, a single API call is slower than a single function call in gm so make sure the code you move to the dll does a lot of stuff. Then you will reap the benifits.
here's an example that loops though a buffer array to fill a list
export double FMODSnapShotToDsList(double startpos, double size, double ds)
{
if(size <1) {{FMODASSERT(FMOD_ERR_INVALID_PARAM);}}
if(size >1024) {{FMODASSERT(FMOD_ERR_INVALID_PARAM);}}
if(startpos <0) {{FMODASSERT(FMOD_ERR_INVALID_PARAM);}}
if(startpos >=1024) {{FMODASSERT(FMOD_ERR_INVALID_PARAM);}}
int endpos = (int)min(startpos+size,1024);
int i = 0;
float minv,maxv;
minv = 9999;
maxv = -9999;
for (i=(int)startpos;i<endpos;i++)
{
//samplebuffer[i] = (float)i/size;
minv = min(minv,samplebuffer[i]);
maxv = max(maxv,samplebuffer[i]);
ds_list_add(ds,samplebuffer[i]);
}
return (double)(maxv-minv);
}The list is populated by an ealier function
GM
l = ds_list_create();
FMODInstanceGetWaveSnapshot(instance,0,1024)
FMODSnapShotToDsList(0,1024,l)
i = 0
repeat(1024)
{
value = ds_list_find_value(l,i);
i+=1
}Here is an example of d3d model generation
d3d_model_primitive_begin(gmmodel,4);
numpointssaved = 0;
for (int i=start; i< end; i++)
{
if(numpointssaved>=nextsplit)
{
//write_line("1 0 0 0 0 0 0 0 0 0 0\r\n",f);
//write_line("0 4 0 0 0 0 0 0 0 0 0\r\n",f);
d3d_model_primitive_end(gmmodel);
d3d_model_primitive_begin(gmmodel,4);
nextsplit+=900;
}
fp1 = FACEPOINT(facepoints,i);
//code x y x nx ny nz u v col alpha
d3d_model_vertex_normal_texture(gmmodel, fp1->v.x+dx, fp1->v.y+dy, fp1->v.z+dz,
fp1->vn.x, fp1->vn.y, fp1->vn.z,
fp1->uv.x, fp1->uv.y);
numpointssaved++;
}
d3d_model_primitive_end(gmmodel);
Edited by icuurd12b42, 28 February 2009 - 04:53 AM.