From 0457333f55c015e0c972c9338b0a8c94d7b32359 Mon Sep 17 00:00:00 2001 From: Philip Nilsson Date: Fri, 21 Mar 2008 00:33:45 +0100 Subject: [PATCH] d3dx9: Implement the D3DXVec*Array functions. --- dlls/d3dx9_36/Makefile.in | 3 +- dlls/d3dx9_36/d3dx9_36.spec | 18 ++-- dlls/d3dx9_36/math.c | 195 ++++++++++++++++++++++++++++++++++++ include/d3dx9math.h | 9 ++ 4 files changed, 215 insertions(+), 10 deletions(-) create mode 100644 dlls/d3dx9_36/math.c diff --git a/dlls/d3dx9_36/Makefile.in b/dlls/d3dx9_36/Makefile.in index c4cdbb46423..2ed85ea4140 100644 --- a/dlls/d3dx9_36/Makefile.in +++ b/dlls/d3dx9_36/Makefile.in @@ -8,7 +8,8 @@ IMPORTS = d3d9 d3dx8 kernel32 C_SRCS = \ d3dx9_36_main.c \ - font.c + font.c \ + math.c @MAKE_DLL_RULES@ diff --git a/dlls/d3dx9_36/d3dx9_36.spec b/dlls/d3dx9_36/d3dx9_36.spec index 46c7cd5d27f..e616d233d33 100644 --- a/dlls/d3dx9_36/d3dx9_36.spec +++ b/dlls/d3dx9_36/d3dx9_36.spec @@ -307,30 +307,30 @@ @ stdcall D3DXVec2Hermite(ptr ptr ptr ptr ptr long) d3dx8.D3DXVec2Hermite @ stdcall D3DXVec2Normalize(ptr ptr) d3dx8.D3DXVec2Normalize @ stdcall D3DXVec2Transform(ptr ptr ptr) d3dx8.D3DXVec2Transform -@ stub D3DXVec2TransformArray +@ stdcall D3DXVec2TransformArray(ptr long ptr long ptr long) @ stdcall D3DXVec2TransformCoord(ptr ptr ptr) d3dx8.D3DXVec2TransformCoord -@ stub D3DXVec2TransformCoordArray +@ stdcall D3DXVec2TransformCoordArray(ptr long ptr long ptr long) @ stdcall D3DXVec2TransformNormal(ptr ptr ptr) d3dx8.D3DXVec2TransformNormal -@ stub D3DXVec2TransformNormalArray +@ stdcall D3DXVec2TransformNormalArray(ptr long ptr long ptr long) @ stdcall D3DXVec3BaryCentric(ptr ptr ptr ptr long long) d3dx8.D3DXVec3BaryCentric @ stdcall D3DXVec3CatmullRom(ptr ptr ptr ptr ptr long) d3dx8.D3DXVec3CatmullRom @ stdcall D3DXVec3Hermite(ptr ptr ptr ptr ptr long) d3dx8.D3DXVec3Hermite @ stdcall D3DXVec3Normalize(ptr ptr) d3dx8.D3DXVec3Normalize @ stdcall D3DXVec3Project(ptr ptr ptr ptr ptr ptr) d3dx8.D3DXVec3Project -@ stub D3DXVec3ProjectArray +@ stdcall D3DXVec3ProjectArray(ptr long ptr long ptr ptr ptr ptr long) @ stdcall D3DXVec3Transform(ptr ptr ptr) d3dx8.D3DXVec3Transform -@ stub D3DXVec3TransformArray +@ stdcall D3DXVec3TransformArray(ptr long ptr long ptr long) @ stdcall D3DXVec3TransformCoord(ptr ptr ptr) d3dx8.D3DXVec3TransformCoord -@ stub D3DXVec3TransformCoordArray +@ stdcall D3DXVec3TransformCoordArray(ptr long ptr long ptr long) @ stdcall D3DXVec3TransformNormal(ptr ptr ptr) d3dx8.D3DXVec3TransformNormal -@ stub D3DXVec3TransformNormalArray +@ stdcall D3DXVec3TransformNormalArray(ptr long ptr long ptr long) @ stdcall D3DXVec3Unproject(ptr ptr ptr ptr ptr ptr) d3dx8.D3DXVec3Unproject -@ stub D3DXVec3UnprojectArray +@ stdcall D3DXVec3UnprojectArray(ptr long ptr long ptr ptr ptr ptr long) @ stdcall D3DXVec4BaryCentric(ptr ptr ptr ptr long long) d3dx8.D3DXVec4BaryCentric @ stdcall D3DXVec4CatmullRom(ptr ptr ptr ptr ptr long) d3dx8.D3DXVec4CatmullRom @ stdcall D3DXVec4Cross(ptr ptr ptr ptr) d3dx8.D3DXVec4Cross @ stdcall D3DXVec4Hermite(ptr ptr ptr ptr ptr long) d3dx8.D3DXVec4Hermite @ stdcall D3DXVec4Normalize(ptr ptr) d3dx8.D3DXVec4Normalize @ stdcall D3DXVec4Transform(ptr ptr ptr) d3dx8.D3DXVec4Transform -@ stub D3DXVec4TransformArray +@ stdcall D3DXVec4TransformArray(ptr long ptr long ptr long) @ stub D3DXWeldVertices diff --git a/dlls/d3dx9_36/math.c b/dlls/d3dx9_36/math.c new file mode 100644 index 00000000000..3a959519568 --- /dev/null +++ b/dlls/d3dx9_36/math.c @@ -0,0 +1,195 @@ +/* + * Mathematical operations specific to D3DX9. + * + * Copyright (C) 2008 Philip Nilsson + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "config.h" +#include "windef.h" +#include "wingdi.h" +#include "wine/debug.h" +#include "d3dx9.h" + +WINE_DEFAULT_DEBUG_CHANNEL(d3dx); + +/************************************************************************* + * D3DXVec2TransformArray + * + * Transform an array of vectors by a matrix. + */ +D3DXVECTOR4* WINAPI D3DXVec2TransformArray( + D3DXVECTOR4* out, UINT outstride, CONST D3DXVECTOR2* in, UINT instride, + CONST D3DXMATRIX* matrix, UINT elements) +{ + unsigned int i; + TRACE("\n"); + for (i = 0; i < elements; ++i) { + D3DXVec2Transform( + (D3DXVECTOR4*)((char*)out + outstride * i), + (CONST D3DXVECTOR2*)((const char*)in + instride * i), + matrix); + } + return out; +} + +/************************************************************************* + * D3DXVec2TransformCoordArray + */ +D3DXVECTOR2* WINAPI D3DXVec2TransformCoordArray( + D3DXVECTOR2* out, UINT outstride, CONST D3DXVECTOR2* in, UINT instride, + CONST D3DXMATRIX* matrix, UINT elements) +{ + unsigned int i; + TRACE("\n"); + for (i = 0; i < elements; ++i) { + D3DXVec2TransformCoord( + (D3DXVECTOR2*)((char*)out + outstride * i), + (CONST D3DXVECTOR2*)((const char*)in + instride * i), + matrix); + } + return out; +} + +/************************************************************************* + * D3DXVec2TransformNormalArray + */ +D3DXVECTOR2* WINAPI D3DXVec2TransformNormalArray( + D3DXVECTOR2* out, UINT outstride, CONST D3DXVECTOR2 *in, UINT instride, + CONST D3DXMATRIX *matrix, UINT elements) +{ + unsigned int i; + TRACE("\n"); + for (i = 0; i < elements; ++i) { + D3DXVec2TransformNormal( + (D3DXVECTOR2*)((char*)out + outstride * i), + (CONST D3DXVECTOR2*)((const char*)in + instride * i), + matrix); + } + return out; +} + +/************************************************************************* + * D3DXVec3ProjectArray + * + * Projects an array of vectors to the screen. + */ +D3DXVECTOR3* WINAPI D3DXVec3ProjectArray( + D3DXVECTOR3* out, UINT outstride, CONST D3DXVECTOR3* in, UINT instride, + CONST D3DVIEWPORT9* viewport, CONST D3DXMATRIX* projection, + CONST D3DXMATRIX* view, CONST D3DXMATRIX* world, UINT elements) +{ + unsigned int i; + TRACE("\n"); + for (i = 0; i < elements; ++i) { + D3DXVec3Project( + (D3DXVECTOR3*)((char*)out + outstride * i), + (CONST D3DXVECTOR3*)((const char*)in + instride * i), + viewport, projection, view, world); + } + return out; +} + +/************************************************************************* + * D3DXVec3TransformArray + */ +D3DXVECTOR4* WINAPI D3DXVec3TransformArray( + D3DXVECTOR4* out, UINT outstride, CONST D3DXVECTOR3* in, UINT instride, + CONST D3DXMATRIX* matrix, UINT elements) +{ + unsigned int i; + TRACE("\n"); + for (i = 0; i < elements; ++i) { + D3DXVec3Transform( + (D3DXVECTOR4*)((char*)out + outstride * i), + (CONST D3DXVECTOR3*)((const char*)in + instride * i), + matrix); + } + return out; +} + +/************************************************************************* + * D3DXVec3TransformCoordArray + */ +D3DXVECTOR3* WINAPI D3DXVec3TransformCoordArray( + D3DXVECTOR3* out, UINT outstride, CONST D3DXVECTOR3* in, UINT instride, + CONST D3DXMATRIX* matrix, UINT elements) +{ + unsigned int i; + TRACE("\n"); + for (i = 0; i < elements; ++i) { + D3DXVec3TransformCoord( + (D3DXVECTOR3*)((char*)out + outstride * i), + (CONST D3DXVECTOR3*)((const char*)in + instride * i), + matrix); + } + return out; +} + +/************************************************************************* + * D3DXVec3TransformNormalArray + */ +D3DXVECTOR3* WINAPI D3DXVec3TransformNormalArray( + D3DXVECTOR3* out, UINT outstride, CONST D3DXVECTOR3* in, UINT instride, + CONST D3DXMATRIX* matrix, UINT elements) +{ + unsigned int i; + TRACE("\n"); + for (i = 0; i < elements; ++i) { + D3DXVec3TransformNormal( + (D3DXVECTOR3*)((char*)out + outstride * i), + (CONST D3DXVECTOR3*)((const char*)in + instride * i), + matrix); + } + return out; +} + +/************************************************************************* + * D3DXVec3UnprojectArray + */ +D3DXVECTOR3* WINAPI D3DXVec3UnprojectArray( + D3DXVECTOR3* out, UINT outstride, CONST D3DXVECTOR3* in, UINT instride, + CONST D3DVIEWPORT9* viewport, CONST D3DXMATRIX* projection, + CONST D3DXMATRIX* view, CONST D3DXMATRIX* world, UINT elements) +{ + unsigned int i; + TRACE("\n"); + for (i = 0; i < elements; ++i) { + D3DXVec3Unproject( + (D3DXVECTOR3*)((char*)out + outstride * i), + (CONST D3DXVECTOR3*)((const char*)in + instride * i), + viewport, projection, view, world); + } + return out; +} + +/************************************************************************* + * D3DXVec4TransformArray + */ +D3DXVECTOR4* WINAPI D3DXVec4TransformArray( + D3DXVECTOR4* out, UINT outstride, CONST D3DXVECTOR4* in, UINT instride, + CONST D3DXMATRIX* matrix, UINT elements) +{ + unsigned int i; + TRACE("\n"); + for (i = 0; i < elements; ++i) { + D3DXVec4Transform( + (D3DXVECTOR4*)((char*)out + outstride * i), + (CONST D3DXVECTOR4*)((const char*)in + instride * i), + matrix); + } + return out; +} diff --git a/include/d3dx9math.h b/include/d3dx9math.h index d4bd3795fd0..63f2be720d1 100644 --- a/include/d3dx9math.h +++ b/include/d3dx9math.h @@ -321,18 +321,26 @@ D3DXVECTOR2* WINAPI D3DXVec2CatmullRom(D3DXVECTOR2 *pout, CONST D3DXVECTOR2 *pv0 D3DXVECTOR2* WINAPI D3DXVec2Hermite(D3DXVECTOR2 *pout, CONST D3DXVECTOR2 *pv1, CONST D3DXVECTOR2 *pt1, CONST D3DXVECTOR2 *pv2, CONST D3DXVECTOR2 *pt2, FLOAT s); D3DXVECTOR2* WINAPI D3DXVec2Normalize(D3DXVECTOR2 *pout, CONST D3DXVECTOR2 *pv); D3DXVECTOR4* WINAPI D3DXVec2Transform(D3DXVECTOR4 *pout, CONST D3DXVECTOR2 *pv, CONST D3DXMATRIX *pm); +D3DXVECTOR4* WINAPI D3DXVec2TransformArray(D3DXVECTOR4 *pout, UINT outstride, CONST D3DXVECTOR2 *pv, UINT vstride, CONST D3DXMATRIX *pm, UINT n); D3DXVECTOR2* WINAPI D3DXVec2TransformCoord(D3DXVECTOR2 *pout, CONST D3DXVECTOR2 *pv, CONST D3DXMATRIX *pm); +D3DXVECTOR2* WINAPI D3DXVec2TransformCoordArray(D3DXVECTOR2 *pout, UINT outstride, CONST D3DXVECTOR2 *pv, UINT vstride, CONST D3DXMATRIX *pm, UINT n); D3DXVECTOR2* WINAPI D3DXVec2TransformNormal(D3DXVECTOR2 *pout, CONST D3DXVECTOR2 *pv, CONST D3DXMATRIX *pm); +D3DXVECTOR2* WINAPI D3DXVec2TransformNormalArray(D3DXVECTOR2 *pout, UINT outstride, CONST D3DXVECTOR2 *pv, UINT vstride, CONST D3DXMATRIX *pm, UINT n); D3DXVECTOR3* WINAPI D3DXVec3BaryCentric(D3DXVECTOR3 *pout, CONST D3DXVECTOR3 *pv1, CONST D3DXVECTOR3 *pv2, CONST D3DXVECTOR3 *pv3, FLOAT f, FLOAT g); D3DXVECTOR3* WINAPI D3DXVec3CatmullRom( D3DXVECTOR3 *pout, CONST D3DXVECTOR3 *pv0, CONST D3DXVECTOR3 *pv1, CONST D3DXVECTOR3 *pv2, CONST D3DXVECTOR3 *pv3, FLOAT s); D3DXVECTOR3* WINAPI D3DXVec3Hermite(D3DXVECTOR3 *pout, CONST D3DXVECTOR3 *pv1, CONST D3DXVECTOR3 *pt1, CONST D3DXVECTOR3 *pv2, CONST D3DXVECTOR3 *pt2, FLOAT s); D3DXVECTOR3* WINAPI D3DXVec3Normalize(D3DXVECTOR3 *pout, CONST D3DXVECTOR3 *pv); D3DXVECTOR3* WINAPI D3DXVec3Project(D3DXVECTOR3 *pout, CONST D3DXVECTOR3 *pv, CONST D3DVIEWPORT9 *pviewport, CONST D3DXMATRIX *pprojection, CONST D3DXMATRIX *pview, CONST D3DXMATRIX *pworld); +D3DXVECTOR3* WINAPI D3DXVec3ProjectArray(D3DXVECTOR3 *pout, UINT outstride, CONST D3DXVECTOR3 *pv, UINT vstride, CONST D3DVIEWPORT9 *pviewport, CONST D3DXMATRIX *pprojection, CONST D3DXMATRIX *pview, CONST D3DXMATRIX *pworld, UINT n); D3DXVECTOR4* WINAPI D3DXVec3Transform(D3DXVECTOR4 *pout, CONST D3DXVECTOR3 *pv, CONST D3DXMATRIX *pm); +D3DXVECTOR4* WINAPI D3DXVec3TransformArray(D3DXVECTOR4 *pout, UINT outstride, CONST D3DXVECTOR3 *pv, UINT vstride, CONST D3DXMATRIX *pm, UINT n); D3DXVECTOR3* WINAPI D3DXVec3TransformCoord(D3DXVECTOR3 *pout, CONST D3DXVECTOR3 *pv, CONST D3DXMATRIX *pm); +D3DXVECTOR3* WINAPI D3DXVec3TransformCoordArray(D3DXVECTOR3 *pout, UINT outstride, CONST D3DXVECTOR3 *pv, UINT vstride, CONST D3DXMATRIX *pm, UINT n); D3DXVECTOR3* WINAPI D3DXVec3TransformNormal(D3DXVECTOR3 *pout, CONST D3DXVECTOR3 *pv, CONST D3DXMATRIX *pm); +D3DXVECTOR3* WINAPI D3DXVec3TransformNormalArray(D3DXVECTOR3 *pout, UINT outstride, CONST D3DXVECTOR3 *pv, UINT vstride, CONST D3DXMATRIX *pm, UINT n); D3DXVECTOR3* WINAPI D3DXVec3Unproject(D3DXVECTOR3 *pout, CONST D3DXVECTOR3 *pv, CONST D3DVIEWPORT9 *pviewport, CONST D3DXMATRIX *pprojection, CONST D3DXMATRIX *pview, CONST D3DXMATRIX *pworld); +D3DXVECTOR3* WINAPI D3DXVec3UnprojectArray(D3DXVECTOR3 *pout, UINT outstride, CONST D3DXVECTOR3 *pv, UINT vstride, CONST D3DVIEWPORT9 *pviewport, CONST D3DXMATRIX *pprojection, CONST D3DXMATRIX *pview, CONST D3DXMATRIX *pworld, UINT n); D3DXVECTOR4* WINAPI D3DXVec4BaryCentric(D3DXVECTOR4 *pout, CONST D3DXVECTOR4 *pv1, CONST D3DXVECTOR4 *pv2, CONST D3DXVECTOR4 *pv3, FLOAT f, FLOAT g); D3DXVECTOR4* WINAPI D3DXVec4CatmullRom(D3DXVECTOR4 *pout, CONST D3DXVECTOR4 *pv0, CONST D3DXVECTOR4 *pv1, CONST D3DXVECTOR4 *pv2, CONST D3DXVECTOR4 *pv3, FLOAT s); @@ -340,6 +348,7 @@ D3DXVECTOR4* WINAPI D3DXVec4Cross(D3DXVECTOR4 *pout, CONST D3DXVECTOR4 *pv1, CON D3DXVECTOR4* WINAPI D3DXVec4Hermite(D3DXVECTOR4 *pout, CONST D3DXVECTOR4 *pv1, CONST D3DXVECTOR4 *pt1, CONST D3DXVECTOR4 *pv2, CONST D3DXVECTOR4 *pt2, FLOAT s); D3DXVECTOR4* WINAPI D3DXVec4Normalize(D3DXVECTOR4 *pout, CONST D3DXVECTOR4 *pv); D3DXVECTOR4* WINAPI D3DXVec4Transform(D3DXVECTOR4 *pout, CONST D3DXVECTOR4 *pv, CONST D3DXMATRIX *pm); +D3DXVECTOR4* WINAPI D3DXVec4TransformArray(D3DXVECTOR4 *pout, UINT outstride, CONST D3DXVECTOR4 *pv, UINT vstride, CONST D3DXMATRIX *pm, UINT n); #ifdef __cplusplus }