maybe the line:
f = *st / (artsp * w * h);
gives bad results. that (I think - not sure) should maybe be:
f = &st / (artsp * w * h);
?
If you can provide the function with sizes of the texture and frame in pixels, this might work:
/*
** RB_CalcAtlasTexCoords - a bit ported from darkplaces
assuming:
frame -> frame to find in atlas
w -> width of the atlas in pixels
h -> height of the atlas in pixels
framew -> single frame width in pixels
frameh -> single frame height in pixels
*/
void RB_CalcAtlasTexCoords( const int frame, const int w, const int h, const int framew, const int frameh, float *st )
{
int x,y;
int cols, rows;
float tx,ty;
cols=w/framew;
rows=h/frameh;
x=frame%cols;
y=(frame-x)/rows;
tx=x/cols;
ty=y/rows;
for ( i = 0; i < tess.numVertexes; i++ )
{
st[i*2] = tx;
st[i*2+1] = ty;
}
}
but this will calculate only the top left corner coordinate of the atlas frame requested... I'm not sure why the loop it there
hope this helps..