- fix Direct3D support and a lot of warnings

- add support for DDraw in a window (not optimized yet)
- cleans up OpenGL extensions handling for D3D
This commit is contained in:
Lionel Ulmer 2000-07-16 14:40:35 +00:00 committed by Alexandre Julliard
parent 0e805aa358
commit a8cc5f543e
16 changed files with 434 additions and 374 deletions

375
configure vendored

File diff suppressed because it is too large Load Diff

View File

@ -250,13 +250,6 @@ then
if test $ac_cv_lib_GL_glXCreateContext = "yes" if test $ac_cv_lib_GL_glXCreateContext = "yes"
then then
dnl Check for the Color Table and Paletted Texture extensions
AC_CACHE_CHECK("for the OpenGL Color Index extension",dummy,
AC_TRY_COMPILE([#include <GL/gl.h>],
[GLenum test = GL_COLOR_INDEX8_EXT;],
[AC_DEFINE(HAVE_GL_COLOR_TABLE)],))
AC_CHECK_LIB(GL,glColorTableEXT,AC_DEFINE(HAVE_GL_PALETTED_TEXTURE),,$X_LIBS -lXext -lX11 -lm $X_EXTRA_LIBS)
AC_CHECK_LIB(GL,glXGetProcAddressARB,AC_DEFINE(HAVE_GLX_GETPROCADDRESS),,$X_LIBS -lXext -lX11 -lm $X_EXTRA_LIBS) AC_CHECK_LIB(GL,glXGetProcAddressARB,AC_DEFINE(HAVE_GLX_GETPROCADDRESS),,$X_LIBS -lXext -lX11 -lm $X_EXTRA_LIBS)
if test $ac_cv_lib_GL_glXGetProcAddressARB = "yes" if test $ac_cv_lib_GL_glXGetProcAddressARB = "yes"

View File

@ -324,7 +324,7 @@ struct IDirect3DExecuteBufferImpl
void (*execute)(IDirect3DExecuteBuffer* this, void (*execute)(IDirect3DExecuteBuffer* this,
IDirect3DDevice* dev, IDirect3DDevice* dev,
IDirect3DViewport2* vp); IDirect3DViewport* vp);
LPVOID private; LPVOID private;
}; };
extern LPDIRECT3DEXECUTEBUFFER d3dexecutebuffer_create(IDirect3DDeviceImpl* d3ddev, LPD3DEXECUTEBUFFERDESC lpDesc); extern LPDIRECT3DEXECUTEBUFFER d3dexecutebuffer_create(IDirect3DDeviceImpl* d3ddev, LPD3DEXECUTEBUFFERDESC lpDesc);

View File

@ -490,7 +490,7 @@ HRESULT WINAPI IDirect3DDeviceImpl_Execute(
/* Put this as the default context */ /* Put this as the default context */
/* Execute... */ /* Execute... */
((IDirect3DExecuteBufferImpl*)lpDirect3DExecuteBuffer)->execute(lpDirect3DExecuteBuffer, iface, (IDirect3DViewport2*)lpDirect3DViewport); ((IDirect3DExecuteBufferImpl*)lpDirect3DExecuteBuffer)->execute(lpDirect3DExecuteBuffer, iface, (IDirect3DViewport*)lpDirect3DViewport);
return DD_OK; return DD_OK;
} }

View File

@ -30,6 +30,13 @@ ICOM_VTABLE(IDirect3DDevice) OpenGL_vtable_dx3;
#define D3DDPRIVATE(x) mesa_d3dd_private *odev=((mesa_d3dd_private*)x->private) #define D3DDPRIVATE(x) mesa_d3dd_private *odev=((mesa_d3dd_private*)x->private)
#define DDPRIVATE(x) x11_dd_private *ddpriv=((x11_dd_private*)(x)->private) #define DDPRIVATE(x) x11_dd_private *ddpriv=((x11_dd_private*)(x)->private)
static const float id_mat[16] = {
1.0, 0.0, 0.0, 0.0,
0.0, 1.0, 0.0, 0.0,
0.0, 0.0, 1.0, 0.0,
0.0, 0.0, 0.0, 1.0
};
/******************************************************************************* /*******************************************************************************
* OpenGL static functions * OpenGL static functions
*/ */
@ -108,11 +115,31 @@ static void fill_opengl_caps(D3DDEVICEDESC *d1, D3DDEVICEDESC *d2)
d2->dwFlags = 0; d2->dwFlags = 0;
} }
static void fill_device_capabilities(IDirectDrawImpl* ddraw) {
x11_dd_private *private = (x11_dd_private *) ddraw->private;
const char *ext_string;
Mesa_DeviceCapabilities *devcap;
private->device_capabilities = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(Mesa_DeviceCapabilities));
devcap = (Mesa_DeviceCapabilities *) private->device_capabilities;
ENTER_GL();
ext_string = glGetString(GL_EXTENSIONS);
/* Query for the ColorTable Extension */
if (strstr(ext_string, "GL_EXT_paletted_texture")) {
devcap->ptr_ColorTableEXT = (PFNGLCOLORTABLEEXTPROC) glXGetProcAddressARB("glColorTableEXT");
TRACE("Color table extension supported (function at %p)\n", devcap->ptr_ColorTableEXT);
} else {
TRACE("Color table extension not found.\n");
}
LEAVE_GL();
}
int d3d_OpenGL(LPD3DENUMDEVICESCALLBACK cb, LPVOID context) { int d3d_OpenGL(LPD3DENUMDEVICESCALLBACK cb, LPVOID context) {
D3DDEVICEDESC d1,d2; D3DDEVICEDESC d1,d2;
TRACE(" Enumerating OpenGL D3D device.\n"); TRACE(" Enumerating OpenGL D3D2 device (IID %s).\n", debugstr_guid(&IID_D3DDEVICE2_OpenGL));
fill_opengl_caps(&d1, &d2); fill_opengl_caps(&d1, &d2);
return cb((void*)&IID_D3DDEVICE2_OpenGL,"WINE Direct3D using OpenGL","direct3d",&d1,&d2,context); return cb((void*)&IID_D3DDEVICE2_OpenGL,"WINE Direct3D2 using OpenGL","direct3d",&d1,&d2,context);
} }
int int
@ -129,17 +156,6 @@ is_OpenGL(
/* OpenGL Device */ /* OpenGL Device */
(!memcmp(&IID_D3DDEVICE2_OpenGL,rguid,sizeof(IID_D3DDEVICE2_OpenGL)))) { (!memcmp(&IID_D3DDEVICE2_OpenGL,rguid,sizeof(IID_D3DDEVICE2_OpenGL)))) {
const float id_mat[16] = {
1.0, 0.0, 0.0, 0.0,
0.0, 1.0, 0.0, 0.0,
0.0, 0.0, 1.0, 0.0,
0.0, 0.0, 0.0, 1.0
};
#ifndef USE_OSMESA
int attributeList[]={ GLX_RGBA, GLX_DEPTH_SIZE, 16, GLX_DOUBLEBUFFER, None };
XVisualInfo *xvis;
#endif
*device = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(IDirect3DDevice2Impl)); *device = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(IDirect3DDevice2Impl));
(*device)->private = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(mesa_d3dd_private)); (*device)->private = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(mesa_d3dd_private));
odev = (mesa_d3dd_private*)(*device)->private; odev = (mesa_d3dd_private*)(*device)->private;
@ -159,38 +175,34 @@ is_OpenGL(
surface->s.surface_desc.dwWidth * surface->s.surface_desc.dwHeight * 4); surface->s.surface_desc.dwWidth * surface->s.surface_desc.dwHeight * 4);
#else #else
/* First get the correct visual */ /* First get the correct visual */
/* if (surface->s.backbuffer == NULL)
attributeList[3] = None; */
ENTER_GL(); ENTER_GL();
xvis = glXChooseVisual(display,
DefaultScreen(display),
attributeList);
if (xvis == NULL)
ERR("No visual found !\n");
else
TRACE("Visual found\n");
/* Create the context */ /* Create the context */
odev->ctx = glXCreateContext(display, {
xvis, XVisualInfo *vis;
NULL, int num;
GL_TRUE); XVisualInfo template;
template.visualid = XVisualIDFromVisual(visual);
vis = XGetVisualInfo(display, VisualIDMask, &template, &num);
odev->ctx = glXCreateContext(display, vis,
NULL, GL_TRUE);
}
if (odev->ctx == NULL) if (odev->ctx == NULL)
ERR("Error in context creation !\n"); ERR("Error in context creation !\n");
else else
TRACE("Context created (%p)\n", odev->ctx); TRACE("Context created (%p)\n", odev->ctx);
#if 0 /* not functional currently */
/* Now override the surface's Flip method (if in double buffering) */ /* Now override the surface's Flip method (if in double buffering) */
surface->s.d3d_device = (void *) odev; ((x11_ds_private *) surface->private)->opengl_flip = TRUE;
{ {
int i; int i;
struct _surface_chain *chain = surface->s.chain; struct _surface_chain *chain = surface->s.chain;
for (i=0;i<chain->nrofsurfaces;i++) for (i=0;i<chain->nrofsurfaces;i++)
if (chain->surfaces[i]->s.surface_desc.ddsCaps.dwCaps & DDSCAPS_FLIP) if (chain->surfaces[i]->s.surface_desc.ddsCaps.dwCaps & DDSCAPS_FLIP)
chain->surfaces[i]->s.d3d_device = (void *) odev; ((x11_ds_private *) chain->surfaces[i]->private)->opengl_flip = TRUE;
} }
#endif
#endif #endif
odev->rs.src = GL_ONE; odev->rs.src = GL_ONE;
@ -198,6 +210,11 @@ is_OpenGL(
odev->rs.mag = GL_NEAREST; odev->rs.mag = GL_NEAREST;
odev->rs.min = GL_NEAREST; odev->rs.min = GL_NEAREST;
odev->vt = 0; odev->vt = 0;
/* Allocate memory for the matrices */
odev->world_mat = (D3DMATRIX *) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, 16 * sizeof(float));
odev->view_mat = (D3DMATRIX *) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, 16 * sizeof(float));
odev->proj_mat = (D3DMATRIX *) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, 16 * sizeof(float));
memcpy(odev->world_mat, id_mat, 16 * sizeof(float)); memcpy(odev->world_mat, id_mat, 16 * sizeof(float));
memcpy(odev->view_mat , id_mat, 16 * sizeof(float)); memcpy(odev->view_mat , id_mat, 16 * sizeof(float));
@ -210,6 +227,9 @@ is_OpenGL(
glClearColor(0.0, 0.0, 0.0, 0.0); glClearColor(0.0, 0.0, 0.0, 0.0);
glColor3f(1.0, 1.0, 1.0); glColor3f(1.0, 1.0, 1.0);
LEAVE_GL(); LEAVE_GL();
fill_device_capabilities(d3d->ddraw);
TRACE("OpenGL device created \n"); TRACE("OpenGL device created \n");
return 1; return 1;
} }
@ -330,7 +350,6 @@ static HRESULT enum_texture_format_OpenGL(LPD3DENUMTEXTUREFORMATSCALLBACK cb,
return DD_OK; return DD_OK;
#endif #endif
#if defined(HAVE_GL_COLOR_TABLE) && defined(HAVE_GL_PALETTED_TEXTURE)
TRACE("Enumerating Paletted (8)\n"); TRACE("Enumerating Paletted (8)\n");
pformat->dwFlags = DDPF_PALETTEINDEXED8; pformat->dwFlags = DDPF_PALETTEINDEXED8;
pformat->u.dwRGBBitCount = 8; pformat->u.dwRGBBitCount = 8;
@ -340,7 +359,6 @@ static HRESULT enum_texture_format_OpenGL(LPD3DENUMTEXTUREFORMATSCALLBACK cb,
pformat->u4.dwRGBAlphaBitMask = 0x00000000; pformat->u4.dwRGBAlphaBitMask = 0x00000000;
if (cb(&sdesc, context) == 0) if (cb(&sdesc, context) == 0)
return DD_OK; return DD_OK;
#endif
TRACE("End of enumeration\n"); TRACE("End of enumeration\n");
@ -529,21 +547,21 @@ static HRESULT WINAPI MESA_IDirect3DDevice2Impl_SetTransform(
case D3DTRANSFORMSTATE_WORLD: { case D3DTRANSFORMSTATE_WORLD: {
conv_mat(lpmatrix, odev->world_mat); conv_mat(lpmatrix, odev->world_mat);
glMatrixMode(GL_MODELVIEW); glMatrixMode(GL_MODELVIEW);
glLoadMatrixf((float *) &(odev->world_mat)); glLoadMatrixf((float *) odev->world_mat);
} break; } break;
case D3DTRANSFORMSTATE_VIEW: { case D3DTRANSFORMSTATE_VIEW: {
conv_mat(lpmatrix, odev->view_mat); conv_mat(lpmatrix, odev->view_mat);
glMatrixMode(GL_PROJECTION); glMatrixMode(GL_PROJECTION);
glLoadMatrixf((float *) &(odev->proj_mat)); glLoadMatrixf((float *) odev->proj_mat);
glMultMatrixf((float *) &(odev->view_mat)); glMultMatrixf((float *) odev->view_mat);
} break; } break;
case D3DTRANSFORMSTATE_PROJECTION: { case D3DTRANSFORMSTATE_PROJECTION: {
conv_mat(lpmatrix, odev->proj_mat); conv_mat(lpmatrix, odev->proj_mat);
glMatrixMode(GL_PROJECTION); glMatrixMode(GL_PROJECTION);
glLoadMatrixf((float *) &(odev->proj_mat)); glLoadMatrixf((float *) odev->proj_mat);
glMultMatrixf((float *) &(odev->view_mat)); glMultMatrixf((float *) odev->view_mat);
} break; } break;
default: default:
@ -559,10 +577,10 @@ static HRESULT WINAPI MESA_IDirect3DDevice2Impl_SetTransform(
if (odev->vt == D3DVT_TLVERTEX) { \ if (odev->vt == D3DVT_TLVERTEX) { \
/* Need to put the correct transformation again */ \ /* Need to put the correct transformation again */ \
glMatrixMode(GL_MODELVIEW); \ glMatrixMode(GL_MODELVIEW); \
glLoadMatrixf((float *) &(odev->world_mat)); \ glLoadMatrixf((float *) odev->world_mat); \
glMatrixMode(GL_PROJECTION); \ glMatrixMode(GL_PROJECTION); \
glLoadMatrixf((float *) &(odev->proj_mat)); \ glLoadMatrixf((float *) odev->proj_mat); \
glMultMatrixf((float *) &(odev->view_mat)); \ glMultMatrixf((float *) odev->view_mat); \
} \ } \
\ \
switch (d3dv) { \ switch (d3dv) { \
@ -820,20 +838,13 @@ ICOM_VTABLE(IDirect3DDevice2) OpenGL_vtable =
int d3d_OpenGL_dx3(LPD3DENUMDEVICESCALLBACK cb, LPVOID context) { int d3d_OpenGL_dx3(LPD3DENUMDEVICESCALLBACK cb, LPVOID context) {
D3DDEVICEDESC d1,d2; D3DDEVICEDESC d1,d2;
TRACE(" Enumerating OpenGL D3D device.\n"); TRACE(" Enumerating OpenGL D3D device (IID %s).\n", debugstr_guid(&IID_D3DDEVICE_OpenGL));
fill_opengl_caps(&d1, &d2); fill_opengl_caps(&d1, &d2);
return cb((void*)&IID_D3DDEVICE_OpenGL,"WINE Direct3D using OpenGL","direct3d",&d1,&d2,context); return cb((void*)&IID_D3DDEVICE_OpenGL,"WINE Direct3D using OpenGL","direct3d",&d1,&d2,context);
} }
float id_mat[16] = {
1.0, 0.0, 0.0, 0.0,
0.0, 1.0, 0.0, 0.0,
0.0, 0.0, 1.0, 0.0,
0.0, 0.0, 0.0, 1.0
};
int is_OpenGL_dx3(REFCLSID rguid, IDirectDrawSurfaceImpl* surface, IDirect3DDeviceImpl** device) int is_OpenGL_dx3(REFCLSID rguid, IDirectDrawSurfaceImpl* surface, IDirect3DDeviceImpl** device)
{ {
if (!memcmp(&IID_D3DDEVICE_OpenGL,rguid,sizeof(IID_D3DDEVICE_OpenGL))) { if (!memcmp(&IID_D3DDEVICE_OpenGL,rguid,sizeof(IID_D3DDEVICE_OpenGL))) {
@ -908,6 +919,8 @@ int is_OpenGL_dx3(REFCLSID rguid, IDirectDrawSurfaceImpl* surface, IDirect3DDevi
glClearColor(0.0, 0.0, 0.0, 0.0); glClearColor(0.0, 0.0, 0.0, 0.0);
glColor3f(1.0, 1.0, 1.0); glColor3f(1.0, 1.0, 1.0);
fill_device_capabilities((IDirectDrawImpl *) surface->s.ddraw);
return 1; return 1;
} }

View File

@ -216,22 +216,31 @@ static HRESULT WINAPI IDirect3DMaterialImpl_Initialize(LPDIRECT3DMATERIAL iface,
/******************************************************************************* /*******************************************************************************
* IDirect3DMaterial VTable * IDirect3DMaterial VTable
*/ */
#if !defined(__STRICT_ANSI__) && defined(__GNUC__)
# define XCAST(fun) (typeof(material_vtable.fn##fun))
#else
# define XCAST(fun) (void*)
#endif
static ICOM_VTABLE(IDirect3DMaterial) material_vtable = static ICOM_VTABLE(IDirect3DMaterial) material_vtable =
{ {
ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
/*** IUnknown methods ***/ /*** IUnknown methods ***/
IDirect3DMaterial2Impl_QueryInterface, XCAST(QueryInterface)IDirect3DMaterial2Impl_QueryInterface,
IDirect3DMaterial2Impl_AddRef, XCAST(AddRef)IDirect3DMaterial2Impl_AddRef,
IDirect3DMaterial2Impl_Release, XCAST(Release)IDirect3DMaterial2Impl_Release,
/*** IDirect3DMaterial methods ***/ /*** IDirect3DMaterial methods ***/
IDirect3DMaterialImpl_Initialize, IDirect3DMaterialImpl_Initialize,
IDirect3DMaterial2Impl_SetMaterial, XCAST(SetMaterial)IDirect3DMaterial2Impl_SetMaterial,
IDirect3DMaterial2Impl_GetMaterial, XCAST(GetMaterial)IDirect3DMaterial2Impl_GetMaterial,
IDirect3DMaterial2Impl_GetHandle, XCAST(GetHandle)IDirect3DMaterial2Impl_GetHandle,
IDirect3DMaterialImpl_Reserve, IDirect3DMaterialImpl_Reserve,
IDirect3DMaterialImpl_Unreserve IDirect3DMaterialImpl_Unreserve
}; };
#if !defined(__STRICT_ANSI__) && defined(__GNUC__)
#undef XCAST
#endif
/******************************************************************************* /*******************************************************************************
* IDirect3DMaterial2 VTable * IDirect3DMaterial2 VTable

View File

@ -94,8 +94,8 @@ DEFAULT_DEBUG_CHANNEL(ddraw)
#define SNOOP_5551() #define SNOOP_5551()
#endif #endif
static ICOM_VTABLE(IDirect3DTexture2) texture2_vtable; extern ICOM_VTABLE(IDirect3DTexture2) mesa_texture2_vtable;
static ICOM_VTABLE(IDirect3DTexture) texture_vtable; extern ICOM_VTABLE(IDirect3DTexture) mesa_texture_vtable;
/******************************************************************************* /*******************************************************************************
* Texture2 Creation functions * Texture2 Creation functions
@ -106,8 +106,10 @@ LPDIRECT3DTEXTURE2 d3dtexture2_create(IDirectDrawSurface4Impl* surf)
tex = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(IDirect3DTexture2Impl)); tex = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(IDirect3DTexture2Impl));
tex->ref = 1; tex->ref = 1;
ICOM_VTBL(tex) = &texture2_vtable; ICOM_VTBL(tex) = &mesa_texture2_vtable;
tex->surface = surf; tex->surface = surf;
tex->private = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(mesa_d3dt_private));
return (LPDIRECT3DTEXTURE2)tex; return (LPDIRECT3DTEXTURE2)tex;
} }
@ -121,8 +123,10 @@ LPDIRECT3DTEXTURE d3dtexture_create(IDirectDrawSurface4Impl* surf)
tex = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(IDirect3DTexture2Impl)); tex = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(IDirect3DTexture2Impl));
tex->ref = 1; tex->ref = 1;
ICOM_VTBL(tex) = (ICOM_VTABLE(IDirect3DTexture2)*)&texture_vtable; ICOM_VTBL(tex) = (ICOM_VTABLE(IDirect3DTexture2)*)&mesa_texture_vtable;
tex->surface = surf; tex->surface = surf;
tex->private = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(mesa_d3dt_private));
return (LPDIRECT3DTEXTURE)tex; return (LPDIRECT3DTEXTURE)tex;
} }
@ -354,8 +358,11 @@ HRESULT WINAPI IDirect3DTexture2Impl_Load(
D3DTPRIVATE(This); D3DTPRIVATE(This);
IDirect3DTexture2Impl* ilpD3DTexture2=(IDirect3DTexture2Impl*)lpD3DTexture2; IDirect3DTexture2Impl* ilpD3DTexture2=(IDirect3DTexture2Impl*)lpD3DTexture2;
DDSURFACEDESC *src_d, *dst_d; DDSURFACEDESC *src_d, *dst_d;
static void (*ptr_ColorTableEXT) (GLenum target, GLenum internalformat,
GLsizei width, GLenum format, GLenum type, const GLvoid *table) = NULL;
static BOOL color_table_queried = FALSE;
TRACE("(%p)->(%p)\n", This, ilpD3DTexture2); TRACE("(%p)->(%p)\n", This, ilpD3DTexture2);
TRACE("Copied surface %p to surface %p\n", ilpD3DTexture2->surface, This->surface); TRACE("Copied surface %p to surface %p\n", ilpD3DTexture2->surface, This->surface);
/* Suppress the ALLOCONLOAD flag */ /* Suppress the ALLOCONLOAD flag */
@ -403,6 +410,11 @@ HRESULT WINAPI IDirect3DTexture2Impl_Load(
IDirectDrawPaletteImpl* pal = This->surface->s.palette; IDirectDrawPaletteImpl* pal = This->surface->s.palette;
BYTE table[256][4]; BYTE table[256][4];
int i; int i;
if (color_table_queried == FALSE) {
ptr_ColorTableEXT =
((Mesa_DeviceCapabilities *) ((x11_dd_private *) This->surface->s.ddraw->private)->device_capabilities)->ptr_ColorTableEXT;
}
if (pal == NULL) { if (pal == NULL) {
ERR("Palettized texture Loading with a NULL palette !\n"); ERR("Palettized texture Loading with a NULL palette !\n");
@ -426,24 +438,47 @@ HRESULT WINAPI IDirect3DTexture2Impl_Load(
/* Texture snooping */ /* Texture snooping */
SNOOP_PALETTED(); SNOOP_PALETTED();
#if defined(HAVE_GL_COLOR_TABLE) && defined(HAVE_GL_PALETTED_TEXTURE) if (ptr_ColorTableEXT != NULL) {
/* use Paletted Texture Extension */ /* use Paletted Texture Extension */
glColorTableEXT(GL_TEXTURE_2D, /* target */ ptr_ColorTableEXT(GL_TEXTURE_2D, /* target */
GL_RGBA, /* internal format */ GL_RGBA, /* internal format */
256, /* table size */ 256, /* table size */
GL_RGBA, /* table format */ GL_RGBA, /* table format */
GL_UNSIGNED_BYTE, /* table type */ GL_UNSIGNED_BYTE, /* table type */
table); /* the color table */ table); /* the color table */
glTexImage2D(GL_TEXTURE_2D, /* target */ glTexImage2D(GL_TEXTURE_2D, /* target */
0, /* level */ 0, /* level */
GL_COLOR_INDEX8_EXT, /* internal format */ GL_COLOR_INDEX8_EXT, /* internal format */
src_d->dwWidth, src_d->dwHeight, /* width, height */ src_d->dwWidth, src_d->dwHeight, /* width, height */
0, /* border */ 0, /* border */
GL_COLOR_INDEX, /* texture format */ GL_COLOR_INDEX, /* texture format */
GL_UNSIGNED_BYTE, /* texture type */ GL_UNSIGNED_BYTE, /* texture type */
src_d->u1.lpSurface); /* the texture */ src_d->u1.lpSurface); /* the texture */
#endif } else {
DWORD *surface = (DWORD *) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, src_d->dwWidth * src_d->dwHeight * sizeof(DWORD));
DWORD i;
BYTE *src = (BYTE *) src_d->u1.lpSurface, *dst = (BYTE *) surface;
for (i = 0; i < src_d->dwHeight * src_d->dwWidth; i++) {
BYTE color = *src++;
*dst++ = table[color][0];
*dst++ = table[color][1];
*dst++ = table[color][2];
*dst++ = table[color][3];
}
glTexImage2D(GL_TEXTURE_2D,
0,
GL_RGBA,
src_d->dwWidth, src_d->dwHeight,
0,
GL_RGBA,
GL_UNSIGNED_BYTE,
surface);
HeapFree(GetProcessHeap(), 0, surface);
}
} else if (src_d->ddpfPixelFormat.dwFlags & DDPF_RGB) { } else if (src_d->ddpfPixelFormat.dwFlags & DDPF_RGB) {
/* ************ /* ************
RGB Textures RGB Textures
@ -551,17 +586,27 @@ ICOM_VTABLE(IDirect3DTexture2) mesa_texture2_vtable =
/******************************************************************************* /*******************************************************************************
* IDirect3DTexture VTable * IDirect3DTexture VTable
*/ */
#if !defined(__STRICT_ANSI__) && defined(__GNUC__)
# define XCAST(fun) (typeof(mesa_texture_vtable.fn##fun))
#else
# define XCAST(fun) (void*)
#endif
ICOM_VTABLE(IDirect3DTexture) mesa_texture_vtable = ICOM_VTABLE(IDirect3DTexture) mesa_texture_vtable =
{ {
ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
/*** IUnknown methods ***/ /*** IUnknown methods ***/
IDirect3DTexture2Impl_QueryInterface, XCAST(QueryInterface)IDirect3DTexture2Impl_QueryInterface,
IDirect3DTexture2Impl_AddRef, XCAST(AddRef)IDirect3DTexture2Impl_AddRef,
IDirect3DTexture2Impl_Release, XCAST(Release)IDirect3DTexture2Impl_Release,
/*** IDirect3DTexture methods ***/ /*** IDirect3DTexture methods ***/
IDirect3DTextureImpl_Initialize, IDirect3DTextureImpl_Initialize,
IDirect3DTextureImpl_GetHandle, IDirect3DTextureImpl_GetHandle,
IDirect3DTexture2Impl_PaletteChanged, XCAST(PaletteChanged)IDirect3DTexture2Impl_PaletteChanged,
IDirect3DTexture2Impl_Load, XCAST(Load)IDirect3DTexture2Impl_Load,
IDirect3DTextureImpl_Unload IDirect3DTextureImpl_Unload
}; };
#if !defined(__STRICT_ANSI__) && defined(__GNUC__)
#undef XCAST
#endif

View File

@ -384,6 +384,7 @@ extern int _common_depth_to_pixelformat(DWORD depth,LPDIRECTDRAW ddraw);
extern HRESULT create_direct3d(LPVOID *obj,IDirectDraw2Impl*); extern HRESULT create_direct3d(LPVOID *obj,IDirectDraw2Impl*);
extern HRESULT create_direct3d2(LPVOID *obj,IDirectDraw2Impl*); extern HRESULT create_direct3d2(LPVOID *obj,IDirectDraw2Impl*);
extern HRESULT create_direct3d3(LPVOID *obj,IDirectDraw2Impl*);
/****************************************************************************** /******************************************************************************
* Debugging / Flags output functions * Debugging / Flags output functions

View File

@ -165,7 +165,7 @@ DGA_Create( LPDIRECTDRAW *lplpDD ) {
/* just assume the default depth is the DGA depth too */ /* just assume the default depth is the DGA depth too */
depth = DefaultDepthOfScreen(X11DRV_GetXScreen()); depth = DefaultDepthOfScreen(X11DRV_GetXScreen());
_common_depth_to_pixelformat(depth, ddraw); _common_depth_to_pixelformat(depth, (IDirectDraw*) ddraw);
#ifdef RESTORE_SIGNALS #ifdef RESTORE_SIGNALS
SIGNAL_Init(); SIGNAL_Init();

View File

@ -317,35 +317,45 @@ static HRESULT WINAPI MESA_IDirect3D3Impl_EvictManagedTextures(
} }
#if !defined(__STRICT_ANSI__) && defined(__GNUC__)
# define XCAST(fun) (typeof(mesa_d3d3vt.fn##fun))
#else
# define XCAST(fun) (void*)
#endif
ICOM_VTABLE(IDirect3D3) mesa_d3d3vt = ICOM_VTABLE(IDirect3D3) mesa_d3d3vt =
{ {
ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
MESA_IDirect3D2Impl_QueryInterface, XCAST(QueryInterface)MESA_IDirect3D2Impl_QueryInterface,
IDirect3D2Impl_AddRef, XCAST(AddRef)IDirect3D2Impl_AddRef,
MESA_IDirect3D2Impl_Release, XCAST(Release)MESA_IDirect3D2Impl_Release,
MESA_IDirect3D2Impl_EnumDevices, XCAST(EnumDevices)MESA_IDirect3D2Impl_EnumDevices,
MESA_IDirect3D2Impl_CreateLight, XCAST(CreateLight)MESA_IDirect3D2Impl_CreateLight,
MESA_IDirect3D2Impl_CreateMaterial, XCAST(CreateMaterial)MESA_IDirect3D2Impl_CreateMaterial,
MESA_IDirect3D2Impl_CreateViewport, XCAST(CreateViewport)MESA_IDirect3D2Impl_CreateViewport,
MESA_IDirect3D2Impl_FindDevice, XCAST(FindDevice)MESA_IDirect3D2Impl_FindDevice,
MESA_IDirect3D2Impl_CreateDevice, XCAST(CreateDevice)MESA_IDirect3D2Impl_CreateDevice,
MESA_IDirect3D3Impl_CreateVertexBuffer, XCAST(CreateVertexBuffer)MESA_IDirect3D3Impl_CreateVertexBuffer,
MESA_IDirect3D3Impl_EnumZBufferFormats, XCAST(EnumZBufferFormats)MESA_IDirect3D3Impl_EnumZBufferFormats,
MESA_IDirect3D3Impl_EvictManagedTextures XCAST(EvictManagedTextures)MESA_IDirect3D3Impl_EvictManagedTextures
}; };
#if !defined(__STRICT_ANSI__) && defined(__GNUC__)
#undef XCAST
#endif
HRESULT create_direct3d(LPVOID *obj,IDirectDraw2Impl* ddraw) { HRESULT create_direct3d(LPVOID *obj,IDirectDraw2Impl* ddraw) {
IDirect3DImpl* d3d; IDirect3DImpl* d3d;
d3d = HeapAlloc(GetProcessHeap(),0,sizeof(*d3d)); d3d = HeapAlloc(GetProcessHeap(),0,sizeof(*d3d));
d3d->ref = 1; d3d->ref = 1;
d3d->ddraw = ddraw; d3d->ddraw = (IDirectDrawImpl *) ddraw;
d3d->private = NULL; /* unused for now */ d3d->private = NULL; /* unused for now */
IDirectDraw_AddRef((LPDIRECTDRAW)ddraw); IDirectDraw_AddRef((LPDIRECTDRAW)ddraw);
ICOM_VTBL(d3d) = &mesa_d3dvt; ICOM_VTBL(d3d) = &mesa_d3dvt;
*obj = (LPUNKNOWN)d3d; *obj = (LPUNKNOWN)d3d;
TRACE(" Created IDirect3D interface (%p)\n", *obj); TRACE(" Created IDirect3D interface (%p)\n", *obj);
return S_OK; return S_OK;
} }
@ -354,12 +364,13 @@ HRESULT create_direct3d2(LPVOID *obj,IDirectDraw2Impl* ddraw) {
d3d = HeapAlloc(GetProcessHeap(),0,sizeof(*d3d)); d3d = HeapAlloc(GetProcessHeap(),0,sizeof(*d3d));
d3d->ref = 1; d3d->ref = 1;
d3d->ddraw = ddraw; d3d->ddraw = (IDirectDrawImpl *) ddraw;
d3d->private = NULL; /* unused for now */ d3d->private = NULL; /* unused for now */
IDirectDraw_AddRef((LPDIRECTDRAW)ddraw); IDirectDraw_AddRef((LPDIRECTDRAW)ddraw);
ICOM_VTBL(d3d) = &mesa_d3d2vt; ICOM_VTBL(d3d) = &mesa_d3d2vt;
*obj = (LPUNKNOWN)d3d; *obj = (LPUNKNOWN)d3d;
TRACE(" Creating IDirect3D2 interface (%p)\n", *obj); TRACE(" Creating IDirect3D2 interface (%p)\n", *obj);
return S_OK; return S_OK;
} }
@ -368,7 +379,7 @@ HRESULT create_direct3d3(LPVOID *obj,IDirectDraw2Impl* ddraw) {
d3d = HeapAlloc(GetProcessHeap(),0,sizeof(*d3d)); d3d = HeapAlloc(GetProcessHeap(),0,sizeof(*d3d));
d3d->ref = 1; d3d->ref = 1;
d3d->ddraw = ddraw; d3d->ddraw = (IDirectDrawImpl *) ddraw;
d3d->private = NULL; /* unused for now */ d3d->private = NULL; /* unused for now */
IDirectDraw_AddRef((LPDIRECTDRAW)ddraw); IDirectDraw_AddRef((LPDIRECTDRAW)ddraw);
@ -376,7 +387,7 @@ HRESULT create_direct3d3(LPVOID *obj,IDirectDraw2Impl* ddraw) {
*obj = (LPUNKNOWN)d3d; *obj = (LPUNKNOWN)d3d;
TRACE(" Creating IDirect3D3 interface (%p)\n", *obj); TRACE(" Creating IDirect3D3 interface (%p)\n", *obj);
return S_OK; return S_OK;
} }

View File

@ -17,6 +17,7 @@
#include "debugtools.h" #include "debugtools.h"
#include "x11_private.h" #include "x11_private.h"
#include "bitmap.h" #include "bitmap.h"
#include "win.h"
#ifdef HAVE_OPENGL #ifdef HAVE_OPENGL
/* for d3d texture stuff */ /* for d3d texture stuff */
@ -133,12 +134,66 @@ HRESULT WINAPI Xlib_IDirectDrawSurface4Impl_Lock(
} }
#endif #endif
/* If part of a visible 'clipped' surface, copy what is seen on the
screen to the surface */
if ((dspriv->image && VISIBLE(This)) &&
(This->s.lpClipper)) {
HWND hWnd = ((IDirectDrawClipperImpl *) This->s.lpClipper)->hWnd;
WND *wndPtr = WIN_FindWndPtr(hWnd);
Drawable drawable = X11DRV_WND_GetXWindow(wndPtr);
int width = wndPtr->rectClient.right - wndPtr->rectClient.left;
int height = wndPtr->rectClient.bottom - wndPtr->rectClient.top;
/* Now, get the source / destination coordinates */
int dest_x = wndPtr->rectClient.left;
int dest_y = wndPtr->rectClient.top;
XGetSubImage(display, drawable, 0, 0, width, height, 0xFFFFFFFF,
ZPixmap, dspriv->image, dest_x, dest_y);
WIN_ReleaseWndPtr(wndPtr);
}
return DD_OK; return DD_OK;
} }
static void Xlib_copy_surface_on_screen(IDirectDrawSurface4Impl* This) { static void Xlib_copy_surface_on_screen(IDirectDrawSurface4Impl* This) {
DSPRIVATE(This); DSPRIVATE(This);
DDPRIVATE(This->s.ddraw); DDPRIVATE(This->s.ddraw);
Drawable drawable = ddpriv->drawable;
POINT adjust[2] = {{0, 0}, {0, 0}};
SIZE imgsiz;
/* Get XImage size */
imgsiz.cx = dspriv->image->width;
imgsiz.cy = dspriv->image->height;
if (This->s.lpClipper) {
HWND hWnd = ((IDirectDrawClipperImpl *) This->s.lpClipper)->hWnd;
SIZE csiz;
WND *wndPtr = WIN_FindWndPtr(hWnd);
drawable = X11DRV_WND_GetXWindow(wndPtr);
MapWindowPoints(hWnd, 0, adjust, 2);
imgsiz.cx -= adjust[0].x;
imgsiz.cy -= adjust[0].y;
/* (note: the rectWindow here should be the X window's interior rect, in
* case anyone thinks otherwise while rewriting managed mode) */
adjust[1].x -= wndPtr->rectWindow.left;
adjust[1].y -= wndPtr->rectWindow.top;
csiz.cx = wndPtr->rectClient.right - wndPtr->rectClient.left;
csiz.cy = wndPtr->rectClient.bottom - wndPtr->rectClient.top;
if (csiz.cx < imgsiz.cx) imgsiz.cx = csiz.cx;
if (csiz.cy < imgsiz.cy) imgsiz.cy = csiz.cy;
TRACE("adjust: hwnd=%08x, surface %ldx%ld, drawable %ldx%ld\n", hWnd,
adjust[0].x, adjust[0].y,
adjust[1].x,adjust[1].y);
WIN_ReleaseWndPtr(wndPtr);
}
if (This->s.ddraw->d.pixel_convert != NULL) if (This->s.ddraw->d.pixel_convert != NULL)
This->s.ddraw->d.pixel_convert(This->s.surface_desc.u1.lpSurface, This->s.ddraw->d.pixel_convert(This->s.surface_desc.u1.lpSurface,
dspriv->image->data, dspriv->image->data,
@ -160,27 +215,24 @@ static void Xlib_copy_surface_on_screen(IDirectDrawSurface4Impl* This) {
* surface locking, where threads have concurrent access) */ * surface locking, where threads have concurrent access) */
X11DRV_EVENT_PrepareShmCompletion( ddpriv->drawable ); X11DRV_EVENT_PrepareShmCompletion( ddpriv->drawable );
TSXShmPutImage(display, TSXShmPutImage(display,
ddpriv->drawable, drawable,
DefaultGCOfScreen(X11DRV_GetXScreen()), DefaultGCOfScreen(X11DRV_GetXScreen()),
dspriv->image, dspriv->image,
0, 0, 0, 0, adjust[0].x, adjust[0].y, adjust[1].x, adjust[1].y,
dspriv->image->width, imgsiz.cx, imgsiz.cy,
dspriv->image->height, True
True );
);
/* make sure the image is transferred ASAP */ /* make sure the image is transferred ASAP */
TSXFlush(display); TSXFlush(display);
} else } else
#endif #endif
TSXPutImage( TSXPutImage(display,
display, drawable,
ddpriv->drawable, DefaultGCOfScreen(X11DRV_GetXScreen()),
DefaultGCOfScreen(X11DRV_GetXScreen()), dspriv->image,
dspriv->image, adjust[0].x, adjust[0].y, adjust[1].x, adjust[1].y,
0, 0, 0, 0, imgsiz.cx, imgsiz.cy
dspriv->image->width, );
dspriv->image->height
);
} }
HRESULT WINAPI Xlib_IDirectDrawSurface4Impl_Unlock( HRESULT WINAPI Xlib_IDirectDrawSurface4Impl_Unlock(
@ -237,20 +289,28 @@ HRESULT WINAPI Xlib_IDirectDrawSurface4Impl_Flip(
dspriv->image = fspriv->image; dspriv->image = fspriv->image;
fspriv->image = image; fspriv->image = image;
#ifdef HAVE_LIBXXSHM if (dspriv->opengl_flip) {
if (ddpriv->xshm_active) { #ifdef HAVE_OPENGL
/* ENTER_GL();
int compl = InterlockedExchange( &(ddpriv->xshm_compl), 0 ); glXSwapBuffers(display, ddpriv->drawable);
if (compl) X11DRV_EVENT_WaitShmCompletion( compl ); LEAVE_GL();
*/
X11DRV_EVENT_WaitShmCompletions( ddpriv->drawable );
}
#endif #endif
Xlib_copy_surface_on_screen(This); } else {
if (iflipto->s.palette) { #ifdef HAVE_LIBXXSHM
if (ddpriv->xshm_active) {
/*
int compl = InterlockedExchange( &(ddpriv->xshm_compl), 0 );
if (compl) X11DRV_EVENT_WaitShmCompletion( compl );
*/
X11DRV_EVENT_WaitShmCompletions( ddpriv->drawable );
}
#endif
Xlib_copy_surface_on_screen(This);
if (iflipto->s.palette) {
DPPRIVATE(iflipto->s.palette); DPPRIVATE(iflipto->s.palette);
if (dppriv->cm) if (dppriv->cm)
TSXSetWindowColormap(display,ddpriv->drawable,dppriv->cm); TSXSetWindowColormap(display,ddpriv->drawable,dppriv->cm);
}
} }
return DD_OK; return DD_OK;
} }

View File

@ -34,13 +34,14 @@ void set_render_state(D3DRENDERSTATETYPE dwRenderStateType,
case D3DRENDERSTATE_TEXTUREHANDLE: { /* 1 */ case D3DRENDERSTATE_TEXTUREHANDLE: { /* 1 */
IDirect3DTexture2Impl* tex = (IDirect3DTexture2Impl*) dwRenderState; IDirect3DTexture2Impl* tex = (IDirect3DTexture2Impl*) dwRenderState;
D3DTPRIVATE(tex);
if (tex == NULL) { if (tex == NULL) {
glBindTexture(GL_TEXTURE_2D, 0); glBindTexture(GL_TEXTURE_2D, 0);
glDisable(GL_TEXTURE_2D); glDisable(GL_TEXTURE_2D);
TRACE("disabling texturing\n");
} else { } else {
TRACE("setting OpenGL texture handle : %d\n", dtpriv->tex_name); D3DTPRIVATE(tex);
glEnable(GL_TEXTURE_2D); glEnable(GL_TEXTURE_2D);
/* Default parameters */ /* Default parameters */
glBindTexture(GL_TEXTURE_2D, dtpriv->tex_name); glBindTexture(GL_TEXTURE_2D, dtpriv->tex_name);
@ -48,6 +49,7 @@ void set_render_state(D3DRENDERSTATETYPE dwRenderStateType,
stored in the texture */ stored in the texture */
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, rs->mag); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, rs->mag);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, rs->min); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, rs->min);
TRACE("setting OpenGL texture handle : %d\n", dtpriv->tex_name);
} }
} break; } break;

View File

@ -146,6 +146,13 @@ static const GUID WINE_UNUSED IID_D3DDEVICE_OpenGL = {
{ 0x82,0x2d,0xa8,0xd5,0x31,0x87,0xca,0xfa } { 0x82,0x2d,0xa8,0xd5,0x31,0x87,0xca,0xfa }
}; };
/* This structure contains all the function pointers to OpenGL extensions
that are used by Wine */
typedef struct {
void (*ptr_ColorTableEXT) (GLenum target, GLenum internalformat,
GLsizei width, GLenum format, GLenum type, const GLvoid *table);
} Mesa_DeviceCapabilities;
extern ICOM_VTABLE(IDirect3D) mesa_d3dvt; extern ICOM_VTABLE(IDirect3D) mesa_d3dvt;
extern ICOM_VTABLE(IDirect3D2) mesa_d3d2vt; extern ICOM_VTABLE(IDirect3D2) mesa_d3d2vt;
extern ICOM_VTABLE(IDirect3D3) mesa_d3d3vt; extern ICOM_VTABLE(IDirect3D3) mesa_d3d3vt;

View File

@ -35,6 +35,7 @@ typedef struct x11_dd_private {
int xshm_active, xshm_compl; int xshm_active, xshm_compl;
#endif /* defined(HAVE_LIBXXSHM) */ #endif /* defined(HAVE_LIBXXSHM) */
Window drawable; Window drawable;
void *device_capabilities;
} x11_dd_private; } x11_dd_private;
typedef struct x11_dp_private { typedef struct x11_dp_private {
@ -51,6 +52,7 @@ typedef struct x11_ds_private {
XShmSegmentInfo shminfo; XShmSegmentInfo shminfo;
#endif #endif
int *oldDIBmap; int *oldDIBmap;
BOOL opengl_flip;
} x11_ds_private; } x11_ds_private;
#ifdef HAVE_LIBXXSHM #ifdef HAVE_LIBXXSHM

View File

@ -105,11 +105,5 @@
/* Define if <linux/joystick.h> defines the Linux 2.2 joystick API */ /* Define if <linux/joystick.h> defines the Linux 2.2 joystick API */
#undef HAVE_LINUX_22_JOYSTICK_API #undef HAVE_LINUX_22_JOYSTICK_API
/* Define if the OpenGL implementation supports the GL_EXT_color_table extension */
#undef HAVE_GL_COLOR_TABLE
/* Define if the OpenGL implementation supports the GL_EXT_paletted_texture extension */
#undef HAVE_GL_PALETTED_TEXTURE
/* Define if the OpenGL library supports the glXGetProcAddressARB call */ /* Define if the OpenGL library supports the glXGetProcAddressARB call */
#undef HAVE_GLX_GETPROCADDRESS #undef HAVE_GLX_GETPROCADDRESS

View File

@ -137,12 +137,6 @@
/* Define if <linux/joystick.h> defines the Linux 2.2 joystick API */ /* Define if <linux/joystick.h> defines the Linux 2.2 joystick API */
#undef HAVE_LINUX_22_JOYSTICK_API #undef HAVE_LINUX_22_JOYSTICK_API
/* Define if the OpenGL implementation supports the GL_EXT_color_table extension */
#undef HAVE_GL_COLOR_TABLE
/* Define if the OpenGL implementation supports the GL_EXT_paletted_texture extension */
#undef HAVE_GL_PALETTED_TEXTURE
/* Define if the OpenGL library supports the glXGetProcAddressARB call */ /* Define if the OpenGL library supports the glXGetProcAddressARB call */
#undef HAVE_GLX_GETPROCADDRESS #undef HAVE_GLX_GETPROCADDRESS