DXGL r493 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r492‎ | r493 | r494 >
Date:19:31, 17 August 2014
Author:admin
Status:new
Tags:
Comment:
Add ComputeSphereVisibility from Wine sources.
Add third-party attributions file.
Fix several errors in Wine test d3d.c
Modified paths:
  • /ThirdParty.txt (added) (history)
  • /ddraw/glDirect3D.cpp (modified) (history)
  • /ddraw/glDirect3D.h (modified) (history)
  • /ddraw/glDirect3DDevice.cpp (modified) (history)
  • /ddraw/glDirect3DDevice.h (modified) (history)
  • /ddraw/glDirect3DLight.cpp (modified) (history)
  • /ddraw/matrix.cpp (modified) (history)
  • /ddraw/matrix.h (modified) (history)

Diff [purge]

Index: ThirdParty.txt
@@ -0,0 +1,76 @@
 2+Contains headers from OpenGL.org, released under the following license:
 3+Copyright (c) 2013-2014 The Khronos Group Inc.
 4+
 5+Permission is hereby granted, free of charge, to any person obtaining a
 6+copy of this software and/or associated documentation files (the
 7+"Materials"), to deal in the Materials without restriction, including
 8+without limitation the rights to use, copy, modify, merge, publish,
 9+distribute, sublicense, and/or sell copies of the Materials, and to
 10+permit persons to whom the Materials are furnished to do so, subject to
 11+the following conditions:
 12+
 13+The above copyright notice and this permission notice shall be included
 14+in all copies or substantial portions of the Materials.
 15+
 16+THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 17+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 18+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 19+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
 20+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 21+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 22+MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
 23+
 24+Contains headers and some code from the Wine project, released under the
 25+following license:
 26+Copyright (c) 1993-2014 the Wine project authors (see the file AUTHORS
 27+in the Wine source code distribution for a complete list)
 28+
 29+Wine is free software; you can redistribute it and/or modify it under
 30+the terms of the GNU Lesser General Public License as published by the
 31+Free Software Foundation; either version 2.1 of the License, or (at
 32+your option) any later version.
 33+
 34+This program is distributed in the hope that it will be useful, but
 35+WITHOUT ANY WARRANTY; without even the implied warranty of
 36+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 37+Lesser General Public License for more details.
 38+
 39+A copy of the GNU Lesser General Public License is included in the
 40+Wine distribution in the file COPYING.LIB. If you did not receive this
 41+copy, write to the Free Software Foundation, Inc., 51 Franklin St,
 42+Fifth Floor, Boston, MA 02110-1301, USA.
 43+
 44+Contains CRC-32 version 2.0.0 by Craig Bruce, 2006-04-29, under the following
 45+declaration:
 46+THIS PROGRAM IS PUBLIC-DOMAIN SOFTWARE.
 47+Based on the byte-oriented implementation "File Verification Using CRC"
 48+by Mark R. Nelson in Dr. Dobb's Journal, May 1992, pp. 64-67.
 49+
 50+Contains portions of the Mesa project.c file, under the following license:
 51+SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
 52+Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
 53+
 54+Permission is hereby granted, free of charge, to any person obtaining a
 55+copy of this software and associated documentation files (the "Software"),
 56+to deal in the Software without restriction, including without limitation
 57+the rights to use, copy, modify, merge, publish, distribute, sublicense,
 58+and/or sell copies of the Software, and to permit persons to whom the
 59+Software is furnished to do so, subject to the following conditions:
 60+
 61+The above copyright notice including the dates of first publication and
 62+either this permission notice or a reference to
 63+http://oss.sgi.com/projects/FreeB/
 64+shall be included in all copies or substantial portions of the Software.
 65+
 66+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 67+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 68+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
 69+SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
 70+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
 71+OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 72+SOFTWARE.
 73+
 74+Except as contained in this notice, the name of Silicon Graphics, Inc.
 75+shall not be used in advertising or otherwise to promote the sale, use or
 76+other dealings in this Software without prior written authorization from
 77+Silicon Graphics, Inc.
\ No newline at end of file
Index: ddraw/glDirect3D.cpp
@@ -175,11 +175,6 @@
176176 d3ddesc_default.wMaxSimultaneousTextures
177177 };
178178
179 -struct D3DDevice
180 -{
181 - char *name;
182 - char *devname;
183 -};
184179 const D3DDevice devices[3] =
185180 {
186181 {
@@ -205,7 +200,8 @@
206201 glD3D2 = NULL;
207202 glD3D1 = NULL;
208203 glDD7 = gl_DD7;
209 - TRACE_EXIT(-1,0);
 204+ memcpy(stored_devices, devices, 3 * sizeof(D3DDevice));
 205+ TRACE_EXIT(-1, 0);
210206 }
211207
212208 glDirect3D7::~glDirect3D7()
@@ -401,7 +397,7 @@
402398 desc.dwDevCaps |= D3DDEVCAPS_HWRASTERIZATION | D3DDEVCAPS_HWTRANSFORMANDLIGHT;
403399 break;
404400 }
405 - result = lpEnumDevicesCallback(devices[i].name,devices[i].devname,&desc,lpUserArg);
 401+ result = lpEnumDevicesCallback(stored_devices[i].name,stored_devices[i].devname,&desc,lpUserArg);
406402 if(result != D3DENUMRET_OK) break;
407403 }
408404 TRACE_EXIT(23,D3D_OK);
@@ -416,10 +412,10 @@
417413 HRESULT result;
418414 D3DDEVICEDESC desc = d3ddesc3;
419415 GUID guid = IID_IDirect3DRGBDevice;
420 - result = lpEnumDevicesCallback(&guid,devices[0].name,devices[0].devname,&desc,&desc,lpUserArg);
 416+ result = lpEnumDevicesCallback(&guid,stored_devices[0].name,stored_devices[0].devname,&desc,&desc,lpUserArg);
421417 if(result != D3DENUMRET_OK) TRACE_RET(HRESULT,23,D3D_OK);
422418 guid = IID_IDirect3DHALDevice;
423 - result = lpEnumDevicesCallback(&guid,devices[1].name,devices[1].devname,&desc,&desc,lpUserArg);
 419+ result = lpEnumDevicesCallback(&guid,stored_devices[1].name,stored_devices[1].devname,&desc,&desc,lpUserArg);
424420 TRACE_EXIT(23,D3D_OK);
425421 return D3D_OK;
426422 }
Index: ddraw/glDirect3D.h
@@ -26,6 +26,13 @@
2727 class glDirect3D3;
2828 class glDirect3D2;
2929 class glDirect3D1;
 30+
 31+struct D3DDevice
 32+{
 33+ char name[64];
 34+ char devname[64];
 35+};
 36+
3037 class glDirect3D7 : public IDirect3D7
3138 {
3239 public:
@@ -49,6 +56,7 @@
5057 glDirect3D1 *glD3D1;
5158 glDirectDraw7 *glDD7;
5259 private:
 60+ D3DDevice stored_devices[3];
5361 ULONG refcount;
5462 D3DDEVICEDESC7 d3ddesc;
5563 D3DDEVICEDESC d3ddesc3;
Index: ddraw/glDirect3DDevice.cpp
@@ -418,7 +418,7 @@
419419 if(!tmp) return 0;
420420 *lights = tmp;
421421 for(DWORD i = *maxlights; i < newmax; i++)
422 - lights[i] = NULL;
 422+ (*lights)[i] = NULL;
423423 *maxlights = newmax;
424424 return 1;
425425 }
@@ -576,14 +576,107 @@
577577 if(dwCount && !lpRects) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
578578 TRACE_RET(HRESULT,23,glRenderer_Clear(renderer,glDDS7,dwCount,lpRects,dwFlags,dwColor,dvZ,dwStencil));
579579 }
 580+
 581+// ComputeSphereVisibility based on modified code from the Wine project, subject
 582+// to the following license terms:
 583+/*
 584+* Copyright (c) 1998-2004 Lionel Ulmer
 585+* Copyright (c) 2002-2005 Christian Costa
 586+* Copyright (c) 2006-2009, 2011-2013 Stefan Dösinger
 587+* Copyright (c) 2008 Alexander Dorofeyev
 588+*
 589+* This library is free software; you can redistribute it and/or
 590+* modify it under the terms of the GNU Lesser General Public
 591+* License as published by the Free Software Foundation; either
 592+* version 2.1 of the License, or (at your option) any later version.
 593+*
 594+* This library is distributed in the hope that it will be useful,
 595+* but WITHOUT ANY WARRANTY; without even the implied warranty of
 596+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 597+* Lesser General Public License for more details.
 598+*
 599+* You should have received a copy of the GNU Lesser General Public
 600+* License along with this library; if not, write to the Free Software
 601+* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 602+*/
 603+static DWORD in_plane(UINT plane, D3DVECTOR normal, D3DVALUE origin_plane, D3DVECTOR center, D3DVALUE radius)
 604+{
 605+ float distance, norm;
 606+
 607+ norm = sqrtf(normal.x * normal.x + normal.y * normal.y + normal.z * normal.z);
 608+ distance = (origin_plane + normal.x * center.x + normal.y * center.y + normal.z * center.z) / norm;
 609+
 610+ if (fabs(distance) < radius) return D3DSTATUS_CLIPUNIONLEFT << plane;
 611+ if (distance < -radius) return (D3DSTATUS_CLIPUNIONLEFT | D3DSTATUS_CLIPINTERSECTIONLEFT) << plane;
 612+ return 0;
 613+}
 614+
 615+
580616 HRESULT WINAPI glDirect3DDevice7::ComputeSphereVisibility(LPD3DVECTOR lpCenters, LPD3DVALUE lpRadii, DWORD dwNumSpheres,
581617 DWORD dwFlags, LPDWORD lpdwReturnValues)
582618 {
 619+ D3DMATRIX m, temp;
 620+ D3DVALUE origin_plane[6];
 621+ D3DVECTOR vec[6];
 622+ HRESULT hr;
 623+ UINT i, j;
 624+
583625 TRACE_ENTER(6,14,this,14,lpCenters,14,lpRadii,8,dwNumSpheres,9,dwFlags,14,lpdwReturnValues);
584626 if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
585 - FIXME("glDirect3DDevice7::ComputeSphereVisibility: stub");
586 - TRACE_EXIT(23,DDERR_GENERIC);
587 - ERR(DDERR_GENERIC);
 627+ hr = GetTransform(D3DTRANSFORMSTATE_WORLD, &m);
 628+ if (hr != DD_OK) return DDERR_INVALIDPARAMS;
 629+ hr = GetTransform(D3DTRANSFORMSTATE_VIEW, &temp);
 630+ if (hr != DD_OK) return DDERR_INVALIDPARAMS;
 631+ multiply_matrix((wined3d_matrix*)&m, (wined3d_matrix*)&temp, (wined3d_matrix*)&m);
 632+
 633+ hr = GetTransform(D3DTRANSFORMSTATE_PROJECTION, &temp);
 634+ if (hr != DD_OK) return DDERR_INVALIDPARAMS;
 635+ multiply_matrix((wined3d_matrix*)&m, (wined3d_matrix*)&temp, (wined3d_matrix*)&m);
 636+
 637+ /* Left plane */
 638+ vec[0].x = m._14 + m._11;
 639+ vec[0].y = m._24 + m._21;
 640+ vec[0].z = m._34 + m._31;
 641+ origin_plane[0] = m._44 + m._41;
 642+
 643+ /* Right plane */
 644+ vec[1].z = m._14 - m._11;
 645+ vec[1].y = m._24 - m._21;
 646+ vec[1].z = m._34 - m._31;
 647+ origin_plane[1] = m._44 - m._41;
 648+
 649+ /* Top plane */
 650+ vec[2].x = m._14 - m._12;
 651+ vec[2].y = m._24 - m._22;
 652+ vec[2].z = m._34 - m._32;
 653+ origin_plane[2] = m._44 - m._42;
 654+
 655+ /* Bottom plane */
 656+ vec[3].x = m._14 + m._12;
 657+ vec[3].y = m._24 + m._22;
 658+ vec[3].z = m._34 + m._32;
 659+ origin_plane[3] = m._44 + m._42;
 660+
 661+ /* Front plane */
 662+ vec[4].x = m._13;
 663+ vec[4].y = m._23;
 664+ vec[4].z = m._33;
 665+ origin_plane[4] = m._43;
 666+
 667+ /* Back plane*/
 668+ vec[5].x = m._14 - m._13;
 669+ vec[5].y = m._24 - m._23;
 670+ vec[5].z = m._34 - m._33;
 671+ origin_plane[5] = m._44 - m._43;
 672+
 673+ for (i = 0; i < dwNumSpheres; ++i)
 674+ {
 675+ lpdwReturnValues[i] = 0;
 676+ for (j = 0; j < 6; ++j)
 677+ lpdwReturnValues[i] |= in_plane(j, vec[j], origin_plane[j], lpCenters[i], lpRadii[i]);
 678+ }
 679+ TRACE_EXIT(23, D3D_OK);
 680+ return D3D_OK;
588681 }
589682 HRESULT WINAPI glDirect3DDevice7::DeleteStateBlock(DWORD dwBlockHandle)
590683 {
@@ -935,8 +1028,8 @@
9361029 TRACE_ENTER(3,14,this,8,dwLightIndex,14,lpLight);
9371030 if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
9381031 if(!lpLight) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
939 - if(dwLightIndex >= lightsmax) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
940 - if(!lights[dwLightIndex]) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
 1032+ if(dwLightIndex >= lightsmax) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
 1033+ if(!lights[dwLightIndex]) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
9411034 lights[dwLightIndex]->GetLight7(lpLight);
9421035 TRACE_EXIT(23,D3D_OK);
9431036 return D3D_OK;
@@ -945,8 +1038,8 @@
9461039 {
9471040 TRACE_ENTER(3,14,this,8,dwLightIndex,14,pbEnable);
9481041 if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
949 - if(dwLightIndex >= lightsmax) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
950 - if(!lights[dwLightIndex]) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
 1042+ if(dwLightIndex >= lightsmax) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
 1043+ if(!lights[dwLightIndex]) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
9511044 if(!pbEnable) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
9521045 *pbEnable = FALSE;
9531046 for(int i = 0; i < 8; i++)
@@ -1130,7 +1223,7 @@
11311224 bool foundlight = false;
11321225 if(dwLightIndex >= lightsmax)
11331226 {
1134 - if(!ExpandLightBuffer(&lights,&lightsmax,dwLightIndex-1)) TRACE_RET(HRESULT,23,DDERR_OUTOFMEMORY);
 1227+ if(!ExpandLightBuffer(&lights,&lightsmax,dwLightIndex+1)) TRACE_RET(HRESULT,23,DDERR_OUTOFMEMORY);
11351228 }
11361229 if(!lights[dwLightIndex]) lights[dwLightIndex] = new glDirect3DLight;
11371230 if(bEnable)
@@ -1208,10 +1301,13 @@
12091302 {
12101303 TRACE_ENTER(3,14,this,8,dwLightIndex,14,lpLight);
12111304 if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
 1305+ if (!lpLight) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
 1306+ if ((lpLight->dltType < D3DLIGHT_POINT) || (lpLight->dltType > D3DLIGHT_GLSPOT))
 1307+ TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
12121308 bool foundlight = false;
12131309 if(dwLightIndex >= lightsmax)
12141310 {
1215 - if(!ExpandLightBuffer(&lights,&lightsmax,dwLightIndex-1)) TRACE_RET(HRESULT,23,DDERR_OUTOFMEMORY);
 1311+ if(!ExpandLightBuffer(&lights,&lightsmax,dwLightIndex+1)) TRACE_RET(HRESULT,23,DDERR_OUTOFMEMORY);
12161312 }
12171313 if(!lights[dwLightIndex]) lights[dwLightIndex] = new glDirect3DLight;
12181314 lights[dwLightIndex]->SetLight7(lpLight);
@@ -1951,15 +2047,6 @@
19522048 return DDERR_GENERIC;
19532049 }
19542050
1955 -HRESULT glDirect3DDevice7::ComputeSphereVisibility3(LPD3DVECTOR lpCenters, LPD3DVALUE lpRadii, DWORD dwNumSpheres, DWORD dwFlags, LPDWORD lpdwReturnValues)
1956 -{
1957 - TRACE_ENTER(6,14,this,14,lpCenters,14,lpRadii,8,dwNumSpheres,9,dwFlags,14,lpdwReturnValues);
1958 - if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
1959 - FIXME("glDirect3DDevice3::ComputeSphereVisibility: stub");
1960 - TRACE_EXIT(23,DDERR_GENERIC);
1961 - return DDERR_GENERIC;
1962 -}
1963 -
19642051 HRESULT glDirect3DDevice7::GetCaps3(LPD3DDEVICEDESC lpD3DHWDevDesc, LPD3DDEVICEDESC lpD3DHELDevDesc)
19652052 {
19662053 TRACE_ENTER(3,14,this,14,lpD3DHWDevDesc,14,lpD3DHELDevDesc);
@@ -2909,7 +2996,7 @@
29102997 {
29112998 TRACE_ENTER(6,14,this,14,lpCenters,14,lpRadii,8,dwNumSpheres,9,dwFlags,14,lpdwReturnValues);
29122999 if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
2913 - TRACE_RET(HRESULT,23,glD3DDev7->ComputeSphereVisibility3(lpCenters,lpRadii,dwNumSpheres,dwFlags,lpdwReturnValues));
 3000+ TRACE_RET(HRESULT,23,glD3DDev7->ComputeSphereVisibility(lpCenters,lpRadii,dwNumSpheres,dwFlags,lpdwReturnValues));
29143001 }
29153002
29163003 HRESULT WINAPI glDirect3DDevice3::DeleteViewport(LPDIRECT3DVIEWPORT3 lpDirect3DViewport)
Index: ddraw/glDirect3DDevice.h
@@ -146,7 +146,6 @@
147147 HRESULT Index(WORD wVertexIndex);
148148 HRESULT Vertex(LPVOID lpVertex);
149149 HRESULT End(DWORD dwFlags);
150 - HRESULT ComputeSphereVisibility3(LPD3DVECTOR lpCenters, LPD3DVALUE lpRadii, DWORD dwNumSpheres, DWORD dwFlags, LPDWORD lpdwReturnValues);
151150 HRESULT GetCaps3(LPD3DDEVICEDESC lpD3DHWDevDesc, LPD3DDEVICEDESC lpD3DHELDevDesc);
152151 HRESULT GetLightState(D3DLIGHTSTATETYPE dwLightStateType, LPDWORD lpdwLightState);
153152 HRESULT SetLightState(D3DLIGHTSTATETYPE dwLightStateType, DWORD dwLightState);
Index: ddraw/glDirect3DLight.cpp
@@ -36,7 +36,7 @@
3737 device = NULL;
3838 ZeroMemory(&light,sizeof(D3DLIGHT7));
3939 light.dltType = D3DLIGHT_DIRECTIONAL;
40 - light.dcvAmbient.r = light.dcvAmbient.g = light.dcvAmbient.b = 1.0f;
 40+ light.dcvDiffuse.r = light.dcvDiffuse.g = light.dcvDiffuse.b = 1.0f;
4141 light.dvDirection = D3DVECTOR(0,0,1.0);
4242 TRACE_EXIT(-1,0);
4343 }
Index: ddraw/matrix.cpp
@@ -109,10 +109,11 @@
110110 GLfloat r[16])
111111 {
112112 int i, j;
 113+ GLfloat out[16];
113114
114115 for (i = 0; i < 4; i++) {
115116 for (j = 0; j < 4; j++) {
116 - r[i*4+j] =
 117+ out[i*4+j] =
117118 a[i*4+0]*b[0*4+j] +
118119 a[i*4+1]*b[1*4+j] +
119120 a[i*4+2]*b[2*4+j] +
@@ -119,6 +120,7 @@
120121 a[i*4+3]*b[3*4+j];
121122 }
122123 }
 124+ memcpy(r, out, 16 * sizeof(GLfloat));
123125 }
124126
125127 void __gluMakeIdentityf(GLfloat m[16])
@@ -141,3 +143,58 @@
142144 in[3] * matrix[3*4+i];
143145 }
144146 }
 147+
 148+
 149+// Portions of this file are from the Wine project, distributed under the
 150+// following license:
 151+/*
 152+* Copyright (c) 1998-2004 Lionel Ulmer
 153+* Copyright (c) 2002-2005 Christian Costa
 154+* Copyright (c) 2006-2009, 2011-2013 Stefan Dösinger
 155+* Copyright (c) 2008 Alexander Dorofeyev
 156+*
 157+* This library is free software; you can redistribute it and/or
 158+* modify it under the terms of the GNU Lesser General Public
 159+* License as published by the Free Software Foundation; either
 160+* version 2.1 of the License, or (at your option) any later version.
 161+*
 162+* This library is distributed in the hope that it will be useful,
 163+* but WITHOUT ANY WARRANTY; without even the implied warranty of
 164+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 165+* Lesser General Public License for more details.
 166+*
 167+* You should have received a copy of the GNU Lesser General Public
 168+* License along with this library; if not, write to the Free Software
 169+* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 170+*/
 171+
 172+void multiply_matrix(struct wined3d_matrix *dest, const struct wined3d_matrix *src1,
 173+ const struct wined3d_matrix *src2)
 174+{
 175+ struct wined3d_matrix temp;
 176+
 177+ /* Now do the multiplication 'by hand'.
 178+ I know that all this could be optimised, but this will be done later :-) */
 179+ temp._11 = (src1->_11 * src2->_11) + (src1->_21 * src2->_12) + (src1->_31 * src2->_13) + (src1->_41 * src2->_14);
 180+ temp._21 = (src1->_11 * src2->_21) + (src1->_21 * src2->_22) + (src1->_31 * src2->_23) + (src1->_41 * src2->_24);
 181+ temp._31 = (src1->_11 * src2->_31) + (src1->_21 * src2->_32) + (src1->_31 * src2->_33) + (src1->_41 * src2->_34);
 182+ temp._41 = (src1->_11 * src2->_41) + (src1->_21 * src2->_42) + (src1->_31 * src2->_43) + (src1->_41 * src2->_44);
 183+
 184+ temp._12 = (src1->_12 * src2->_11) + (src1->_22 * src2->_12) + (src1->_32 * src2->_13) + (src1->_42 * src2->_14);
 185+ temp._22 = (src1->_12 * src2->_21) + (src1->_22 * src2->_22) + (src1->_32 * src2->_23) + (src1->_42 * src2->_24);
 186+ temp._32 = (src1->_12 * src2->_31) + (src1->_22 * src2->_32) + (src1->_32 * src2->_33) + (src1->_42 * src2->_34);
 187+ temp._42 = (src1->_12 * src2->_41) + (src1->_22 * src2->_42) + (src1->_32 * src2->_43) + (src1->_42 * src2->_44);
 188+
 189+ temp._13 = (src1->_13 * src2->_11) + (src1->_23 * src2->_12) + (src1->_33 * src2->_13) + (src1->_43 * src2->_14);
 190+ temp._23 = (src1->_13 * src2->_21) + (src1->_23 * src2->_22) + (src1->_33 * src2->_23) + (src1->_43 * src2->_24);
 191+ temp._33 = (src1->_13 * src2->_31) + (src1->_23 * src2->_32) + (src1->_33 * src2->_33) + (src1->_43 * src2->_34);
 192+ temp._43 = (src1->_13 * src2->_41) + (src1->_23 * src2->_42) + (src1->_33 * src2->_43) + (src1->_43 * src2->_44);
 193+
 194+ temp._14 = (src1->_14 * src2->_11) + (src1->_24 * src2->_12) + (src1->_34 * src2->_13) + (src1->_44 * src2->_14);
 195+ temp._24 = (src1->_14 * src2->_21) + (src1->_24 * src2->_22) + (src1->_34 * src2->_23) + (src1->_44 * src2->_24);
 196+ temp._34 = (src1->_14 * src2->_31) + (src1->_24 * src2->_32) + (src1->_34 * src2->_33) + (src1->_44 * src2->_34);
 197+ temp._44 = (src1->_14 * src2->_41) + (src1->_24 * src2->_42) + (src1->_34 * src2->_43) + (src1->_44 * src2->_44);
 198+
 199+ /* And copy the new matrix in the good storage.. */
 200+ memcpy(dest, &temp, 16 * sizeof(float));
 201+}
Index: ddraw/matrix.h
@@ -56,4 +56,45 @@
5757 void __gluMakeIdentityf(GLfloat m[16]);
5858 void __gluMultMatrixVecf(const GLfloat matrix[16], const GLfloat in[4], GLfloat out[4]);
5959
 60+// Portions of this file are from the Wine project, distributed under the
 61+// following license:
 62+/*
 63+* Copyright (c) 1998-2004 Lionel Ulmer
 64+* Copyright (c) 2002-2005 Christian Costa
 65+* Copyright (c) 2006-2009, 2011-2013 Stefan Dösinger
 66+* Copyright (c) 2008 Alexander Dorofeyev
 67+*
 68+* This library is free software; you can redistribute it and/or
 69+* modify it under the terms of the GNU Lesser General Public
 70+* License as published by the Free Software Foundation; either
 71+* version 2.1 of the License, or (at your option) any later version.
 72+*
 73+* This library is distributed in the hope that it will be useful,
 74+* but WITHOUT ANY WARRANTY; without even the implied warranty of
 75+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 76+* Lesser General Public License for more details.
 77+*
 78+* You should have received a copy of the GNU Lesser General Public
 79+* License along with this library; if not, write to the Free Software
 80+* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 81+*/
 82+
 83+struct wined3d_matrix
 84+{
 85+ union
 86+ {
 87+ struct
 88+ {
 89+ float _11, _12, _13, _14;
 90+ float _21, _22, _23, _24;
 91+ float _31, _32, _33, _34;
 92+ float _41, _42, _43, _44;
 93+ } DUMMYSTRUCTNAME;
 94+ float m[4][4];
 95+ } DUMMYUNIONNAME;
 96+};
 97+
 98+void multiply_matrix(struct wined3d_matrix *dest, const struct wined3d_matrix *src1,
 99+ const struct wined3d_matrix *src2);
 100+
60101 #endif //_MATRIX_H
\ No newline at end of file