Added a few C++ operators to Direct3D structures, and made some unions

'nameless'.
This commit is contained in:
Ove Kaaven 2000-07-23 14:19:19 +00:00 committed by Alexandre Julliard
parent 37f5c11118
commit fddc3e15d8
5 changed files with 195 additions and 48 deletions

View File

@ -49,17 +49,17 @@ static void update(IDirect3DLightImpl* This) {
TRACE("Activating DIRECTIONAL\n");
TRACE(" direction : %f %f %f\n",
This->light.dvDirection.x.x,
This->light.dvDirection.y.y,
This->light.dvDirection.z.z);
This->light.dvDirection.u1.x,
This->light.dvDirection.u2.y,
This->light.dvDirection.u3.z);
_dump_colorvalue(" color ", This->light.dcvColor);
glLightfv(dlpriv->light_num, GL_AMBIENT, (float *) zero_value);
glLightfv(dlpriv->light_num, GL_DIFFUSE, (float *) &(This->light.dcvColor));
direction[0] = -This->light.dvDirection.x.x;
direction[1] = -This->light.dvDirection.y.y;
direction[2] = -This->light.dvDirection.z.z;
direction[0] = -This->light.dvDirection.u1.x;
direction[1] = -This->light.dvDirection.u2.y;
direction[2] = -This->light.dvDirection.u3.z;
direction[3] = 0.0; /* This is a directional light */
glLightfv(dlpriv->light_num, GL_POSITION, (float *) direction);

View File

@ -103,7 +103,7 @@ typedef struct mesa_d3dd_private {
#define _dump_colorvalue(s,v) \
TRACE(" " s " : %f %f %f %f\n", \
(v).r.r, (v).g.g, (v).b.b, (v).a.a);
(v).u1.r, (v).u2.g, (v).u3.b, (v).u4.a);
/* Common functions defined in d3dcommon.c */
void set_render_state(D3DRENDERSTATETYPE dwRenderStateType,

View File

@ -1732,18 +1732,18 @@ static HRESULT WINAPI IDirectSoundBufferImpl_QueryInterface(
*ppobj = (LPVOID)dsl;
dsl->ds3dl.dwSize = sizeof(DS3DLISTENER);
dsl->ds3dl.vPosition.x.x = 0.0;
dsl->ds3dl.vPosition.x.x = 0.0;
dsl->ds3dl.vPosition.z.z = 0.0;
dsl->ds3dl.vVelocity.x.x = 0.0;
dsl->ds3dl.vVelocity.y.y = 0.0;
dsl->ds3dl.vVelocity.z.z = 0.0;
dsl->ds3dl.vOrientFront.x.x = 0.0;
dsl->ds3dl.vOrientFront.y.y = 0.0;
dsl->ds3dl.vOrientFront.z.z = 1.0;
dsl->ds3dl.vOrientTop.x.x = 0.0;
dsl->ds3dl.vOrientTop.y.y = 1.0;
dsl->ds3dl.vOrientTop.z.z = 0.0;
dsl->ds3dl.vPosition.u1.x = 0.0;
dsl->ds3dl.vPosition.u2.y = 0.0;
dsl->ds3dl.vPosition.u3.z = 0.0;
dsl->ds3dl.vVelocity.u1.x = 0.0;
dsl->ds3dl.vVelocity.u2.y = 0.0;
dsl->ds3dl.vVelocity.u3.z = 0.0;
dsl->ds3dl.vOrientFront.u1.x = 0.0;
dsl->ds3dl.vOrientFront.u2.y = 0.0;
dsl->ds3dl.vOrientFront.u3.z = 1.0;
dsl->ds3dl.vOrientTop.u1.x = 0.0;
dsl->ds3dl.vOrientTop.u2.y = 1.0;
dsl->ds3dl.vOrientTop.u3.z = 0.0;
dsl->ds3dl.flDistanceFactor = DS3D_DEFAULTDISTANCEFACTOR;
dsl->ds3dl.flRolloffFactor = DS3D_DEFAULTROLLOFFFACTOR;
@ -2169,18 +2169,18 @@ static HRESULT WINAPI IDirectSoundImpl_QueryInterface(
This->listener->dsb = NULL;
This->listener->ds3dl.dwSize = sizeof(DS3DLISTENER);
This->listener->ds3dl.vPosition.x.x = 0.0;
This->listener->ds3dl.vPosition.x.x = 0.0;
This->listener->ds3dl.vPosition.z.z = 0.0;
This->listener->ds3dl.vVelocity.x.x = 0.0;
This->listener->ds3dl.vVelocity.y.y = 0.0;
This->listener->ds3dl.vVelocity.z.z = 0.0;
This->listener->ds3dl.vOrientFront.x.x = 0.0;
This->listener->ds3dl.vOrientFront.y.y = 0.0;
This->listener->ds3dl.vOrientFront.z.z = 1.0;
This->listener->ds3dl.vOrientTop.x.x = 0.0;
This->listener->ds3dl.vOrientTop.y.y = 1.0;
This->listener->ds3dl.vOrientTop.z.z = 0.0;
This->listener->ds3dl.vPosition.u1.x = 0.0;
This->listener->ds3dl.vPosition.u2.y = 0.0;
This->listener->ds3dl.vPosition.u3.z = 0.0;
This->listener->ds3dl.vVelocity.u1.x = 0.0;
This->listener->ds3dl.vVelocity.u2.y = 0.0;
This->listener->ds3dl.vVelocity.u3.z = 0.0;
This->listener->ds3dl.vOrientFront.u1.x = 0.0;
This->listener->ds3dl.vOrientFront.u2.y = 0.0;
This->listener->ds3dl.vOrientFront.u3.z = 1.0;
This->listener->ds3dl.vOrientTop.u1.x = 0.0;
This->listener->ds3dl.vOrientTop.u2.y = 1.0;
This->listener->ds3dl.vOrientTop.u3.z = 0.0;
This->listener->ds3dl.flDistanceFactor = DS3D_DEFAULTDISTANCEFACTOR;
This->listener->ds3dl.flRolloffFactor = DS3D_DEFAULTROLLOFFFACTOR;
This->listener->ds3dl.flDopplerFactor = DS3D_DEFAULTDOPPLERFACTOR;

View File

@ -69,54 +69,86 @@ typedef struct _D3DCOLORVALUE {
union {
D3DVALUE r;
D3DVALUE dvR;
} r;
} DUMMYUNIONNAME1;
union {
D3DVALUE g;
D3DVALUE dvG;
} g;
} DUMMYUNIONNAME2;
union {
D3DVALUE b;
D3DVALUE dvB;
} b;
} DUMMYUNIONNAME3;
union {
D3DVALUE a;
D3DVALUE dvA;
} a;
} DUMMYUNIONNAME4;
} D3DCOLORVALUE,*LPD3DCOLORVALUE;
typedef struct _D3DRECT {
union {
LONG x1;
LONG lX1;
} x1;
} DUMMYUNIONNAME1;
union {
LONG y1;
LONG lY1;
} y1;
} DUMMYUNIONNAME2;
union {
LONG x2;
LONG lX2;
} x2;
} DUMMYUNIONNAME3;
union {
LONG y2;
LONG lY2;
} y2;
} DUMMYUNIONNAME4;
} D3DRECT, *LPD3DRECT;
typedef struct _D3DVECTOR {
union {
D3DVALUE x;
D3DVALUE dvX;
} x;
} DUMMYUNIONNAME1;
union {
D3DVALUE y;
D3DVALUE dvY;
} y;
} DUMMYUNIONNAME2;
union {
D3DVALUE z;
D3DVALUE dvZ;
} z;
/* the C++ variant has operator overloads etc. too */
} DUMMYUNIONNAME3;
#if defined(__cplusplus) && defined(D3D_OVERLOADS)
/* the definitions for these methods are in d3dvec.inl */
public:
/*** constructors ***/
_D3DVECTOR() {}
_D3DVECTOR(D3DVALUE f);
_D3DVECTOR(D3DVALUE _x, D3DVALUE _y, D3DVALUE _z);
_D3DVECTOR(const D3DVALUE f[3]);
/*** assignment operators ***/
_D3DVECTOR& operator += (const _D3DVECTOR& v);
_D3DVECTOR& operator -= (const _D3DVECTOR& v);
_D3DVECTOR& operator *= (const _D3DVECTOR& v);
_D3DVECTOR& operator /= (const _D3DVECTOR& v);
_D3DVECTOR& operator *= (D3DVALUE s);
_D3DVECTOR& operator /= (D3DVALUE s);
/*** binary operators ***/
friend _D3DVECTOR operator + (const _D3DVECTOR& v1, const _D3DVECTOR& v2);
friend _D3DVECTOR operator - (const _D3DVECTOR& v1, const _D3DVECTOR& v2);
friend _D3DVECTOR operator * (const _D3DVECTOR& v, D3DVALUE s);
friend _D3DVECTOR operator * (D3DVALUE s, const _D3DVECTOR& v);
friend _D3DVECTOR operator / (const _D3DVECTOR& v, D3DVALUE s);
friend D3DVALUE SquareMagnitude(const _D3DVECTOR& v);
friend D3DVALUE Magnitude(const _D3DVECTOR& v);
friend _D3DVECTOR Normalize(const _D3DVECTOR& v);
friend D3DVALUE DotProduct(const _D3DVECTOR& v1, const _D3DVECTOR& v2);
friend _D3DVECTOR CrossProduct(const _D3DVECTOR& v1, const _D3DVECTOR& v2);
#endif
} D3DVECTOR,*LPD3DVECTOR;
typedef struct _D3DHVERTEX {
@ -250,6 +282,10 @@ typedef struct {
/* FIXME: Some C++ stuff here */
} D3DMATRIX, *LPD3DMATRIX;
#if defined(__cplusplus) && defined(D3D_OVERLOADS)
#include "d3dvec.inl"
#endif
typedef struct _D3DVIEWPORT {
DWORD dwSize;
DWORD dwX;
@ -421,23 +457,23 @@ typedef struct _D3DMATERIAL7 {
union {
D3DCOLORVALUE diffuse;
D3DCOLORVALUE dcvDiffuse;
}a;
} DUMMYUNIONNAME;
union {
D3DCOLORVALUE ambient;
D3DCOLORVALUE dcvAmbient;
}b;
} DUMMYUNIONNAME1;
union {
D3DCOLORVALUE specular;
D3DCOLORVALUE dcvSpecular;
}c;
} DUMMYUNIONNAME2;
union {
D3DCOLORVALUE emissive;
D3DCOLORVALUE dcvEmissive;
}d;
} DUMMYUNIONNAME3;
union {
D3DVALUE power;
D3DVALUE dvPower;
}e;
} DUMMYUNIONNAME4;
} D3DMATERIAL7, *LPD3DMATERIAL7;
typedef enum {

111
include/d3dvec.inl Normal file
View File

@ -0,0 +1,111 @@
#ifndef __WINE_D3DVEC_INL
#define __WINE_D3DVEC_INL
/*** constructors ***/
inline _D3DVECTOR::_D3DVECTOR(D3DVALUE f)
{
x = y = z = f;
}
inline _D3DVECTOR::_D3DVECTOR(D3DVALUE _x, D3DVALUE _y, D3DVALUE _z)
{
x = _x; y = _y; z = _z;
}
/*** assignment operators ***/
inline _D3DVECTOR& _D3DVECTOR::operator += (const _D3DVECTOR& v)
{
x += v.x; y += v.y; z += v.z;
return *this;
}
inline _D3DVECTOR& _D3DVECTOR::operator -= (const _D3DVECTOR& v)
{
x -= v.x; y -= v.y; z -= v.z;
return *this;
}
inline _D3DVECTOR& _D3DVECTOR::operator *= (const _D3DVECTOR& v)
{
x *= v.x; y *= v.y; z *= v.z;
return *this;
}
inline _D3DVECTOR& _D3DVECTOR::operator /= (const _D3DVECTOR& v)
{
x /= v.x; y /= v.y; z /= v.z;
return *this;
}
inline _D3DVECTOR& _D3DVECTOR::operator *= (D3DVALUE s)
{
x *= s; y *= s; z *= s;
return *this;
}
inline _D3DVECTOR& _D3DVECTOR::operator /= (D3DVALUE s)
{
x /= s; y /= s; z /= s;
return *this;
}
/*** binary operators ***/
inline _D3DVECTOR operator + (const _D3DVECTOR& v1, const _D3DVECTOR& v2)
{
return _D3DVECTOR(v1.x+v2.x, v1.y+v2.y, v1.z+v2.z);
}
inline _D3DVECTOR operator - (const _D3DVECTOR& v1, const _D3DVECTOR& v2)
{
return _D3DVECTOR(v1.x-v2.x, v1.y-v2.y, v1.z-v2.z);
}
inline _D3DVECTOR operator * (const _D3DVECTOR& v, D3DVALUE s)
{
return _D3DVECTOR(v.x*s, v.y*s, v.z*s);
}
inline _D3DVECTOR operator * (D3DVALUE s, const _D3DVECTOR& v)
{
return _D3DVECTOR(v.x*s, v.y*s, v.z*s);
}
inline _D3DVECTOR operator / (const _D3DVECTOR& v, D3DVALUE s)
{
return _D3DVECTOR(v.x/s, v.y/s, v.z/s);
}
inline D3DVALUE SquareMagnitude(const _D3DVECTOR& v)
{
return v.x*v.x + v.y*v.y + v.z*v.z; /* DotProduct(v, v) */
}
inline D3DVALUE Magnitude(const _D3DVECTOR& v)
{
return sqrt(SquareMagnitude(v));
}
inline _D3DVECTOR Normalize(const _D3DVECTOR& v)
{
return v / Magnitude(v);
}
inline D3DVALUE DotProduct(const _D3DVECTOR& v1, const _D3DVECTOR& v2)
{
return v1.x*v2.x + v1.y*v2.y + v1.z*v2.z;
}
inline _D3DVECTOR CrossProduct(const _D3DVECTOR& v1, const _D3DVECTOR& v2)
{
_D3DVECTOR res;
/* this is a left-handed cross product, right? */
res.x = v1.y * v2.z - v1.z * v2.y;
res.y = v1.z * v2.x - v1.x * v2.z;
res.z = v1.x * v2.y - v1.y * v2.x;
return res;
}
#endif