- 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"
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)
if test $ac_cv_lib_GL_glXGetProcAddressARB = "yes"

View File

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

View File

@ -490,7 +490,7 @@ HRESULT WINAPI IDirect3DDeviceImpl_Execute(
/* Put this as the default context */
/* Execute... */
((IDirect3DExecuteBufferImpl*)lpDirect3DExecuteBuffer)->execute(lpDirect3DExecuteBuffer, iface, (IDirect3DViewport2*)lpDirect3DViewport);
((IDirect3DExecuteBufferImpl*)lpDirect3DExecuteBuffer)->execute(lpDirect3DExecuteBuffer, iface, (IDirect3DViewport*)lpDirect3DViewport);
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 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
*/
@ -108,11 +115,31 @@ static void fill_opengl_caps(D3DDEVICEDESC *d1, D3DDEVICEDESC *d2)
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) {
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);
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
@ -129,17 +156,6 @@ is_OpenGL(
/* OpenGL Device */
(!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)->private = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(mesa_d3dd_private));
odev = (mesa_d3dd_private*)(*device)->private;
@ -159,38 +175,34 @@ is_OpenGL(
surface->s.surface_desc.dwWidth * surface->s.surface_desc.dwHeight * 4);
#else
/* First get the correct visual */
/* if (surface->s.backbuffer == NULL)
attributeList[3] = None; */
ENTER_GL();
xvis = glXChooseVisual(display,
DefaultScreen(display),
attributeList);
if (xvis == NULL)
ERR("No visual found !\n");
else
TRACE("Visual found\n");
/* Create the context */
odev->ctx = glXCreateContext(display,
xvis,
NULL,
GL_TRUE);
{
XVisualInfo *vis;
int num;
XVisualInfo template;
template.visualid = XVisualIDFromVisual(visual);
vis = XGetVisualInfo(display, VisualIDMask, &template, &num);
odev->ctx = glXCreateContext(display, vis,
NULL, GL_TRUE);
}
if (odev->ctx == NULL)
ERR("Error in context creation !\n");
else
TRACE("Context created (%p)\n", odev->ctx);
#if 0 /* not functional currently */
/* 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;
struct _surface_chain *chain = surface->s.chain;
for (i=0;i<chain->nrofsurfaces;i++)
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
odev->rs.src = GL_ONE;
@ -199,6 +211,11 @@ is_OpenGL(
odev->rs.min = GL_NEAREST;
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->view_mat , id_mat, 16 * sizeof(float));
memcpy(odev->proj_mat , id_mat, 16 * sizeof(float));
@ -210,6 +227,9 @@ is_OpenGL(
glClearColor(0.0, 0.0, 0.0, 0.0);
glColor3f(1.0, 1.0, 1.0);
LEAVE_GL();
fill_device_capabilities(d3d->ddraw);
TRACE("OpenGL device created \n");
return 1;
}
@ -330,7 +350,6 @@ static HRESULT enum_texture_format_OpenGL(LPD3DENUMTEXTUREFORMATSCALLBACK cb,
return DD_OK;
#endif
#if defined(HAVE_GL_COLOR_TABLE) && defined(HAVE_GL_PALETTED_TEXTURE)
TRACE("Enumerating Paletted (8)\n");
pformat->dwFlags = DDPF_PALETTEINDEXED8;
pformat->u.dwRGBBitCount = 8;
@ -340,7 +359,6 @@ static HRESULT enum_texture_format_OpenGL(LPD3DENUMTEXTUREFORMATSCALLBACK cb,
pformat->u4.dwRGBAlphaBitMask = 0x00000000;
if (cb(&sdesc, context) == 0)
return DD_OK;
#endif
TRACE("End of enumeration\n");
@ -529,21 +547,21 @@ static HRESULT WINAPI MESA_IDirect3DDevice2Impl_SetTransform(
case D3DTRANSFORMSTATE_WORLD: {
conv_mat(lpmatrix, odev->world_mat);
glMatrixMode(GL_MODELVIEW);
glLoadMatrixf((float *) &(odev->world_mat));
glLoadMatrixf((float *) odev->world_mat);
} break;
case D3DTRANSFORMSTATE_VIEW: {
conv_mat(lpmatrix, odev->view_mat);
glMatrixMode(GL_PROJECTION);
glLoadMatrixf((float *) &(odev->proj_mat));
glMultMatrixf((float *) &(odev->view_mat));
glLoadMatrixf((float *) odev->proj_mat);
glMultMatrixf((float *) odev->view_mat);
} break;
case D3DTRANSFORMSTATE_PROJECTION: {
conv_mat(lpmatrix, odev->proj_mat);
glMatrixMode(GL_PROJECTION);
glLoadMatrixf((float *) &(odev->proj_mat));
glMultMatrixf((float *) &(odev->view_mat));
glLoadMatrixf((float *) odev->proj_mat);
glMultMatrixf((float *) odev->view_mat);
} break;
default:
@ -559,10 +577,10 @@ static HRESULT WINAPI MESA_IDirect3DDevice2Impl_SetTransform(
if (odev->vt == D3DVT_TLVERTEX) { \
/* Need to put the correct transformation again */ \
glMatrixMode(GL_MODELVIEW); \
glLoadMatrixf((float *) &(odev->world_mat)); \
glLoadMatrixf((float *) odev->world_mat); \
glMatrixMode(GL_PROJECTION); \
glLoadMatrixf((float *) &(odev->proj_mat)); \
glMultMatrixf((float *) &(odev->view_mat)); \
glLoadMatrixf((float *) odev->proj_mat); \
glMultMatrixf((float *) odev->view_mat); \
} \
\
switch (d3dv) { \
@ -820,20 +838,13 @@ ICOM_VTABLE(IDirect3DDevice2) OpenGL_vtable =
int d3d_OpenGL_dx3(LPD3DENUMDEVICESCALLBACK cb, LPVOID context) {
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);
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)
{
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);
glColor3f(1.0, 1.0, 1.0);
fill_device_capabilities((IDirectDrawImpl *) surface->s.ddraw);
return 1;
}

View File

@ -216,22 +216,31 @@ static HRESULT WINAPI IDirect3DMaterialImpl_Initialize(LPDIRECT3DMATERIAL iface,
/*******************************************************************************
* 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 =
{
ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
/*** IUnknown methods ***/
IDirect3DMaterial2Impl_QueryInterface,
IDirect3DMaterial2Impl_AddRef,
IDirect3DMaterial2Impl_Release,
XCAST(QueryInterface)IDirect3DMaterial2Impl_QueryInterface,
XCAST(AddRef)IDirect3DMaterial2Impl_AddRef,
XCAST(Release)IDirect3DMaterial2Impl_Release,
/*** IDirect3DMaterial methods ***/
IDirect3DMaterialImpl_Initialize,
IDirect3DMaterial2Impl_SetMaterial,
IDirect3DMaterial2Impl_GetMaterial,
IDirect3DMaterial2Impl_GetHandle,
XCAST(SetMaterial)IDirect3DMaterial2Impl_SetMaterial,
XCAST(GetMaterial)IDirect3DMaterial2Impl_GetMaterial,
XCAST(GetHandle)IDirect3DMaterial2Impl_GetHandle,
IDirect3DMaterialImpl_Reserve,
IDirect3DMaterialImpl_Unreserve
};
#if !defined(__STRICT_ANSI__) && defined(__GNUC__)
#undef XCAST
#endif
/*******************************************************************************
* IDirect3DMaterial2 VTable

View File

@ -94,8 +94,8 @@ DEFAULT_DEBUG_CHANNEL(ddraw)
#define SNOOP_5551()
#endif
static ICOM_VTABLE(IDirect3DTexture2) texture2_vtable;
static ICOM_VTABLE(IDirect3DTexture) texture_vtable;
extern ICOM_VTABLE(IDirect3DTexture2) mesa_texture2_vtable;
extern ICOM_VTABLE(IDirect3DTexture) mesa_texture_vtable;
/*******************************************************************************
* Texture2 Creation functions
@ -106,9 +106,11 @@ LPDIRECT3DTEXTURE2 d3dtexture2_create(IDirectDrawSurface4Impl* surf)
tex = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(IDirect3DTexture2Impl));
tex->ref = 1;
ICOM_VTBL(tex) = &texture2_vtable;
ICOM_VTBL(tex) = &mesa_texture2_vtable;
tex->surface = surf;
tex->private = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(mesa_d3dt_private));
return (LPDIRECT3DTEXTURE2)tex;
}
@ -121,9 +123,11 @@ LPDIRECT3DTEXTURE d3dtexture_create(IDirectDrawSurface4Impl* surf)
tex = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(IDirect3DTexture2Impl));
tex->ref = 1;
ICOM_VTBL(tex) = (ICOM_VTABLE(IDirect3DTexture2)*)&texture_vtable;
ICOM_VTBL(tex) = (ICOM_VTABLE(IDirect3DTexture2)*)&mesa_texture_vtable;
tex->surface = surf;
tex->private = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(mesa_d3dt_private));
return (LPDIRECT3DTEXTURE)tex;
}
@ -354,8 +358,11 @@ HRESULT WINAPI IDirect3DTexture2Impl_Load(
D3DTPRIVATE(This);
IDirect3DTexture2Impl* ilpD3DTexture2=(IDirect3DTexture2Impl*)lpD3DTexture2;
DDSURFACEDESC *src_d, *dst_d;
TRACE("(%p)->(%p)\n", This, ilpD3DTexture2);
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("Copied surface %p to surface %p\n", ilpD3DTexture2->surface, This->surface);
/* Suppress the ALLOCONLOAD flag */
@ -404,6 +411,11 @@ HRESULT WINAPI IDirect3DTexture2Impl_Load(
BYTE table[256][4];
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) {
ERR("Palettized texture Loading with a NULL palette !\n");
LEAVE_GL();
@ -426,9 +438,9 @@ HRESULT WINAPI IDirect3DTexture2Impl_Load(
/* Texture snooping */
SNOOP_PALETTED();
#if defined(HAVE_GL_COLOR_TABLE) && defined(HAVE_GL_PALETTED_TEXTURE)
if (ptr_ColorTableEXT != NULL) {
/* use Paletted Texture Extension */
glColorTableEXT(GL_TEXTURE_2D, /* target */
ptr_ColorTableEXT(GL_TEXTURE_2D, /* target */
GL_RGBA, /* internal format */
256, /* table size */
GL_RGBA, /* table format */
@ -443,7 +455,30 @@ HRESULT WINAPI IDirect3DTexture2Impl_Load(
GL_COLOR_INDEX, /* texture format */
GL_UNSIGNED_BYTE, /* texture type */
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) {
/* ************
RGB Textures
@ -551,17 +586,27 @@ ICOM_VTABLE(IDirect3DTexture2) mesa_texture2_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_MSVTABLE_COMPAT_DummyRTTIVALUE
/*** IUnknown methods ***/
IDirect3DTexture2Impl_QueryInterface,
IDirect3DTexture2Impl_AddRef,
IDirect3DTexture2Impl_Release,
XCAST(QueryInterface)IDirect3DTexture2Impl_QueryInterface,
XCAST(AddRef)IDirect3DTexture2Impl_AddRef,
XCAST(Release)IDirect3DTexture2Impl_Release,
/*** IDirect3DTexture methods ***/
IDirect3DTextureImpl_Initialize,
IDirect3DTextureImpl_GetHandle,
IDirect3DTexture2Impl_PaletteChanged,
IDirect3DTexture2Impl_Load,
XCAST(PaletteChanged)IDirect3DTexture2Impl_PaletteChanged,
XCAST(Load)IDirect3DTexture2Impl_Load,
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_direct3d2(LPVOID *obj,IDirectDraw2Impl*);
extern HRESULT create_direct3d3(LPVOID *obj,IDirectDraw2Impl*);
/******************************************************************************
* Debugging / Flags output functions

View File

@ -165,7 +165,7 @@ DGA_Create( LPDIRECTDRAW *lplpDD ) {
/* just assume the default depth is the DGA depth too */
depth = DefaultDepthOfScreen(X11DRV_GetXScreen());
_common_depth_to_pixelformat(depth, ddraw);
_common_depth_to_pixelformat(depth, (IDirectDraw*) ddraw);
#ifdef RESTORE_SIGNALS
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_MSVTABLE_COMPAT_DummyRTTIVALUE
MESA_IDirect3D2Impl_QueryInterface,
IDirect3D2Impl_AddRef,
MESA_IDirect3D2Impl_Release,
MESA_IDirect3D2Impl_EnumDevices,
MESA_IDirect3D2Impl_CreateLight,
MESA_IDirect3D2Impl_CreateMaterial,
MESA_IDirect3D2Impl_CreateViewport,
MESA_IDirect3D2Impl_FindDevice,
MESA_IDirect3D2Impl_CreateDevice,
MESA_IDirect3D3Impl_CreateVertexBuffer,
MESA_IDirect3D3Impl_EnumZBufferFormats,
MESA_IDirect3D3Impl_EvictManagedTextures
XCAST(QueryInterface)MESA_IDirect3D2Impl_QueryInterface,
XCAST(AddRef)IDirect3D2Impl_AddRef,
XCAST(Release)MESA_IDirect3D2Impl_Release,
XCAST(EnumDevices)MESA_IDirect3D2Impl_EnumDevices,
XCAST(CreateLight)MESA_IDirect3D2Impl_CreateLight,
XCAST(CreateMaterial)MESA_IDirect3D2Impl_CreateMaterial,
XCAST(CreateViewport)MESA_IDirect3D2Impl_CreateViewport,
XCAST(FindDevice)MESA_IDirect3D2Impl_FindDevice,
XCAST(CreateDevice)MESA_IDirect3D2Impl_CreateDevice,
XCAST(CreateVertexBuffer)MESA_IDirect3D3Impl_CreateVertexBuffer,
XCAST(EnumZBufferFormats)MESA_IDirect3D3Impl_EnumZBufferFormats,
XCAST(EvictManagedTextures)MESA_IDirect3D3Impl_EvictManagedTextures
};
#if !defined(__STRICT_ANSI__) && defined(__GNUC__)
#undef XCAST
#endif
HRESULT create_direct3d(LPVOID *obj,IDirectDraw2Impl* ddraw) {
IDirect3DImpl* d3d;
d3d = HeapAlloc(GetProcessHeap(),0,sizeof(*d3d));
d3d->ref = 1;
d3d->ddraw = ddraw;
d3d->ddraw = (IDirectDrawImpl *) ddraw;
d3d->private = NULL; /* unused for now */
IDirectDraw_AddRef((LPDIRECTDRAW)ddraw);
ICOM_VTBL(d3d) = &mesa_d3dvt;
*obj = (LPUNKNOWN)d3d;
TRACE(" Created IDirect3D interface (%p)\n", *obj);
return S_OK;
}
@ -354,12 +364,13 @@ HRESULT create_direct3d2(LPVOID *obj,IDirectDraw2Impl* ddraw) {
d3d = HeapAlloc(GetProcessHeap(),0,sizeof(*d3d));
d3d->ref = 1;
d3d->ddraw = ddraw;
d3d->ddraw = (IDirectDrawImpl *) ddraw;
d3d->private = NULL; /* unused for now */
IDirectDraw_AddRef((LPDIRECTDRAW)ddraw);
ICOM_VTBL(d3d) = &mesa_d3d2vt;
*obj = (LPUNKNOWN)d3d;
TRACE(" Creating IDirect3D2 interface (%p)\n", *obj);
return S_OK;
}
@ -368,7 +379,7 @@ HRESULT create_direct3d3(LPVOID *obj,IDirectDraw2Impl* ddraw) {
d3d = HeapAlloc(GetProcessHeap(),0,sizeof(*d3d));
d3d->ref = 1;
d3d->ddraw = ddraw;
d3d->ddraw = (IDirectDrawImpl *) ddraw;
d3d->private = NULL; /* unused for now */
IDirectDraw_AddRef((LPDIRECTDRAW)ddraw);

View File

@ -17,6 +17,7 @@
#include "debugtools.h"
#include "x11_private.h"
#include "bitmap.h"
#include "win.h"
#ifdef HAVE_OPENGL
/* for d3d texture stuff */
@ -133,12 +134,66 @@ HRESULT WINAPI Xlib_IDirectDrawSurface4Impl_Lock(
}
#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;
}
static void Xlib_copy_surface_on_screen(IDirectDrawSurface4Impl* This) {
DSPRIVATE(This);
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)
This->s.ddraw->d.pixel_convert(This->s.surface_desc.u1.lpSurface,
dspriv->image->data,
@ -160,26 +215,23 @@ static void Xlib_copy_surface_on_screen(IDirectDrawSurface4Impl* This) {
* surface locking, where threads have concurrent access) */
X11DRV_EVENT_PrepareShmCompletion( ddpriv->drawable );
TSXShmPutImage(display,
ddpriv->drawable,
drawable,
DefaultGCOfScreen(X11DRV_GetXScreen()),
dspriv->image,
0, 0, 0, 0,
dspriv->image->width,
dspriv->image->height,
adjust[0].x, adjust[0].y, adjust[1].x, adjust[1].y,
imgsiz.cx, imgsiz.cy,
True
);
/* make sure the image is transferred ASAP */
TSXFlush(display);
} else
#endif
TSXPutImage(
display,
ddpriv->drawable,
TSXPutImage(display,
drawable,
DefaultGCOfScreen(X11DRV_GetXScreen()),
dspriv->image,
0, 0, 0, 0,
dspriv->image->width,
dspriv->image->height
adjust[0].x, adjust[0].y, adjust[1].x, adjust[1].y,
imgsiz.cx, imgsiz.cy
);
}
@ -237,12 +289,19 @@ HRESULT WINAPI Xlib_IDirectDrawSurface4Impl_Flip(
dspriv->image = fspriv->image;
fspriv->image = image;
if (dspriv->opengl_flip) {
#ifdef HAVE_OPENGL
ENTER_GL();
glXSwapBuffers(display, ddpriv->drawable);
LEAVE_GL();
#endif
} else {
#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
@ -252,6 +311,7 @@ HRESULT WINAPI Xlib_IDirectDrawSurface4Impl_Flip(
if (dppriv->cm)
TSXSetWindowColormap(display,ddpriv->drawable,dppriv->cm);
}
}
return DD_OK;
}

View File

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

View File

@ -146,6 +146,13 @@ static const GUID WINE_UNUSED IID_D3DDEVICE_OpenGL = {
{ 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(IDirect3D2) mesa_d3d2vt;
extern ICOM_VTABLE(IDirect3D3) mesa_d3d3vt;

View File

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

View File

@ -105,11 +105,5 @@
/* Define if <linux/joystick.h> defines the Linux 2.2 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 */
#undef HAVE_GLX_GETPROCADDRESS

View File

@ -137,12 +137,6 @@
/* Define if <linux/joystick.h> defines the Linux 2.2 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 */
#undef HAVE_GLX_GETPROCADDRESS