Commit 91c6f817 authored by Lionel Ulmer's avatar Lionel Ulmer Committed by Alexandre Julliard

- rework how texturing is done in the D3D driver

- added the generic path for DrawPrimitive API in D3D 3 / 7
parent cc1577cd
......@@ -32,7 +32,6 @@
typedef struct IDirect3DImpl IDirect3DImpl;
typedef struct IDirect3DLightImpl IDirect3DLightImpl;
typedef struct IDirect3DMaterialImpl IDirect3DMaterialImpl;
typedef struct IDirect3DTextureImpl IDirect3DTextureImpl;
typedef struct IDirect3DViewportImpl IDirect3DViewportImpl;
typedef struct IDirect3DExecuteBufferImpl IDirect3DExecuteBufferImpl;
typedef struct IDirect3DDeviceImpl IDirect3DDeviceImpl;
......@@ -53,6 +52,9 @@ struct IDirect3DImpl
DWORD ref;
/* IDirect3D fields */
IDirectDrawImpl* ddraw;
/* Used as a callback function to create a texture */
HRESULT (*create_texture)(IDirect3DImpl *d3d, IDirectDrawSurfaceImpl *tex, BOOLEAN at_creation, IDirectDrawSurfaceImpl *main, DWORD mipmap_level);
};
/*****************************************************************************
......@@ -95,21 +97,6 @@ struct IDirect3DMaterialImpl
};
/*****************************************************************************
* IDirect3DTexture implementation structure
*/
struct IDirect3DTextureImpl
{
ICOM_VFIELD_MULTI(IDirect3DTexture2);
ICOM_VFIELD_MULTI(IDirect3DTexture);
DWORD ref;
/* IDirect3DTexture fields */
IDirect3DImpl *d3d;
IDirect3DDeviceImpl *d3ddevice;
IDirectDrawSurfaceImpl *surface;
BOOL loaded;
};
/*****************************************************************************
* IDirect3DViewport implementation structure
*/
struct IDirect3DViewportImpl
......@@ -183,7 +170,7 @@ struct IDirect3DDeviceImpl
IDirect3DViewportImpl *viewport_list;
IDirect3DViewportImpl *current_viewport;
IDirect3DTextureImpl *current_texture[MAX_TEXTURES];
IDirectDrawSurfaceImpl *current_texture[MAX_TEXTURES];
void (*set_context)(IDirect3DDeviceImpl*);
};
......
......@@ -160,7 +160,7 @@ static void fill_opengl_caps(D3DDEVICEDESC *d1)
fill_opengl_primcaps(&(d1->dpcLineCaps));
fill_opengl_primcaps(&(d1->dpcTriCaps));
d1->dwDeviceRenderBitDepth = DDBD_16|DDBD_24|DDBD_32;
d1->dwDeviceZBufferBitDepth = DDBD_16;
d1->dwDeviceZBufferBitDepth = DDBD_16|DDBD_24|DDBD_32;
d1->dwMaxBufferSize = 0;
d1->dwMaxVertexCount = 65536;
d1->dwMinTextureWidth = 1;
......@@ -842,19 +842,23 @@ GL_IDirect3DDeviceImpl_1_CreateExecuteBuffer(LPDIRECT3DDEVICE iface,
return ret_value;
}
DWORD get_flexible_vertex_size(DWORD d3dvtVertexType)
DWORD get_flexible_vertex_size(DWORD d3dvtVertexType, DWORD *elements)
{
DWORD size = 0;
DWORD elts = 0;
if (d3dvtVertexType & D3DFVF_NORMAL) size += 3 * sizeof(D3DVALUE);
if (d3dvtVertexType & D3DFVF_DIFFUSE) size += sizeof(DWORD);
if (d3dvtVertexType & D3DFVF_SPECULAR) size += sizeof(DWORD);
if (d3dvtVertexType & D3DFVF_NORMAL) { size += 3 * sizeof(D3DVALUE); elts += 1; }
if (d3dvtVertexType & D3DFVF_DIFFUSE) { size += sizeof(DWORD); elts += 1; }
if (d3dvtVertexType & D3DFVF_SPECULAR) { size += sizeof(DWORD); elts += 1; }
switch (d3dvtVertexType & D3DFVF_POSITION_MASK) {
case D3DFVF_XYZ: size += 3 * sizeof(D3DVALUE); break;
case D3DFVF_XYZRHW: size += 4 * sizeof(D3DVALUE); break;
case D3DFVF_XYZ: size += 3 * sizeof(D3DVALUE); elts += 1; break;
case D3DFVF_XYZRHW: size += 4 * sizeof(D3DVALUE); elts += 1; break;
default: TRACE(" matrix weighting not handled yet...\n");
}
size += 2 * sizeof(D3DVALUE) * ((d3dvtVertexType & D3DFVF_TEXCOUNT_MASK) >> D3DFVF_TEXCOUNT_SHIFT);
elts += (d3dvtVertexType & D3DFVF_TEXCOUNT_MASK) >> D3DFVF_TEXCOUNT_SHIFT;
if (elements) *elements = elts;
return size;
}
......@@ -908,6 +912,48 @@ typedef struct {
float tu1, tv1;
} D3DFVF_TLVERTEX_1;
typedef struct {
int offset;
int extra;
void (*handler)(char *vertex, int offset, int extra);
} D3DFVF_GENERIC;
/* These are the various handler used in the generic path */
static void handle_xyz(char *vertex, int offset, int extra) {
glVertex3fv((float *) (vertex + offset));
}
static void handle_xyzrhw(char *vertex, int offset, int extra) {
float *coords = (float *) (vertex + offset);
if (coords[3] < 0.00001)
glVertex3f(coords[0], coords[1], coords[2]);
else
glVertex4f(coords[0] / coords[3],
coords[1] / coords[3],
coords[2] / coords[3],
1.0 / coords[3]);
}
static void handle_normal(char *vertex, int offset, int extra) {
glNormal3fv((float *) (vertex + offset));
}
static void handle_specular(char *vertex, int offset, int extra) {
/* Specular not handled yet properly... */
}
static void handle_diffuse(char *vertex, int offset, int extra) {
DWORD color = *((DWORD *) (vertex + offset));
glColor4ub((color >> 24) & 0xFF,
(color >> 16) & 0xFF,
(color >> 8) & 0xFF,
(color >> 0) & 0xFF);
}
static void handle_texture(char *vertex, int offset, int extra) {
if (extra == 0xFF) {
/* Special case for single texture... */
glTexCoord2fv((float *) (vertex + offset));
} else {
/* Multitexturing not handled yet */
}
}
static void draw_primitive_7(IDirect3DDeviceImpl *This,
D3DPRIMITIVETYPE d3dptPrimitiveType,
DWORD d3dvtVertexType,
......@@ -936,9 +982,9 @@ static void draw_primitive_7(IDirect3DDeviceImpl *This,
for (index = 0; index < dwIndexCount; index++) {
int i = (dwIndices == NULL) ? index : dwIndices[index];
glNormal3f(vertices[i].nx, vertices[i].ny, vertices[i].nz);
glTexCoord2f(vertices[i].tu1, vertices[i].tv1);
glVertex3f(vertices[i].x, vertices[i].y, vertices[i].z);
glNormal3fv(&(vertices[i].nx));
glTexCoord2fv(&(vertices[i].tu1));
glVertex3fv(&(vertices[i].x));
TRACE(" %f %f %f / %f %f %f (%f %f)\n",
vertices[i].x, vertices[i].y, vertices[i].z,
vertices[i].nx, vertices[i].ny, vertices[i].nz,
......@@ -956,7 +1002,7 @@ static void draw_primitive_7(IDirect3DDeviceImpl *This,
(vertices[i].diffuse >> 8) & 0xFF,
(vertices[i].diffuse >> 0) & 0xFF);
/* Todo : handle specular... */
glTexCoord2f(vertices[i].tu1, vertices[i].tv1);
glTexCoord2fv(&(vertices[i].tu1));
if (vertices[i].rhw < 0.00001)
glVertex3f(vertices[i].x, vertices[i].y, vertices[i].z);
else
......@@ -976,6 +1022,76 @@ static void draw_primitive_7(IDirect3DDeviceImpl *This,
(vertices[i].specular >> 0) & 0xFF,
vertices[i].tu1, vertices[i].tv1);
}
} else if (((d3dvtVertexType & D3DFVF_POSITION_MASK) == D3DFVF_XYZ) ||
((d3dvtVertexType & D3DFVF_POSITION_MASK) == D3DFVF_XYZRHW)) {
/* This is the 'slow path' but that should support all possible vertex formats out there...
Note that people should write a fast path for all vertex formats out there...
*/
DWORD elements;
DWORD size = get_flexible_vertex_size(d3dvtVertexType, &elements);
char *vertices = (char *) lpvVertices;
int index;
int current_offset = 0;
int current_position = 0;
D3DFVF_GENERIC *handler = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, elements * sizeof(D3DFVF_GENERIC));
WARN(" using draw_primitive generic path - for better performance, add a fast path for your vertex case !\n");
if ((d3dvtVertexType & D3DFVF_POSITION_MASK) == D3DFVF_XYZ) {
handler[elements - 1].handler = handle_xyz;
handler[elements - 1].offset = current_offset;
current_offset += 3 * sizeof(D3DVALUE);
} else {
handler[elements - 1].handler = handle_xyzrhw;
handler[elements - 1].offset = current_offset;
current_offset += 4 * sizeof(D3DVALUE);
}
if (d3dvtVertexType & D3DFVF_NORMAL) {
handler[current_position].handler = handle_normal;
handler[current_position].offset = current_offset;
current_position += 1;
current_offset += 3 * sizeof(D3DVALUE);
}
if (d3dvtVertexType & D3DFVF_DIFFUSE) {
handler[current_position].handler = handle_diffuse;
handler[current_position].offset = current_offset;
current_position += 1;
current_offset += sizeof(DWORD);
}
if (d3dvtVertexType & D3DFVF_SPECULAR) {
handler[current_position].handler = handle_specular;
handler[current_position].offset = current_offset;
current_position += 1;
current_offset += sizeof(DWORD);
}
if (((d3dvtVertexType & D3DFVF_TEXCOUNT_MASK) >> D3DFVF_TEXCOUNT_SHIFT) == 1) {
handler[current_position].handler = handle_texture;
handler[current_position].offset = current_offset;
handler[current_position].extra = 0xFF;
current_position += 1;
current_offset += 2 * sizeof(D3DVALUE);
} else {
int tex_index;
for (tex_index = 0; tex_index < ((d3dvtVertexType & D3DFVF_TEXCOUNT_MASK) >> D3DFVF_TEXCOUNT_SHIFT); tex_index++) {
handler[current_position].handler = handle_texture;
handler[current_position].offset = current_offset;
handler[current_position].extra = tex_index;
current_position += 1;
current_offset += 2 * sizeof(D3DVALUE);
}
}
for (index = 0; index < dwIndexCount; index++) {
int i = (dwIndices == NULL) ? index : dwIndices[index];
int elt;
char *vertex = vertices + (i * size);
for (elt = 0; elt < elements; elt++) {
handler[elt].handler(vertex, handler[elt].offset, handler[elt].extra);
}
}
} else {
ERR(" matrix weighting not handled yet....\n");
}
glEnd();
......@@ -1130,11 +1246,11 @@ GL_IDirect3DDeviceImpl_3_SetTexture(LPDIRECT3DDEVICE3 iface,
glBindTexture(GL_TEXTURE_2D, 0);
glDisable(GL_TEXTURE_2D);
} else {
IDirect3DTextureImpl *tex_impl = ICOM_OBJECT(IDirect3DTextureImpl, IDirect3DTexture2, lpTexture2);
IDirect3DTextureGLImpl *tex_glimpl = (IDirect3DTextureGLImpl *) tex_impl;
IDirectDrawSurfaceImpl *tex_impl = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirect3DTexture2, lpTexture2);
IDirect3DTextureGLImpl *tex_glimpl = (IDirect3DTextureGLImpl *) tex_impl->tex_private;
This->current_texture[dwStage] = tex_impl;
IDirect3DTexture2_AddRef(lpTexture2);
IDirectDrawSurface7_AddRef(ICOM_INTERFACE(tex_impl, IDirectDrawSurface7));
TRACE(" activating OpenGL texture %d.\n", tex_glimpl->tex_name);
......@@ -1453,7 +1569,6 @@ static void d3ddevice_unlock_update(IDirectDrawSurfaceImpl* This, LPCRECT pRect)
LEAVE_GL();
return;
}
glRasterPos2f(0.0, 0.0);
glDrawPixels(This->surface_desc.dwWidth, This->surface_desc.dwHeight,
GL_RGB, buffer_type, This->surface_desc.lpSurface);
......
......@@ -303,7 +303,7 @@ HRESULT d3dvertexbuffer_create(IDirect3DVertexBufferImpl **obj, IDirect3DImpl *d
object->ref = 1;
object->d3d = d3d;
object->desc = *lpD3DVertBufDesc;
object->vertex_buffer_size = get_flexible_vertex_size(lpD3DVertBufDesc->dwFVF) * lpD3DVertBufDesc->dwNumVertices;
object->vertex_buffer_size = get_flexible_vertex_size(lpD3DVertBufDesc->dwFVF, NULL) * lpD3DVertBufDesc->dwNumVertices;
object->vertices = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, object->vertex_buffer_size);
ICOM_INIT_INTERFACE(object, IDirect3DVertexBuffer, VTABLE_IDirect3DVertexBuffer);
......
......@@ -177,7 +177,10 @@ HRESULT WINAPI Main_DirectDraw_QueryInterface(
*obj = ICOM_INTERFACE(This, IDirectDraw4);
}
#ifdef HAVE_OPENGL
else if ( IsEqualGUID( &IID_IDirect3D , refiid ) )
else if ( IsEqualGUID( &IID_IDirect3D , refiid ) ||
IsEqualGUID( &IID_IDirect3D2 , refiid ) ||
IsEqualGUID( &IID_IDirect3D3 , refiid ) ||
IsEqualGUID( &IID_IDirect3D7 , refiid ) )
{
IDirect3DImpl *d3d_impl;
HRESULT ret_value;
......@@ -185,49 +188,23 @@ HRESULT WINAPI Main_DirectDraw_QueryInterface(
ret_value = direct3d_create(&d3d_impl, This);
if (FAILED(ret_value)) return ret_value;
if ( IsEqualGUID( &IID_IDirect3D , refiid ) ) {
*obj = ICOM_INTERFACE(d3d_impl, IDirect3D);
/* And store the D3D object */
This->d3d = d3d_impl;
TRACE(" returning Direct3D interface at %p.\n", *obj);
}
else if ( IsEqualGUID( &IID_IDirect3D2 , refiid ) )
{
IDirect3DImpl *d3d_impl;
HRESULT ret_value;
ret_value = direct3d_create(&d3d_impl, This);
if (FAILED(ret_value)) return ret_value;
} else if ( IsEqualGUID( &IID_IDirect3D2 , refiid ) ) {
*obj = ICOM_INTERFACE(d3d_impl, IDirect3D2);
TRACE(" returning Direct3D2 interface at %p.\n", *obj);
}
else if ( IsEqualGUID( &IID_IDirect3D3 , refiid ) )
{
IDirect3DImpl *d3d_impl;
HRESULT ret_value;
ret_value = direct3d_create(&d3d_impl, This);
if (FAILED(ret_value)) return ret_value;
} else if ( IsEqualGUID( &IID_IDirect3D3 , refiid ) ) {
*obj = ICOM_INTERFACE(d3d_impl, IDirect3D3);
TRACE(" returning Direct3D3 interface at %p.\n", *obj);
}
else if ( IsEqualGUID( &IID_IDirect3D7 , refiid ) )
{
IDirect3DImpl *d3d_impl;
HRESULT ret_value;
ret_value = direct3d_create(&d3d_impl, This);
if (FAILED(ret_value)) return ret_value;
} else {
*obj = ICOM_INTERFACE(d3d_impl, IDirect3D7);
TRACE(" returning Direct3D7 interface at %p.\n", *obj);
}
/* And store the D3D object */
This->d3d = d3d_impl;
}
#endif
else
{
......@@ -375,6 +352,9 @@ create_texture(IDirectDrawImpl* This, const DDSURFACEDESC2 *pDDSD,
hr = This->create_texture(This, &ddsd, ppSurf, pUnkOuter, mipmap_level);
if (FAILED(hr)) return hr;
if (This->d3d) This->d3d->create_texture(This->d3d, ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, *ppSurf), TRUE,
ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, *ppSurf), mipmap_level);
/* Create attached mipmaps if required. */
if (more_mipmaps(&ddsd))
{
......@@ -411,6 +391,8 @@ create_texture(IDirectDrawImpl* This, const DDSURFACEDESC2 *pDDSD,
IDirectDrawSurface7_Release(*ppSurf);
return hr;
}
if (This->d3d) This->d3d->create_texture(This->d3d, ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, *ppSurf), TRUE,
ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, *ppSurf), mipmap_level);
IDirectDrawSurface7_AddAttachedSurface(prev_mipmap, mipmap);
IDirectDrawSurface7_Release(prev_mipmap);
......@@ -1131,6 +1113,11 @@ Main_DirectDraw_GetAvailableVidMem(LPDIRECTDRAW7 iface, LPDDSCAPS2 ddscaps,
ICOM_THIS(IDirectDrawImpl,iface);
TRACE("(%p)->(%p,%p,%p)\n", This,ddscaps,total,free);
if (TRACE_ON(ddraw)) {
TRACE(" Asking for memory of type : \n");
DDRAW_dump_DDSCAPS2(ddscaps);
}
/* We have 16 MB videomemory */
if (total) *total= This->total_vidmem;
if (free) *free = This->available_vidmem;
......
......@@ -26,6 +26,7 @@
#include "wingdi.h"
#include "winuser.h"
#include "ddraw.h"
#include "d3d.h"
#include "ddcomimpl.h"
#include "ddrawi.h"
......@@ -220,6 +221,8 @@ struct IDirectDrawSurfaceImpl
ICOM_VFIELD_MULTI(IDirectDrawSurface7);
ICOM_VFIELD_MULTI(IDirectDrawSurface3);
ICOM_VFIELD_MULTI(IDirectDrawGammaControl);
ICOM_VFIELD_MULTI(IDirect3DTexture2);
ICOM_VFIELD_MULTI(IDirect3DTexture);
DWORD ref;
struct IDirectDrawSurfaceImpl* attached; /* attached surfaces */
......@@ -289,10 +292,10 @@ struct IDirectDrawSurfaceImpl
void (*aux_release)(LPVOID ctx, LPVOID data);
BOOL (*aux_flip)(LPVOID ctx, LPVOID data);
void (*aux_unlock)(LPVOID ctx, LPVOID data, LPRECT lpRect);
struct IDirect3DTextureImpl *texture;
HRESULT (WINAPI *SetColorKey_cb)(struct IDirect3DTextureImpl *texture, DWORD dwFlags, LPDDCOLORKEY ckey ) ;
HRESULT (WINAPI *SetColorKey_cb)(struct IDirectDrawSurfaceImpl *texture, DWORD dwFlags, LPDDCOLORKEY ckey ) ;
/* This is to get the D3DDevice object associated to this surface */
struct IDirect3DDeviceImpl *d3ddevice;
LPVOID tex_private;
};
/*****************************************************************************
......
......@@ -387,6 +387,7 @@ HRESULT direct3d_create(IDirect3DImpl **obj, IDirectDrawImpl *ddraw)
object->ref = 1;
object->ddraw = ddraw;
object->create_texture = d3dtexture_create;
ICOM_INIT_INTERFACE(object, IDirect3D, VTABLE_IDirect3D);
ICOM_INIT_INTERFACE(object, IDirect3D2, VTABLE_IDirect3D2);
......
......@@ -81,7 +81,7 @@ Main_DirectDrawSurface_Construct(IDirectDrawSurfaceImpl *This,
DDRAW_IDDS3_Thunk_VTable);
ICOM_INIT_INTERFACE(This, IDirectDrawGammaControl,
DDRAW_IDDGC_VTable);
/* There is no generic implementation of IDDS7 */
/* There is no generic implementation of IDDS7 or texture */
Main_DirectDraw_AddSurface(pDD, This);
return DD_OK;
......@@ -101,6 +101,7 @@ static void Main_DirectDrawSurface_Destroy(IDirectDrawSurfaceImpl* This)
{
This->final_release(This);
if (This->private != This+1) HeapFree(GetProcessHeap(), 0, This->private);
if (This->tex_private) HeapFree(GetProcessHeap(), 0, This->tex_private);
HeapFree(GetProcessHeap(), 0, This);
}
......@@ -146,6 +147,8 @@ Main_DirectDrawSurface_QueryInterface(LPDIRECTDRAWSURFACE7 iface, REFIID riid,
ICOM_THIS(IDirectDrawSurfaceImpl, iface);
TRACE("(%p)->(%s,%p)\n", This, debugstr_guid(riid), ppObj);
*ppObj = NULL;
if (IsEqualGUID(&IID_IUnknown, riid)
|| IsEqualGUID(&IID_IDirectDrawSurface7, riid)
|| IsEqualGUID(&IID_IDirectDrawSurface4, riid))
......@@ -184,32 +187,38 @@ Main_DirectDrawSurface_QueryInterface(LPDIRECTDRAWSURFACE7 iface, REFIID riid,
This->ref++; /* No idea if this is correct.. Need to check using real Windows */
return ret_value;
}
else if (IsEqualGUID( &IID_IDirect3DTexture, riid ))
else if (IsEqualGUID( &IID_IDirect3DTexture, riid ) ||
IsEqualGUID( &IID_IDirect3DTexture2, riid ))
{
IDirect3DTextureImpl *d3dteximpl;
HRESULT ret_value;
ret_value = d3dtexture_create(&d3dteximpl, NULL, This);
if (FAILED(ret_value)) return ret_value;
*ppObj = ICOM_INTERFACE(d3dteximpl, IDirect3DTexture);
TRACE(" returning Direct3DTexture interface at %p.\n", *ppObj);
HRESULT ret_value = S_OK;
/* In case the texture surface was created before the D3D creation */
if ((This->surface_desc.ddsCaps.dwCaps & DDSCAPS_TEXTURE) == 0) return E_NOINTERFACE;
/* Create a 'delayed' private field only if it is not an offscreen texture... */
if ((This->tex_private == NULL) &&
((This->surface_desc.ddsCaps.dwCaps & (DDSCAPS_OFFSCREENPLAIN|DDSCAPS_SYSTEMMEMORY)) == 0)) {
if (This->ddraw_owner->d3d == NULL) {
ERR("Texture created with no D3D object yet.. Not supported !\n");
return E_NOINTERFACE;
}
This->ref++; /* No idea if this is correct.. Need to check using real Windows */
return ret_value;
if (((This->surface_desc.dwFlags & DDSD_MIPMAPCOUNT) &&
(This->surface_desc.u2.dwMipMapCount > 1)) ||
(This->surface_desc.ddsCaps.dwCaps2 & DDSCAPS2_MIPMAPSUBLEVEL)) {
ERR(" need to fix mipmaping in this case !!\n");
}
else if (IsEqualGUID( &IID_IDirect3DTexture2, riid ))
{
IDirect3DTextureImpl *d3dteximpl;
HRESULT ret_value;
ret_value = d3dtexture_create(&d3dteximpl, NULL, This);
ret_value = This->ddraw_owner->d3d->create_texture(This->ddraw_owner->d3d, This, FALSE, NULL, 0);
if (FAILED(ret_value)) return ret_value;
*ppObj = ICOM_INTERFACE(d3dteximpl, IDirect3DTexture2);
}
if (IsEqualGUID( &IID_IDirect3DTexture, riid )) {
*ppObj = ICOM_INTERFACE(This, IDirect3DTexture);
TRACE(" returning Direct3DTexture interface at %p.\n", *ppObj);
} else {
*ppObj = ICOM_INTERFACE(This, IDirect3DTexture2);
TRACE(" returning Direct3DTexture2 interface at %p.\n", *ppObj);
This->ref++; /* No idea if this is correct.. Need to check using real Windows */
}
This->ref++;
return ret_value;
}
#endif
......
......@@ -46,14 +46,14 @@ void set_render_state(D3DRENDERSTATETYPE dwRenderStateType,
/* All others state variables */
switch (dwRenderStateType) {
case D3DRENDERSTATE_TEXTUREHANDLE: { /* 1 */
IDirect3DTextureImpl *tex = (IDirect3DTextureImpl*) dwRenderState;
IDirectDrawSurfaceImpl *tex = (IDirectDrawSurfaceImpl*) dwRenderState;
if (tex == NULL) {
glBindTexture(GL_TEXTURE_2D, 0);
glDisable(GL_TEXTURE_2D);
TRACE("disabling texturing\n");
} else {
IDirect3DTextureGLImpl *gl_tex = (IDirect3DTextureGLImpl *) tex;
IDirect3DTextureGLImpl *gl_tex = (IDirect3DTextureGLImpl *) tex->tex_private;
glEnable(GL_TEXTURE_2D);
/* Default parameters */
......
......@@ -82,10 +82,17 @@ typedef struct IDirect3DLightGLImpl
GLenum light_num;
} IDirect3DLightGLImpl;
/* This structure is used for the 'private' field of the IDirectDrawSurfaceImpl structure */
typedef struct IDirect3DTextureGLImpl
{
struct IDirect3DTextureImpl parent;
GLuint tex_name;
BOOLEAN loaded; /* For the moment, this is here.. Should be part of surface management though */
BOOLEAN first_unlock;
DWORD mipmap_level;
/* This is for now used to override 'standard' surface stuff to be as transparent as possible */
void (*final_release)(struct IDirectDrawSurfaceImpl *This);
void (*lock_update)(IDirectDrawSurfaceImpl* This, LPCRECT pRect, DWORD dwFlags);
void (*unlock_update)(IDirectDrawSurfaceImpl* This, LPCRECT pRect);
} IDirect3DTextureGLImpl;
typedef struct IDirect3DDeviceGLImpl
......@@ -111,7 +118,7 @@ typedef struct IDirect3DDeviceGLImpl
/* All non-static functions 'exported' by various sub-objects */
extern HRESULT direct3d_create(IDirect3DImpl **obj, IDirectDrawImpl *ddraw);
extern HRESULT d3dtexture_create(IDirect3DTextureImpl **obj, IDirect3DImpl *d3d, IDirectDrawSurfaceImpl *surf);
extern HRESULT d3dtexture_create(IDirect3DImpl *d3d, IDirectDrawSurfaceImpl *surf, BOOLEAN at_creation, IDirectDrawSurfaceImpl *main_surf, DWORD mipmap_level);
extern HRESULT d3dlight_create(IDirect3DLightImpl **obj, IDirect3DImpl *d3d, GLenum light_num);
extern HRESULT d3dexecutebuffer_create(IDirect3DExecuteBufferImpl **obj, IDirect3DImpl *d3d, IDirect3DDeviceImpl *d3ddev, LPD3DEXECUTEBUFFERDESC lpDesc);
extern HRESULT d3dmaterial_create(IDirect3DMaterialImpl **obj, IDirect3DImpl *d3d);
......@@ -126,7 +133,7 @@ extern HRESULT d3ddevice_find(IDirect3DImpl *d3d, LPD3DFINDDEVICESEARCH lpD3DDFS
/* Some helper functions.. Would need to put them in a better place */
extern void dump_flexible_vertex(DWORD d3dvtVertexType);
extern DWORD get_flexible_vertex_size(DWORD d3dvtVertexType);
extern DWORD get_flexible_vertex_size(DWORD d3dvtVertexType, DWORD *elements);
/* Matrix copy WITH transposition */
#define conv_mat2(mat,gl_mat) \
......
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