Commit 022d3727 authored by Francois Gouget's avatar Francois Gouget Committed by Alexandre Julliard

Adapted to the interface/implementation separation.

Now uses ICOM_THIS to access the implementation structures. Replaced 'this' with 'This' for ICOM_THIS. Direct access to the virtual table has been eliminated too.
parent 9e2f4af9
...@@ -124,7 +124,7 @@ void set_render_state(D3DRENDERSTATETYPE dwRenderStateType, ...@@ -124,7 +124,7 @@ void set_render_state(D3DRENDERSTATETYPE dwRenderStateType,
switch (dwRenderStateType) { switch (dwRenderStateType) {
case D3DRENDERSTATE_TEXTUREHANDLE: { /* 1 */ case D3DRENDERSTATE_TEXTUREHANDLE: { /* 1 */
LPDIRECT3DTEXTURE2 tex = (LPDIRECT3DTEXTURE2) dwRenderState; IDirect3DTexture2Impl* tex = (IDirect3DTexture2Impl*) dwRenderState;
if (tex == NULL) { if (tex == NULL) {
glBindTexture(GL_TEXTURE_2D, 0); glBindTexture(GL_TEXTURE_2D, 0);
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
#ifdef HAVE_MESAGL #ifdef HAVE_MESAGL
static IDirect3DLight_VTable light_vtable; static ICOM_VTABLE(IDirect3DLight) light_vtable;
enum { enum {
D3D_1, D3D_1,
...@@ -31,8 +31,8 @@ static const float zero_value[] = { ...@@ -31,8 +31,8 @@ static const float zero_value[] = {
0.0, 0.0, 0.0, 0.0 0.0, 0.0, 0.0, 0.0
}; };
static void update(LPDIRECT3DLIGHT this) { static void update(IDirect3DLightImpl* This) {
switch (this->light.dltType) { switch (This->light.dltType) {
case D3DLIGHT_POINT: /* 1 */ case D3DLIGHT_POINT: /* 1 */
TRACE(ddraw, "Activating POINT\n"); TRACE(ddraw, "Activating POINT\n");
break; break;
...@@ -46,24 +46,24 @@ static void update(LPDIRECT3DLIGHT this) { ...@@ -46,24 +46,24 @@ static void update(LPDIRECT3DLIGHT this) {
TRACE(ddraw, "Activating DIRECTIONAL\n"); TRACE(ddraw, "Activating DIRECTIONAL\n");
TRACE(ddraw, " direction : %f %f %f\n", TRACE(ddraw, " direction : %f %f %f\n",
this->light.dvDirection.x.x, This->light.dvDirection.x.x,
this->light.dvDirection.y.y, This->light.dvDirection.y.y,
this->light.dvDirection.z.z); This->light.dvDirection.z.z);
_dump_colorvalue(" color ", this->light.dcvColor); _dump_colorvalue(" color ", This->light.dcvColor);
glLightfv(this->light_num, glLightfv(This->light_num,
GL_AMBIENT, GL_AMBIENT,
(float *) zero_value); (float *) zero_value);
glLightfv(this->light_num, glLightfv(This->light_num,
GL_DIFFUSE, GL_DIFFUSE,
(float *) &(this->light.dcvColor)); (float *) &(This->light.dcvColor));
direction[0] = -this->light.dvDirection.x.x; direction[0] = -This->light.dvDirection.x.x;
direction[1] = -this->light.dvDirection.y.y; direction[1] = -This->light.dvDirection.y.y;
direction[2] = -this->light.dvDirection.z.z; direction[2] = -This->light.dvDirection.z.z;
direction[3] = 0.0; /* This is a directional light */ direction[3] = 0.0; /* This is a directional light */
glLightfv(this->light_num, glLightfv(This->light_num,
GL_POSITION, GL_POSITION,
(float *) direction); (float *) direction);
} break; } break;
...@@ -78,14 +78,14 @@ static void update(LPDIRECT3DLIGHT this) { ...@@ -78,14 +78,14 @@ static void update(LPDIRECT3DLIGHT this) {
} }
} }
static void activate(LPDIRECT3DLIGHT this) { static void activate(IDirect3DLightImpl* This) {
update(this); update(This);
/* If was not active, activate it */ /* If was not active, activate it */
if (this->is_active == 0) { if (This->is_active == 0) {
glEnable(this->light_num); glEnable(This->light_num);
this->is_active = 1; This->is_active = 1;
} }
return ; return ;
...@@ -94,80 +94,83 @@ static void activate(LPDIRECT3DLIGHT this) { ...@@ -94,80 +94,83 @@ static void activate(LPDIRECT3DLIGHT this) {
/******************************************************************************* /*******************************************************************************
* Light Creation functions * Light Creation functions
*/ */
LPDIRECT3DLIGHT d3dlight_create(LPDIRECT3D2 d3d) LPDIRECT3DLIGHT d3dlight_create(IDirect3D2Impl* d3d2)
{ {
LPDIRECT3DLIGHT mat; IDirect3DLightImpl* light;
mat = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(IDirect3DLight)); light = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(IDirect3DLightImpl));
mat->ref = 1; light->ref = 1;
mat->lpvtbl = &light_vtable; light->lpvtbl = &light_vtable;
mat->d3d.d3d2 = d3d; light->d3d.d3d2 = d3d2;
mat->type = D3D_2; light->type = D3D_2;
mat->next = NULL; light->next = NULL;
mat->prev = NULL; light->prev = NULL;
mat->activate = activate; light->activate = activate;
mat->is_active = 0; light->is_active = 0;
return mat; return (LPDIRECT3DLIGHT)light;
} }
LPDIRECT3DLIGHT d3dlight_create_dx3(LPDIRECT3D d3d) LPDIRECT3DLIGHT d3dlight_create_dx3(IDirect3DImpl* d3d1)
{ {
LPDIRECT3DLIGHT mat; IDirect3DLightImpl* light;
mat = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(IDirect3DLight)); light = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(IDirect3DLightImpl));
mat->ref = 1; light->ref = 1;
mat->lpvtbl = &light_vtable; light->lpvtbl = &light_vtable;
mat->d3d.d3d = d3d; light->d3d.d3d1 = d3d1;
mat->type = D3D_1; light->type = D3D_1;
mat->next = NULL; light->next = NULL;
mat->prev = NULL; light->prev = NULL;
mat->activate = activate; light->activate = activate;
mat->is_active = 0; light->is_active = 0;
return mat; return (LPDIRECT3DLIGHT)light;
} }
/******************************************************************************* /*******************************************************************************
* IDirect3DLight methods * IDirect3DLight methods
*/ */
static HRESULT WINAPI IDirect3DLight_QueryInterface(LPDIRECT3DLIGHT this, static HRESULT WINAPI IDirect3DLightImpl_QueryInterface(LPDIRECT3DLIGHT iface,
REFIID riid, REFIID riid,
LPVOID* ppvObj) LPVOID* ppvObj)
{ {
ICOM_THIS(IDirect3DLightImpl,iface);
char xrefiid[50]; char xrefiid[50];
WINE_StringFromCLSID((LPCLSID)riid,xrefiid); WINE_StringFromCLSID((LPCLSID)riid,xrefiid);
FIXME(ddraw, "(%p)->(%s,%p): stub\n", this, xrefiid,ppvObj); FIXME(ddraw, "(%p)->(%s,%p): stub\n", This, xrefiid,ppvObj);
return S_OK; return S_OK;
} }
static ULONG WINAPI IDirect3DLight_AddRef(LPDIRECT3DLIGHT this) static ULONG WINAPI IDirect3DLightImpl_AddRef(LPDIRECT3DLIGHT iface)
{ {
TRACE(ddraw, "(%p)->()incrementing from %lu.\n", this, this->ref ); ICOM_THIS(IDirect3DLightImpl,iface);
TRACE(ddraw, "(%p)->()incrementing from %lu.\n", This, This->ref );
return ++(this->ref); return ++(This->ref);
} }
static ULONG WINAPI IDirect3DLight_Release(LPDIRECT3DLIGHT this) static ULONG WINAPI IDirect3DLightImpl_Release(LPDIRECT3DLIGHT iface)
{ {
FIXME( ddraw, "(%p)->() decrementing from %lu.\n", this, this->ref ); ICOM_THIS(IDirect3DLightImpl,iface);
FIXME( ddraw, "(%p)->() decrementing from %lu.\n", This, This->ref );
if (!--(this->ref)) { if (!--(This->ref)) {
HeapFree(GetProcessHeap(),0,this); HeapFree(GetProcessHeap(),0,This);
return 0; return 0;
} }
return this->ref; return This->ref;
} }
/*** IDirect3DLight methods ***/ /*** IDirect3DLight methods ***/
...@@ -176,54 +179,57 @@ static void dump_light(LPD3DLIGHT light) ...@@ -176,54 +179,57 @@ static void dump_light(LPD3DLIGHT light)
fprintf(stderr, " dwSize : %ld\n", light->dwSize); fprintf(stderr, " dwSize : %ld\n", light->dwSize);
} }
static HRESULT WINAPI IDirect3DLight_GetLight(LPDIRECT3DLIGHT this, static HRESULT WINAPI IDirect3DLightImpl_GetLight(LPDIRECT3DLIGHT iface,
LPD3DLIGHT lpLight) LPD3DLIGHT lpLight)
{ {
TRACE(ddraw, "(%p)->(%p)\n", this, lpLight); ICOM_THIS(IDirect3DLightImpl,iface);
TRACE(ddraw, "(%p)->(%p)\n", This, lpLight);
if (TRACE_ON(ddraw)) if (TRACE_ON(ddraw))
dump_light(lpLight); dump_light(lpLight);
/* Copies the light structure */ /* Copies the light structure */
switch (this->type) { switch (This->type) {
case D3D_1: case D3D_1:
*((LPD3DLIGHT)lpLight) = *((LPD3DLIGHT) &(this->light)); *((LPD3DLIGHT)lpLight) = *((LPD3DLIGHT) &(This->light));
break; break;
case D3D_2: case D3D_2:
*((LPD3DLIGHT2)lpLight) = *((LPD3DLIGHT2) &(this->light)); *((LPD3DLIGHT2)lpLight) = *((LPD3DLIGHT2) &(This->light));
break; break;
} }
return DD_OK; return DD_OK;
} }
static HRESULT WINAPI IDirect3DLight_SetLight(LPDIRECT3DLIGHT this, static HRESULT WINAPI IDirect3DLightImpl_SetLight(LPDIRECT3DLIGHT iface,
LPD3DLIGHT lpLight) LPD3DLIGHT lpLight)
{ {
TRACE(ddraw, "(%p)->(%p)\n", this, lpLight); ICOM_THIS(IDirect3DLightImpl,iface);
TRACE(ddraw, "(%p)->(%p)\n", This, lpLight);
if (TRACE_ON(ddraw)) if (TRACE_ON(ddraw))
dump_light(lpLight); dump_light(lpLight);
/* Stores the light */ /* Stores the light */
switch (this->type) { switch (This->type) {
case D3D_1: case D3D_1:
*((LPD3DLIGHT) &(this->light)) = *((LPD3DLIGHT)lpLight); *((LPD3DLIGHT) &(This->light)) = *((LPD3DLIGHT)lpLight);
break; break;
case D3D_2: case D3D_2:
*((LPD3DLIGHT2) &(this->light)) = *((LPD3DLIGHT2)lpLight); *((LPD3DLIGHT2) &(This->light)) = *((LPD3DLIGHT2)lpLight);
break; break;
} }
if (this->is_active) if (This->is_active)
update(this); update(This);
return DD_OK; return DD_OK;
} }
static HRESULT WINAPI IDirect3DLight_Initialize(LPDIRECT3DLIGHT this, static HRESULT WINAPI IDirect3DLightImpl_Initialize(LPDIRECT3DLIGHT iface,
LPDIRECT3D lpDirect3D) LPDIRECT3D lpDirect3D)
{ {
TRACE(ddraw, "(%p)->(%p)\n", this, lpDirect3D); ICOM_THIS(IDirect3DLightImpl,iface);
TRACE(ddraw, "(%p)->(%p)\n", This, lpDirect3D);
return DDERR_ALREADYINITIALIZED; return DDERR_ALREADYINITIALIZED;
} }
...@@ -232,26 +238,26 @@ static HRESULT WINAPI IDirect3DLight_Initialize(LPDIRECT3DLIGHT this, ...@@ -232,26 +238,26 @@ static HRESULT WINAPI IDirect3DLight_Initialize(LPDIRECT3DLIGHT this,
/******************************************************************************* /*******************************************************************************
* IDirect3DLight VTable * IDirect3DLight VTable
*/ */
static IDirect3DLight_VTable light_vtable = { static ICOM_VTABLE(IDirect3DLight) light_vtable = {
/*** IUnknown methods ***/ /*** IUnknown methods ***/
IDirect3DLight_QueryInterface, IDirect3DLightImpl_QueryInterface,
IDirect3DLight_AddRef, IDirect3DLightImpl_AddRef,
IDirect3DLight_Release, IDirect3DLightImpl_Release,
/*** IDirect3DLight methods ***/ /*** IDirect3DLight methods ***/
IDirect3DLight_Initialize, IDirect3DLightImpl_Initialize,
IDirect3DLight_SetLight, IDirect3DLightImpl_SetLight,
IDirect3DLight_GetLight IDirect3DLightImpl_GetLight
}; };
#else /* HAVE_MESAGL */ #else /* HAVE_MESAGL */
/* These function should never be called if MesaGL is not present */ /* These function should never be called if MesaGL is not present */
LPDIRECT3DLIGHT d3dlight_create_dx3(LPDIRECT3D d3d) { LPDIRECT3DLIGHT d3dlight_create_dx3(IDirect3DImpl* d3d1) {
ERR(ddraw, "Should not be called...\n"); ERR(ddraw, "Should not be called...\n");
return NULL; return NULL;
} }
LPDIRECT3DLIGHT d3dlight_create(LPDIRECT3D2 d3d) { LPDIRECT3DLIGHT d3dlight_create(IDirect3D2Impl* d3d2) {
ERR(ddraw, "Should not be called...\n"); ERR(ddraw, "Should not be called...\n");
return NULL; return NULL;
} }
......
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment