1999-01-03 18:00:19 +01:00
|
|
|
/* Direct3D Device
|
|
|
|
(c) 1998 Lionel ULMER
|
|
|
|
|
2000-04-09 16:30:50 +02:00
|
|
|
This files contains the MESA implementation of all the D3D devices that
|
|
|
|
Wine supports. */
|
1999-01-03 18:00:19 +01:00
|
|
|
|
1999-02-28 13:27:56 +01:00
|
|
|
#include <string.h>
|
1999-01-03 18:00:19 +01:00
|
|
|
#include "config.h"
|
1999-03-14 17:35:05 +01:00
|
|
|
#include "windef.h"
|
1999-01-03 18:00:19 +01:00
|
|
|
#include "winerror.h"
|
1999-02-02 17:14:23 +01:00
|
|
|
#include "wine/obj_base.h"
|
1999-01-03 18:00:19 +01:00
|
|
|
#include "heap.h"
|
|
|
|
#include "ddraw.h"
|
|
|
|
#include "d3d.h"
|
1999-06-26 21:09:08 +02:00
|
|
|
#include "debugtools.h"
|
1999-01-03 18:00:19 +01:00
|
|
|
|
2000-04-09 16:30:50 +02:00
|
|
|
#include "mesa_private.h"
|
1999-01-03 18:00:19 +01:00
|
|
|
|
1999-04-19 16:56:29 +02:00
|
|
|
DEFAULT_DEBUG_CHANNEL(ddraw)
|
|
|
|
|
2000-04-09 16:30:50 +02:00
|
|
|
ICOM_VTABLE(IDirect3DDevice2) OpenGL_vtable;
|
|
|
|
ICOM_VTABLE(IDirect3DDevice) OpenGL_vtable_dx3;
|
|
|
|
|
1999-01-23 13:32:46 +01:00
|
|
|
/* Define this variable if you have an unpatched Mesa 3.0 (patches are available
|
|
|
|
on Mesa's home page) or version 3.1b.
|
|
|
|
|
1999-05-13 20:53:05 +02:00
|
|
|
Version 3.1b2 should correct this bug */
|
1999-01-23 13:32:46 +01:00
|
|
|
#undef HAVE_BUGGY_MESAGL
|
|
|
|
|
2000-04-09 16:30:50 +02:00
|
|
|
#define D3DDPRIVATE(x) mesa_d3dd_private *odev=((mesa_d3dd_private*)x->private)
|
2000-07-23 15:39:52 +02:00
|
|
|
#define DDPRIVATE(x) x11_dd_private *ddpriv=((x11_dd_private*)(x)->d->private)
|
1999-01-03 18:00:19 +01:00
|
|
|
|
2000-07-23 16:23:31 +02:00
|
|
|
#ifndef HAVE_GLEXT_PROTOTYPES
|
|
|
|
/* This is for non-OpenGL ABI compliant glext.h headers :-) */
|
|
|
|
typedef void (* PFNGLCOLORTABLEEXTPROC) (GLenum target, GLenum internalFormat,
|
|
|
|
GLsizei width, GLenum format, GLenum type,
|
|
|
|
const GLvoid *table);
|
|
|
|
#endif
|
|
|
|
|
2000-07-16 16:40:35 +02:00
|
|
|
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
|
|
|
|
};
|
|
|
|
|
1999-01-03 18:00:19 +01:00
|
|
|
/*******************************************************************************
|
|
|
|
* OpenGL static functions
|
|
|
|
*/
|
1999-03-27 17:56:13 +01:00
|
|
|
static void set_context(IDirect3DDevice2Impl* This) {
|
2000-04-09 16:30:50 +02:00
|
|
|
D3DDPRIVATE(This);
|
|
|
|
DDPRIVATE(This->surface->s.ddraw);
|
1999-01-03 18:00:19 +01:00
|
|
|
|
1999-05-13 20:53:05 +02:00
|
|
|
#ifdef USE_OSMESA
|
2000-04-09 16:30:50 +02:00
|
|
|
OSMesaMakeCurrent(d3ddpriv->ctx, odev->buffer, GL_UNSIGNED_BYTE,
|
1999-03-27 17:56:13 +01:00
|
|
|
This->surface->s.surface_desc.dwWidth,
|
|
|
|
This->surface->s.surface_desc.dwHeight);
|
1999-05-13 20:53:05 +02:00
|
|
|
#else
|
2000-04-09 16:30:50 +02:00
|
|
|
if (glXMakeCurrent(display,ddpriv->drawable, odev->ctx) == False) {
|
|
|
|
ERR("Error in setting current context (context %p drawable %ld)!\n",
|
|
|
|
odev->ctx, ddpriv->drawable);
|
1999-05-13 20:53:05 +02:00
|
|
|
}
|
|
|
|
#endif
|
1999-01-03 18:00:19 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void fill_opengl_primcaps(D3DPRIMCAPS *pc)
|
|
|
|
{
|
|
|
|
pc->dwSize = sizeof(*pc);
|
|
|
|
pc->dwMiscCaps = D3DPMISCCAPS_CONFORMANT | D3DPMISCCAPS_CULLCCW | D3DPMISCCAPS_CULLCW |
|
|
|
|
D3DPMISCCAPS_LINEPATTERNREP | D3DPMISCCAPS_MASKZ;
|
|
|
|
pc->dwRasterCaps = D3DPRASTERCAPS_DITHER | D3DPRASTERCAPS_FOGRANGE | D3DPRASTERCAPS_FOGTABLE |
|
|
|
|
D3DPRASTERCAPS_FOGVERTEX | D3DPRASTERCAPS_STIPPLE | D3DPRASTERCAPS_ZBIAS | D3DPRASTERCAPS_ZTEST;
|
|
|
|
pc->dwZCmpCaps = 0xFFFFFFFF; /* All Z test can be done */
|
|
|
|
pc->dwSrcBlendCaps = 0xFFFFFFFF; /* FIXME: need REAL values */
|
|
|
|
pc->dwDestBlendCaps = 0xFFFFFFFF; /* FIXME: need REAL values */
|
|
|
|
pc->dwAlphaCmpCaps = 0xFFFFFFFF; /* FIXME: need REAL values */
|
|
|
|
pc->dwShadeCaps = 0xFFFFFFFF; /* FIXME: need REAL values */
|
|
|
|
pc->dwTextureCaps = D3DPTEXTURECAPS_ALPHA | D3DPTEXTURECAPS_BORDER | D3DPTEXTURECAPS_PERSPECTIVE |
|
|
|
|
D3DPTEXTURECAPS_POW2 | D3DPTEXTURECAPS_TRANSPARENCY;
|
|
|
|
pc->dwTextureFilterCaps = D3DPTFILTERCAPS_LINEAR | D3DPTFILTERCAPS_LINEARMIPLINEAR | D3DPTFILTERCAPS_LINEARMIPNEAREST |
|
|
|
|
D3DPTFILTERCAPS_MIPLINEAR | D3DPTFILTERCAPS_MIPNEAREST | D3DPTFILTERCAPS_NEAREST;
|
|
|
|
pc->dwTextureBlendCaps = 0xFFFFFFFF; /* FIXME: need REAL values */
|
|
|
|
pc->dwTextureAddressCaps = D3DPTADDRESSCAPS_BORDER | D3DPTADDRESSCAPS_CLAMP | D3DPTADDRESSCAPS_WRAP;
|
|
|
|
pc->dwStippleWidth = 32;
|
|
|
|
pc->dwStippleHeight = 32;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void fill_opengl_caps(D3DDEVICEDESC *d1, D3DDEVICEDESC *d2)
|
|
|
|
{
|
1999-01-23 13:32:46 +01:00
|
|
|
/* GLint maxlight; */
|
1999-01-03 18:00:19 +01:00
|
|
|
|
|
|
|
d1->dwSize = sizeof(*d1);
|
|
|
|
d1->dwFlags = D3DDD_DEVCAPS | D3DDD_BCLIPPING | D3DDD_COLORMODEL | D3DDD_DEVICERENDERBITDEPTH | D3DDD_DEVICEZBUFFERBITDEPTH
|
1999-01-23 13:32:46 +01:00
|
|
|
| D3DDD_LIGHTINGCAPS | D3DDD_LINECAPS | D3DDD_MAXBUFFERSIZE | D3DDD_MAXVERTEXCOUNT | D3DDD_TRANSFORMCAPS | D3DDD_TRICAPS;
|
1999-01-03 18:00:19 +01:00
|
|
|
d1->dcmColorModel = D3DCOLOR_RGB;
|
|
|
|
d1->dwDevCaps = D3DDEVCAPS_CANRENDERAFTERFLIP | D3DDEVCAPS_DRAWPRIMTLVERTEX | D3DDEVCAPS_EXECUTESYSTEMMEMORY |
|
|
|
|
D3DDEVCAPS_EXECUTEVIDEOMEMORY | D3DDEVCAPS_FLOATTLVERTEX | D3DDEVCAPS_TEXTURENONLOCALVIDMEM | D3DDEVCAPS_TEXTURESYSTEMMEMORY |
|
|
|
|
D3DDEVCAPS_TEXTUREVIDEOMEMORY | D3DDEVCAPS_TLVERTEXSYSTEMMEMORY | D3DDEVCAPS_TLVERTEXVIDEOMEMORY;
|
|
|
|
d1->dtcTransformCaps.dwSize = sizeof(D3DTRANSFORMCAPS);
|
|
|
|
d1->dtcTransformCaps.dwCaps = D3DTRANSFORMCAPS_CLIP;
|
|
|
|
d1->bClipping = TRUE;
|
|
|
|
d1->dlcLightingCaps.dwSize = sizeof(D3DLIGHTINGCAPS);
|
|
|
|
d1->dlcLightingCaps.dwCaps = D3DLIGHTCAPS_DIRECTIONAL | D3DLIGHTCAPS_PARALLELPOINT | D3DLIGHTCAPS_POINT | D3DLIGHTCAPS_SPOT;
|
|
|
|
d1->dlcLightingCaps.dwLightingModel = D3DLIGHTINGMODEL_RGB;
|
1999-01-17 17:55:11 +01:00
|
|
|
d1->dlcLightingCaps.dwNumLights = 16; /* glGetIntegerv(GL_MAX_LIGHTS, &maxlight); d1->dlcLightingCaps.dwNumLights = maxlight; */
|
1999-01-03 18:00:19 +01:00
|
|
|
fill_opengl_primcaps(&(d1->dpcLineCaps));
|
|
|
|
fill_opengl_primcaps(&(d1->dpcTriCaps));
|
|
|
|
d1->dwDeviceRenderBitDepth = DDBD_16;
|
|
|
|
d1->dwDeviceZBufferBitDepth = DDBD_16;
|
|
|
|
d1->dwMaxBufferSize = 0;
|
1999-01-23 13:32:46 +01:00
|
|
|
d1->dwMaxVertexCount = 65536;
|
1999-01-03 18:00:19 +01:00
|
|
|
d1->dwMinTextureWidth = 1;
|
|
|
|
d1->dwMinTextureHeight = 1;
|
|
|
|
d1->dwMaxTextureWidth = 256; /* This is for Mesa on top of Glide (in the future :-) ) */
|
|
|
|
d1->dwMaxTextureHeight = 256; /* This is for Mesa on top of Glide (in the future :-) ) */
|
|
|
|
d1->dwMinStippleWidth = 1;
|
|
|
|
d1->dwMinStippleHeight = 1;
|
|
|
|
d1->dwMaxStippleWidth = 32;
|
|
|
|
d1->dwMaxStippleHeight = 32;
|
|
|
|
|
|
|
|
d2->dwSize = sizeof(*d2);
|
|
|
|
d2->dwFlags = 0;
|
|
|
|
}
|
|
|
|
|
2000-07-16 16:40:35 +02:00
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
1999-01-03 18:00:19 +01:00
|
|
|
int d3d_OpenGL(LPD3DENUMDEVICESCALLBACK cb, LPVOID context) {
|
|
|
|
D3DDEVICEDESC d1,d2;
|
2000-07-16 16:40:35 +02:00
|
|
|
TRACE(" Enumerating OpenGL D3D2 device (IID %s).\n", debugstr_guid(&IID_D3DDEVICE2_OpenGL));
|
1999-01-03 18:00:19 +01:00
|
|
|
fill_opengl_caps(&d1, &d2);
|
2000-07-16 16:40:35 +02:00
|
|
|
return cb((void*)&IID_D3DDEVICE2_OpenGL,"WINE Direct3D2 using OpenGL","direct3d",&d1,&d2,context);
|
1999-01-03 18:00:19 +01:00
|
|
|
}
|
|
|
|
|
2000-04-09 16:30:50 +02:00
|
|
|
int
|
|
|
|
is_OpenGL(
|
|
|
|
REFCLSID rguid, IDirectDrawSurfaceImpl* surface,
|
|
|
|
IDirect3DDevice2Impl** device, IDirect3D2Impl* d3d
|
|
|
|
) {
|
|
|
|
mesa_d3dd_private *odev = NULL;
|
|
|
|
|
1999-01-03 18:00:19 +01:00
|
|
|
if (/* Default device */
|
|
|
|
(rguid == NULL) ||
|
|
|
|
/* HAL Device */
|
|
|
|
(!memcmp(&IID_IDirect3DHALDevice,rguid,sizeof(IID_IDirect3DHALDevice))) ||
|
|
|
|
/* OpenGL Device */
|
|
|
|
(!memcmp(&IID_D3DDEVICE2_OpenGL,rguid,sizeof(IID_D3DDEVICE2_OpenGL)))) {
|
|
|
|
|
2000-04-09 16:30:50 +02:00
|
|
|
*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;
|
1999-01-03 18:00:19 +01:00
|
|
|
(*device)->ref = 1;
|
1999-10-31 02:59:23 +01:00
|
|
|
ICOM_VTBL(*device) = &OpenGL_vtable;
|
1999-01-03 18:00:19 +01:00
|
|
|
(*device)->d3d = d3d;
|
|
|
|
(*device)->surface = surface;
|
|
|
|
(*device)->viewport_list = NULL;
|
|
|
|
(*device)->current_viewport = NULL;
|
|
|
|
(*device)->set_context = set_context;
|
|
|
|
|
1999-06-26 21:09:08 +02:00
|
|
|
TRACE("Creating OpenGL device for surface %p\n", surface);
|
1999-01-03 18:00:19 +01:00
|
|
|
/* Create the OpenGL context */
|
1999-05-13 20:53:05 +02:00
|
|
|
#ifdef USE_OSMESA
|
1999-01-03 18:00:19 +01:00
|
|
|
odev->ctx = OSMesaCreateContext(OSMESA_RGBA, NULL);
|
|
|
|
odev->buffer = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,
|
|
|
|
surface->s.surface_desc.dwWidth * surface->s.surface_desc.dwHeight * 4);
|
1999-05-13 20:53:05 +02:00
|
|
|
#else
|
|
|
|
/* First get the correct visual */
|
|
|
|
ENTER_GL();
|
|
|
|
/* Create the context */
|
2000-07-16 16:40:35 +02:00
|
|
|
{
|
|
|
|
XVisualInfo *vis;
|
|
|
|
int num;
|
|
|
|
XVisualInfo template;
|
|
|
|
|
|
|
|
template.visualid = XVisualIDFromVisual(visual);
|
|
|
|
vis = XGetVisualInfo(display, VisualIDMask, &template, &num);
|
|
|
|
|
|
|
|
odev->ctx = glXCreateContext(display, vis,
|
|
|
|
NULL, GL_TRUE);
|
|
|
|
}
|
|
|
|
|
1999-05-13 20:53:05 +02:00
|
|
|
if (odev->ctx == NULL)
|
1999-06-26 21:09:08 +02:00
|
|
|
ERR("Error in context creation !\n");
|
1999-05-13 20:53:05 +02:00
|
|
|
else
|
1999-06-26 21:09:08 +02:00
|
|
|
TRACE("Context created (%p)\n", odev->ctx);
|
1999-05-13 20:53:05 +02:00
|
|
|
|
|
|
|
/* Now override the surface's Flip method (if in double buffering) */
|
2000-07-16 16:40:35 +02:00
|
|
|
((x11_ds_private *) surface->private)->opengl_flip = TRUE;
|
1999-07-03 13:57:29 +02:00
|
|
|
{
|
|
|
|
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)
|
2000-07-16 16:40:35 +02:00
|
|
|
((x11_ds_private *) chain->surfaces[i]->private)->opengl_flip = TRUE;
|
1999-07-03 13:57:29 +02:00
|
|
|
}
|
2000-04-09 16:30:50 +02:00
|
|
|
|
1999-05-13 20:53:05 +02:00
|
|
|
#endif
|
1999-01-17 17:55:11 +01:00
|
|
|
odev->rs.src = GL_ONE;
|
|
|
|
odev->rs.dst = GL_ZERO;
|
|
|
|
odev->rs.mag = GL_NEAREST;
|
|
|
|
odev->rs.min = GL_NEAREST;
|
|
|
|
odev->vt = 0;
|
2000-07-16 16:40:35 +02:00
|
|
|
|
|
|
|
/* 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));
|
1999-01-03 18:00:19 +01:00
|
|
|
|
|
|
|
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));
|
|
|
|
|
|
|
|
/* Initialisation */
|
1999-06-26 21:09:08 +02:00
|
|
|
TRACE("Setting current context\n");
|
1999-01-03 18:00:19 +01:00
|
|
|
(*device)->set_context(*device);
|
1999-06-26 21:09:08 +02:00
|
|
|
TRACE("Current context set\n");
|
1999-01-03 18:00:19 +01:00
|
|
|
glClearColor(0.0, 0.0, 0.0, 0.0);
|
|
|
|
glColor3f(1.0, 1.0, 1.0);
|
1999-05-13 20:53:05 +02:00
|
|
|
LEAVE_GL();
|
2000-07-16 16:40:35 +02:00
|
|
|
|
|
|
|
fill_device_capabilities(d3d->ddraw);
|
|
|
|
|
1999-06-26 21:09:08 +02:00
|
|
|
TRACE("OpenGL device created \n");
|
1999-01-03 18:00:19 +01:00
|
|
|
return 1;
|
|
|
|
}
|
2000-04-09 16:30:50 +02:00
|
|
|
FIXME("bad IID %s\n",debugstr_guid(rguid));
|
1999-01-03 18:00:19 +01:00
|
|
|
/* This is not the OpenGL UID */
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
2000-04-09 16:30:50 +02:00
|
|
|
* MESA IDirect3DDevice2
|
1999-01-03 18:00:19 +01:00
|
|
|
*/
|
2000-04-09 16:30:50 +02:00
|
|
|
static ULONG WINAPI MESA_IDirect3DDevice2Impl_Release(LPDIRECT3DDEVICE2 iface)
|
1999-01-03 18:00:19 +01:00
|
|
|
{
|
1999-03-27 17:56:13 +01:00
|
|
|
ICOM_THIS(IDirect3DDevice2Impl,iface);
|
2000-04-09 16:30:50 +02:00
|
|
|
D3DDPRIVATE(This);
|
1999-06-26 21:09:08 +02:00
|
|
|
FIXME("(%p)->() decrementing from %lu.\n", This, This->ref );
|
1999-01-03 18:00:19 +01:00
|
|
|
|
1999-03-27 17:56:13 +01:00
|
|
|
if (!--(This->ref)) {
|
1999-05-13 20:53:05 +02:00
|
|
|
#ifdef USE_OSMESA
|
|
|
|
OSMesaDestroyContext(odev->ctx);
|
|
|
|
#else
|
|
|
|
ENTER_GL();
|
2000-04-09 16:30:50 +02:00
|
|
|
glXDestroyContext(display, odev->ctx);
|
1999-05-13 20:53:05 +02:00
|
|
|
LEAVE_GL();
|
|
|
|
#endif
|
2000-04-09 16:30:50 +02:00
|
|
|
This->private = NULL;
|
1999-03-27 17:56:13 +01:00
|
|
|
HeapFree(GetProcessHeap(),0,This);
|
1999-01-03 18:00:19 +01:00
|
|
|
return 0;
|
|
|
|
}
|
1999-03-27 17:56:13 +01:00
|
|
|
return This->ref;
|
1999-01-03 18:00:19 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*** IDirect3DDevice2 methods ***/
|
2000-04-09 16:30:50 +02:00
|
|
|
static HRESULT WINAPI MESA_IDirect3DDevice2Impl_GetCaps(
|
|
|
|
LPDIRECT3DDEVICE2 iface, LPD3DDEVICEDESC lpdescsoft,
|
|
|
|
LPD3DDEVICEDESC lpdeschard
|
|
|
|
) {
|
1999-03-27 17:56:13 +01:00
|
|
|
ICOM_THIS(IDirect3DDevice2Impl,iface);
|
1999-06-26 21:09:08 +02:00
|
|
|
FIXME("(%p)->(%p,%p): stub\n", This, lpdescsoft, lpdeschard);
|
1999-01-03 18:00:19 +01:00
|
|
|
fill_opengl_caps(lpdescsoft, lpdeschard);
|
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT enum_texture_format_OpenGL(LPD3DENUMTEXTUREFORMATSCALLBACK cb,
|
|
|
|
LPVOID context) {
|
|
|
|
DDSURFACEDESC sdesc;
|
|
|
|
LPDDPIXELFORMAT pformat;
|
|
|
|
|
|
|
|
/* Do the texture enumeration */
|
|
|
|
sdesc.dwSize = sizeof(DDSURFACEDESC);
|
|
|
|
sdesc.dwFlags = DDSD_PIXELFORMAT | DDSD_CAPS;
|
|
|
|
sdesc.ddsCaps.dwCaps = DDSCAPS_TEXTURE;
|
|
|
|
pformat = &(sdesc.ddpfPixelFormat);
|
|
|
|
pformat->dwSize = sizeof(DDPIXELFORMAT);
|
|
|
|
pformat->dwFourCC = 0;
|
|
|
|
|
1999-06-26 21:09:08 +02:00
|
|
|
TRACE("Enumerating GL_RGBA unpacked (32)\n");
|
1999-01-03 18:00:19 +01:00
|
|
|
pformat->dwFlags = DDPF_RGB | DDPF_ALPHAPIXELS;
|
1999-10-23 20:52:17 +02:00
|
|
|
pformat->u.dwRGBBitCount = 32;
|
|
|
|
pformat->u1.dwRBitMask = 0xFF000000;
|
|
|
|
pformat->u2.dwGBitMask = 0x00FF0000;
|
|
|
|
pformat->u3.dwBBitMask = 0x0000FF00;
|
|
|
|
pformat->u4.dwRGBAlphaBitMask = 0x000000FF;
|
1999-01-03 18:00:19 +01:00
|
|
|
if (cb(&sdesc, context) == 0)
|
|
|
|
return DD_OK;
|
|
|
|
|
1999-06-26 21:09:08 +02:00
|
|
|
TRACE("Enumerating GL_RGB unpacked (24)\n");
|
1999-01-03 18:00:19 +01:00
|
|
|
pformat->dwFlags = DDPF_RGB;
|
1999-10-23 20:52:17 +02:00
|
|
|
pformat->u.dwRGBBitCount = 24;
|
|
|
|
pformat->u1.dwRBitMask = 0x00FF0000;
|
|
|
|
pformat->u2.dwGBitMask = 0x0000FF00;
|
|
|
|
pformat->u3.dwBBitMask = 0x000000FF;
|
|
|
|
pformat->u4.dwRGBAlphaBitMask = 0x00000000;
|
1999-01-03 18:00:19 +01:00
|
|
|
if (cb(&sdesc, context) == 0)
|
|
|
|
return DD_OK;
|
|
|
|
|
1999-01-23 13:32:46 +01:00
|
|
|
#ifndef HAVE_BUGGY_MESAGL
|
|
|
|
/* The packed texture format are buggy in Mesa. The bug was reported and corrected,
|
|
|
|
so that future version will work great. */
|
1999-06-26 21:09:08 +02:00
|
|
|
TRACE("Enumerating GL_RGB packed GL_UNSIGNED_SHORT_5_6_5 (16)\n");
|
1999-01-03 18:00:19 +01:00
|
|
|
pformat->dwFlags = DDPF_RGB;
|
1999-10-23 20:52:17 +02:00
|
|
|
pformat->u.dwRGBBitCount = 16;
|
|
|
|
pformat->u1.dwRBitMask = 0x0000F800;
|
|
|
|
pformat->u2.dwGBitMask = 0x000007E0;
|
|
|
|
pformat->u3.dwBBitMask = 0x0000001F;
|
|
|
|
pformat->u4.dwRGBAlphaBitMask = 0x00000000;
|
1999-01-03 18:00:19 +01:00
|
|
|
if (cb(&sdesc, context) == 0)
|
|
|
|
return DD_OK;
|
|
|
|
|
1999-06-26 21:09:08 +02:00
|
|
|
TRACE("Enumerating GL_RGBA packed GL_UNSIGNED_SHORT_5_5_5_1 (16)\n");
|
1999-01-23 13:32:46 +01:00
|
|
|
pformat->dwFlags = DDPF_RGB | DDPF_ALPHAPIXELS;
|
1999-10-23 20:52:17 +02:00
|
|
|
pformat->u.dwRGBBitCount = 16;
|
|
|
|
pformat->u1.dwRBitMask = 0x0000F800;
|
|
|
|
pformat->u2.dwGBitMask = 0x000007C0;
|
|
|
|
pformat->u3.dwBBitMask = 0x0000003E;
|
|
|
|
pformat->u4.dwRGBAlphaBitMask = 0x00000001;
|
1999-01-23 13:32:46 +01:00
|
|
|
if (cb(&sdesc, context) == 0)
|
|
|
|
return DD_OK;
|
|
|
|
|
1999-06-26 21:09:08 +02:00
|
|
|
TRACE("Enumerating GL_RGBA packed GL_UNSIGNED_SHORT_4_4_4_4 (16)\n");
|
1999-01-23 13:32:46 +01:00
|
|
|
pformat->dwFlags = DDPF_RGB | DDPF_ALPHAPIXELS;
|
1999-10-23 20:52:17 +02:00
|
|
|
pformat->u.dwRGBBitCount = 16;
|
|
|
|
pformat->u1.dwRBitMask = 0x0000F000;
|
|
|
|
pformat->u2.dwGBitMask = 0x00000F00;
|
|
|
|
pformat->u3.dwBBitMask = 0x000000F0;
|
|
|
|
pformat->u4.dwRGBAlphaBitMask = 0x0000000F;
|
1999-01-23 13:32:46 +01:00
|
|
|
if (cb(&sdesc, context) == 0)
|
|
|
|
return DD_OK;
|
|
|
|
|
1999-06-26 21:09:08 +02:00
|
|
|
TRACE("Enumerating GL_RGB packed GL_UNSIGNED_BYTE_3_3_2 (8)\n");
|
1999-01-23 13:32:46 +01:00
|
|
|
pformat->dwFlags = DDPF_RGB;
|
1999-10-23 20:52:17 +02:00
|
|
|
pformat->u.dwRGBBitCount = 8;
|
|
|
|
pformat->u1.dwRBitMask = 0x0000F800;
|
|
|
|
pformat->u2.dwGBitMask = 0x000007C0;
|
|
|
|
pformat->u3.dwBBitMask = 0x0000003E;
|
|
|
|
pformat->u4.dwRGBAlphaBitMask = 0x00000001;
|
1999-01-23 13:32:46 +01:00
|
|
|
if (cb(&sdesc, context) == 0)
|
|
|
|
return DD_OK;
|
|
|
|
#endif
|
2000-01-05 02:51:02 +01:00
|
|
|
|
1999-06-26 21:09:08 +02:00
|
|
|
TRACE("Enumerating Paletted (8)\n");
|
1999-01-03 18:00:19 +01:00
|
|
|
pformat->dwFlags = DDPF_PALETTEINDEXED8;
|
1999-10-23 20:52:17 +02:00
|
|
|
pformat->u.dwRGBBitCount = 8;
|
|
|
|
pformat->u1.dwRBitMask = 0x00000000;
|
|
|
|
pformat->u2.dwGBitMask = 0x00000000;
|
|
|
|
pformat->u3.dwBBitMask = 0x00000000;
|
|
|
|
pformat->u4.dwRGBAlphaBitMask = 0x00000000;
|
1999-01-03 18:00:19 +01:00
|
|
|
if (cb(&sdesc, context) == 0)
|
|
|
|
return DD_OK;
|
|
|
|
|
1999-06-26 21:09:08 +02:00
|
|
|
TRACE("End of enumeration\n");
|
1999-01-03 18:00:19 +01:00
|
|
|
|
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2000-04-09 16:30:50 +02:00
|
|
|
static HRESULT WINAPI MESA_IDirect3DDevice2Impl_EnumTextureFormats(
|
|
|
|
LPDIRECT3DDEVICE2 iface, LPD3DENUMTEXTUREFORMATSCALLBACK cb, LPVOID context
|
|
|
|
) {
|
1999-03-27 17:56:13 +01:00
|
|
|
ICOM_THIS(IDirect3DDevice2Impl,iface);
|
1999-06-26 21:09:08 +02:00
|
|
|
FIXME("(%p)->(%p,%p): stub\n", This, cb, context);
|
1999-01-03 18:00:19 +01:00
|
|
|
|
|
|
|
return enum_texture_format_OpenGL(cb, context);
|
|
|
|
}
|
|
|
|
|
2000-04-09 16:30:50 +02:00
|
|
|
static HRESULT WINAPI MESA_IDirect3DDevice2Impl_BeginScene(
|
|
|
|
LPDIRECT3DDEVICE2 iface
|
|
|
|
) {
|
1999-03-27 17:56:13 +01:00
|
|
|
ICOM_THIS(IDirect3DDevice2Impl,iface);
|
1999-01-03 18:00:19 +01:00
|
|
|
|
1999-06-26 21:09:08 +02:00
|
|
|
FIXME("(%p)->(): stub\n", This);
|
1999-01-03 18:00:19 +01:00
|
|
|
|
|
|
|
/* Here, we should get the DDraw surface and 'copy it' to the
|
|
|
|
OpenGL surface.... */
|
|
|
|
|
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2000-04-09 16:30:50 +02:00
|
|
|
HRESULT WINAPI MESA_IDirect3DDevice2Impl_EndScene(LPDIRECT3DDEVICE2 iface) {
|
1999-03-27 17:56:13 +01:00
|
|
|
ICOM_THIS(IDirect3DDevice2Impl,iface);
|
1999-05-13 20:53:05 +02:00
|
|
|
#ifdef USE_OSMESA
|
2000-04-09 16:30:50 +02:00
|
|
|
D3DPRIVATE(This);
|
|
|
|
|
1999-03-27 17:56:13 +01:00
|
|
|
LPDIRECTDRAWSURFACE3 surf = (LPDIRECTDRAWSURFACE3) This->surface;
|
1999-01-03 18:00:19 +01:00
|
|
|
DDSURFACEDESC sdesc;
|
|
|
|
int x,y;
|
|
|
|
unsigned char *src;
|
|
|
|
unsigned short *dest;
|
1999-05-13 20:53:05 +02:00
|
|
|
#endif
|
1999-01-03 18:00:19 +01:00
|
|
|
|
1999-06-26 21:09:08 +02:00
|
|
|
FIXME("(%p)->(): stub\n", This);
|
1999-01-03 18:00:19 +01:00
|
|
|
|
1999-05-13 20:53:05 +02:00
|
|
|
#ifdef USE_OSMESA
|
1999-01-03 18:00:19 +01:00
|
|
|
/* Here we copy back the OpenGL scene to the the DDraw surface */
|
|
|
|
/* First, lock the surface */
|
1999-03-27 17:56:13 +01:00
|
|
|
IDirectDrawSurface3_Lock(surf,NULL,&sdesc,DDLOCK_WRITEONLY,0);
|
1999-01-03 18:00:19 +01:00
|
|
|
|
|
|
|
/* The copy the OpenGL buffer to this surface */
|
|
|
|
|
|
|
|
/* NOTE : this is only for debugging purpose. I KNOW it is really unoptimal.
|
|
|
|
I am currently working on a set of patches for Mesa to have OSMesa support
|
|
|
|
16 bpp surfaces => we will able to render directly onto the surface, no
|
|
|
|
need to do a bpp conversion */
|
|
|
|
dest = (unsigned short *) sdesc.y.lpSurface;
|
|
|
|
src = ((unsigned char *) odev->buffer) + 4 * (sdesc.dwWidth * (sdesc.dwHeight - 1));
|
|
|
|
for (y = 0; y < sdesc.dwHeight; y++) {
|
|
|
|
unsigned char *lsrc = src;
|
|
|
|
|
|
|
|
for (x = 0; x < sdesc.dwWidth ; x++) {
|
|
|
|
unsigned char r = *lsrc++;
|
|
|
|
unsigned char g = *lsrc++;
|
|
|
|
unsigned char b = *lsrc++;
|
|
|
|
lsrc++; /* Alpha */
|
|
|
|
*dest = ((r >> 3) << 11) | ((g >> 2) << 5) | (b >> 3);
|
|
|
|
|
|
|
|
dest++;
|
|
|
|
}
|
|
|
|
|
|
|
|
src -= 4 * sdesc.dwWidth;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Unlock the surface */
|
1999-03-27 17:56:13 +01:00
|
|
|
IDirectDrawSurface3_Unlock(surf,sdesc.y.lpSurface);
|
1999-05-13 20:53:05 +02:00
|
|
|
#else
|
|
|
|
/* No need to do anything here... */
|
|
|
|
#endif
|
1999-01-03 18:00:19 +01:00
|
|
|
|
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2000-04-09 16:30:50 +02:00
|
|
|
static HRESULT WINAPI MESA_IDirect3DDevice2Impl_SetRenderState(
|
|
|
|
LPDIRECT3DDEVICE2 iface, D3DRENDERSTATETYPE dwRenderStateType,
|
|
|
|
DWORD dwRenderState
|
|
|
|
) {
|
1999-03-27 17:56:13 +01:00
|
|
|
ICOM_THIS(IDirect3DDevice2Impl,iface);
|
2000-04-09 16:30:50 +02:00
|
|
|
D3DDPRIVATE(This);
|
1999-01-17 17:55:11 +01:00
|
|
|
|
1999-06-26 21:09:08 +02:00
|
|
|
TRACE("(%p)->(%d,%ld)\n", This, dwRenderStateType, dwRenderState);
|
1999-01-03 18:00:19 +01:00
|
|
|
|
|
|
|
/* Call the render state functions */
|
1999-01-17 17:55:11 +01:00
|
|
|
set_render_state(dwRenderStateType, dwRenderState, &(odev->rs));
|
1999-01-03 18:00:19 +01:00
|
|
|
|
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2000-04-09 16:30:50 +02:00
|
|
|
static HRESULT WINAPI MESA_IDirect3DDevice2Impl_SetLightState(
|
|
|
|
LPDIRECT3DDEVICE2 iface, D3DLIGHTSTATETYPE dwLightStateType,
|
|
|
|
DWORD dwLightState
|
|
|
|
) {
|
1999-03-27 17:56:13 +01:00
|
|
|
ICOM_THIS(IDirect3DDevice2Impl,iface);
|
1999-06-26 21:09:08 +02:00
|
|
|
FIXME("(%p)->(%d,%08lx): stub\n", This, dwLightStateType, dwLightState);
|
1999-01-03 18:00:19 +01:00
|
|
|
|
|
|
|
switch (dwLightStateType) {
|
|
|
|
case D3DLIGHTSTATE_MATERIAL: { /* 1 */
|
1999-03-27 17:56:13 +01:00
|
|
|
IDirect3DMaterial2Impl* mat = (IDirect3DMaterial2Impl*) dwLightState;
|
1999-01-03 18:00:19 +01:00
|
|
|
|
|
|
|
if (mat != NULL) {
|
1999-05-13 20:53:05 +02:00
|
|
|
ENTER_GL();
|
1999-01-03 18:00:19 +01:00
|
|
|
mat->activate(mat);
|
1999-05-13 20:53:05 +02:00
|
|
|
LEAVE_GL();
|
1999-01-03 18:00:19 +01:00
|
|
|
} else {
|
1999-06-26 21:09:08 +02:00
|
|
|
TRACE("Zoups !!!\n");
|
1999-01-03 18:00:19 +01:00
|
|
|
}
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case D3DLIGHTSTATE_AMBIENT: { /* 2 */
|
|
|
|
float light[4];
|
|
|
|
|
|
|
|
light[0] = ((dwLightState >> 16) & 0xFF) / 255.0;
|
|
|
|
light[1] = ((dwLightState >> 8) & 0xFF) / 255.0;
|
|
|
|
light[2] = ((dwLightState >> 0) & 0xFF) / 255.0;
|
|
|
|
light[3] = 1.0;
|
1999-05-13 20:53:05 +02:00
|
|
|
ENTER_GL();
|
1999-01-03 18:00:19 +01:00
|
|
|
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, (float *) light);
|
1999-05-13 20:53:05 +02:00
|
|
|
LEAVE_GL();
|
1999-01-03 18:00:19 +01:00
|
|
|
} break;
|
2000-04-09 16:30:50 +02:00
|
|
|
|
|
|
|
#define UNSUP(x) case D3DLIGHTSTATE_##x: FIXME("unsupported D3DLIGHTSTATE_" #x "!\n");break;
|
|
|
|
UNSUP(COLORMODEL);
|
|
|
|
UNSUP(FOGMODE);
|
|
|
|
UNSUP(FOGSTART);
|
|
|
|
UNSUP(FOGEND);
|
|
|
|
UNSUP(FOGDENSITY);
|
|
|
|
#undef UNSUP
|
1999-01-03 18:00:19 +01:00
|
|
|
default:
|
1999-06-26 21:09:08 +02:00
|
|
|
TRACE("Unexpected Light State Type\n");
|
1999-01-03 18:00:19 +01:00
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
}
|
|
|
|
|
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2000-04-09 16:30:50 +02:00
|
|
|
static HRESULT WINAPI MESA_IDirect3DDevice2Impl_SetTransform(
|
|
|
|
LPDIRECT3DDEVICE2 iface, D3DTRANSFORMSTATETYPE d3dts,
|
|
|
|
LPD3DMATRIX lpmatrix
|
|
|
|
) {
|
1999-03-27 17:56:13 +01:00
|
|
|
ICOM_THIS(IDirect3DDevice2Impl,iface);
|
2000-04-09 16:30:50 +02:00
|
|
|
D3DDPRIVATE(This);
|
1999-01-03 18:00:19 +01:00
|
|
|
|
1999-06-26 21:09:08 +02:00
|
|
|
FIXME("(%p)->(%d,%p): stub\n", This, d3dts, lpmatrix);
|
1999-01-03 18:00:19 +01:00
|
|
|
|
1999-05-13 20:53:05 +02:00
|
|
|
ENTER_GL();
|
|
|
|
|
1999-01-03 18:00:19 +01:00
|
|
|
/* Using a trial and failure approach, I found that the order of
|
|
|
|
Direct3D transformations that works best is :
|
|
|
|
|
|
|
|
ScreenCoord = ProjectionMat * ViewMat * WorldMat * ObjectCoord
|
|
|
|
|
|
|
|
As OpenGL uses only two matrices, I combined PROJECTION and VIEW into
|
|
|
|
OpenGL's GL_PROJECTION matrix and the WORLD into GL_MODELVIEW.
|
|
|
|
|
|
|
|
If anyone has a good explanation of the three different matrices in
|
|
|
|
the SDK online documentation, feel free to point it to me. For example,
|
|
|
|
which matrices transform lights ? In OpenGL only the PROJECTION matrix
|
|
|
|
transform the lights, not the MODELVIEW. Using the matrix names, I
|
|
|
|
supposed that PROJECTION and VIEW (all 'camera' related names) do
|
|
|
|
transform lights, but WORLD do not. It may be wrong though... */
|
|
|
|
|
|
|
|
/* After reading through both OpenGL and Direct3D documentations, I
|
|
|
|
thought that D3D matrices were written in 'line major mode' transposed
|
|
|
|
from OpenGL's 'column major mode'. But I found out that a simple memcpy
|
|
|
|
works fine to transfer one matrix format to the other (it did not work
|
|
|
|
when transposing)....
|
|
|
|
|
|
|
|
So :
|
|
|
|
1) are the documentations wrong
|
|
|
|
2) does the matrix work even if they are not read correctly
|
|
|
|
3) is Mesa's implementation of OpenGL not compliant regarding Matrix
|
|
|
|
loading using glLoadMatrix ?
|
|
|
|
|
|
|
|
Anyway, I always use 'conv_mat' to transfer the matrices from one format
|
|
|
|
to the other so that if I ever find out that I need to transpose them, I
|
|
|
|
will able to do it quickly, only by changing the macro conv_mat. */
|
|
|
|
|
|
|
|
switch (d3dts) {
|
|
|
|
case D3DTRANSFORMSTATE_WORLD: {
|
|
|
|
conv_mat(lpmatrix, odev->world_mat);
|
|
|
|
glMatrixMode(GL_MODELVIEW);
|
2000-07-16 16:40:35 +02:00
|
|
|
glLoadMatrixf((float *) odev->world_mat);
|
1999-01-03 18:00:19 +01:00
|
|
|
} break;
|
|
|
|
|
|
|
|
case D3DTRANSFORMSTATE_VIEW: {
|
|
|
|
conv_mat(lpmatrix, odev->view_mat);
|
|
|
|
glMatrixMode(GL_PROJECTION);
|
2000-07-16 16:40:35 +02:00
|
|
|
glLoadMatrixf((float *) odev->proj_mat);
|
|
|
|
glMultMatrixf((float *) odev->view_mat);
|
1999-01-03 18:00:19 +01:00
|
|
|
} break;
|
|
|
|
|
|
|
|
case D3DTRANSFORMSTATE_PROJECTION: {
|
|
|
|
conv_mat(lpmatrix, odev->proj_mat);
|
|
|
|
glMatrixMode(GL_PROJECTION);
|
2000-07-16 16:40:35 +02:00
|
|
|
glLoadMatrixf((float *) odev->proj_mat);
|
|
|
|
glMultMatrixf((float *) odev->view_mat);
|
1999-01-03 18:00:19 +01:00
|
|
|
} break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
1999-05-13 20:53:05 +02:00
|
|
|
LEAVE_GL();
|
1999-01-03 18:00:19 +01:00
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2000-04-09 16:30:50 +02:00
|
|
|
#define DRAW_PRIMITIVE(MAXVERT,INDEX) \
|
|
|
|
/* Puts GL in the correct lighting mode */ \
|
|
|
|
if (odev->vt != d3dv) { \
|
|
|
|
if (odev->vt == D3DVT_TLVERTEX) { \
|
|
|
|
/* Need to put the correct transformation again */ \
|
|
|
|
glMatrixMode(GL_MODELVIEW); \
|
2000-07-16 16:40:35 +02:00
|
|
|
glLoadMatrixf((float *) odev->world_mat); \
|
2000-04-09 16:30:50 +02:00
|
|
|
glMatrixMode(GL_PROJECTION); \
|
2000-07-16 16:40:35 +02:00
|
|
|
glLoadMatrixf((float *) odev->proj_mat); \
|
|
|
|
glMultMatrixf((float *) odev->view_mat); \
|
2000-04-09 16:30:50 +02:00
|
|
|
} \
|
|
|
|
\
|
|
|
|
switch (d3dv) { \
|
|
|
|
case D3DVT_VERTEX: \
|
1999-06-26 21:09:08 +02:00
|
|
|
TRACE("Standard Vertex\n"); \
|
2000-04-09 16:30:50 +02:00
|
|
|
glEnable(GL_LIGHTING); \
|
|
|
|
break; \
|
|
|
|
\
|
|
|
|
case D3DVT_LVERTEX: \
|
|
|
|
TRACE("Lighted Vertex\n"); \
|
|
|
|
glDisable(GL_LIGHTING); \
|
|
|
|
break; \
|
|
|
|
\
|
|
|
|
case D3DVT_TLVERTEX: { \
|
|
|
|
GLdouble height, width, minZ, maxZ; \
|
|
|
|
\
|
1999-06-26 21:09:08 +02:00
|
|
|
TRACE("Transformed - Lighted Vertex\n"); \
|
2000-04-09 16:30:50 +02:00
|
|
|
/* First, disable lighting */ \
|
|
|
|
glDisable(GL_LIGHTING); \
|
|
|
|
\
|
|
|
|
/* Then do not put any transformation matrixes */ \
|
|
|
|
glMatrixMode(GL_MODELVIEW); \
|
|
|
|
glLoadIdentity(); \
|
|
|
|
glMatrixMode(GL_PROJECTION); \
|
|
|
|
glLoadIdentity(); \
|
|
|
|
\
|
|
|
|
if (This->current_viewport == NULL) { \
|
1999-06-26 21:09:08 +02:00
|
|
|
ERR("No current viewport !\n"); \
|
2000-04-09 16:30:50 +02:00
|
|
|
/* Using standard values */ \
|
|
|
|
height = 640.0; \
|
|
|
|
width = 480.0; \
|
|
|
|
minZ = -10.0; \
|
|
|
|
maxZ = 10.0; \
|
|
|
|
} else { \
|
|
|
|
if (This->current_viewport->use_vp2) { \
|
|
|
|
height = (GLdouble) This->current_viewport->viewport.vp2.dwHeight;\
|
|
|
|
width = (GLdouble) This->current_viewport->viewport.vp2.dwWidth;\
|
|
|
|
minZ = (GLdouble) This->current_viewport->viewport.vp2.dvMinZ;\
|
|
|
|
maxZ = (GLdouble) This->current_viewport->viewport.vp2.dvMaxZ;\
|
|
|
|
} else { \
|
|
|
|
height = (GLdouble) This->current_viewport->viewport.vp1.dwHeight;\
|
|
|
|
width = (GLdouble) This->current_viewport->viewport.vp1.dwWidth;\
|
|
|
|
minZ = (GLdouble) This->current_viewport->viewport.vp1.dvMinZ;\
|
|
|
|
maxZ = (GLdouble) This->current_viewport->viewport.vp1.dvMaxZ;\
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
glOrtho(0.0, width, height, 0.0, -minZ, -maxZ); \
|
|
|
|
} break; \
|
|
|
|
\
|
|
|
|
default: \
|
1999-06-26 21:09:08 +02:00
|
|
|
ERR("Unhandled vertex type\n"); \
|
2000-04-09 16:30:50 +02:00
|
|
|
break; \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
odev->vt = d3dv; \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
switch (d3dp) { \
|
|
|
|
case D3DPT_POINTLIST: \
|
1999-06-26 21:09:08 +02:00
|
|
|
TRACE("Start POINTS\n"); \
|
2000-04-09 16:30:50 +02:00
|
|
|
glBegin(GL_POINTS); \
|
|
|
|
break; \
|
|
|
|
\
|
|
|
|
case D3DPT_LINELIST: \
|
1999-06-26 21:09:08 +02:00
|
|
|
TRACE("Start LINES\n"); \
|
2000-04-09 16:30:50 +02:00
|
|
|
glBegin(GL_LINES); \
|
|
|
|
break; \
|
|
|
|
\
|
|
|
|
case D3DPT_LINESTRIP: \
|
|
|
|
TRACE("Start LINE_STRIP\n"); \
|
|
|
|
glBegin(GL_LINE_STRIP); \
|
|
|
|
break; \
|
|
|
|
\
|
|
|
|
case D3DPT_TRIANGLELIST: \
|
1999-06-26 21:09:08 +02:00
|
|
|
TRACE("Start TRIANGLES\n"); \
|
2000-04-09 16:30:50 +02:00
|
|
|
glBegin(GL_TRIANGLES); \
|
|
|
|
break; \
|
|
|
|
\
|
|
|
|
case D3DPT_TRIANGLESTRIP: \
|
1999-06-26 21:09:08 +02:00
|
|
|
TRACE("Start TRIANGLE_STRIP\n"); \
|
2000-04-09 16:30:50 +02:00
|
|
|
glBegin(GL_TRIANGLE_STRIP); \
|
|
|
|
break; \
|
|
|
|
\
|
|
|
|
case D3DPT_TRIANGLEFAN: \
|
1999-06-26 21:09:08 +02:00
|
|
|
TRACE("Start TRIANGLE_FAN\n"); \
|
2000-04-09 16:30:50 +02:00
|
|
|
glBegin(GL_TRIANGLE_FAN); \
|
|
|
|
break; \
|
|
|
|
\
|
|
|
|
default: \
|
1999-06-26 21:09:08 +02:00
|
|
|
TRACE("Unhandled primitive\n"); \
|
2000-04-09 16:30:50 +02:00
|
|
|
break; \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
/* Draw the primitives */ \
|
|
|
|
for (vx_index = 0; vx_index < MAXVERT; vx_index++) { \
|
|
|
|
switch (d3dv) { \
|
|
|
|
case D3DVT_VERTEX: { \
|
|
|
|
D3DVERTEX *vx = ((D3DVERTEX *) lpvertex) + INDEX; \
|
|
|
|
\
|
|
|
|
glNormal3f(vx->nx.nx, vx->ny.ny, vx->nz.nz); \
|
|
|
|
glVertex3f(vx->x.x, vx->y.y, vx->z.z); \
|
1999-06-26 21:09:08 +02:00
|
|
|
TRACE(" V: %f %f %f\n", vx->x.x, vx->y.y, vx->z.z); \
|
2000-04-09 16:30:50 +02:00
|
|
|
} break; \
|
|
|
|
\
|
|
|
|
case D3DVT_LVERTEX: { \
|
|
|
|
D3DLVERTEX *vx = ((D3DLVERTEX *) lpvertex) + INDEX; \
|
|
|
|
DWORD col = vx->c.color; \
|
|
|
|
\
|
|
|
|
glColor3f(((col >> 16) & 0xFF) / 255.0, \
|
|
|
|
((col >> 8) & 0xFF) / 255.0, \
|
|
|
|
((col >> 0) & 0xFF) / 255.0); \
|
|
|
|
glVertex3f(vx->x.x, vx->y.y, vx->z.z); \
|
1999-06-26 21:09:08 +02:00
|
|
|
TRACE(" LV: %f %f %f (%02lx %02lx %02lx)\n", \
|
2000-04-09 16:30:50 +02:00
|
|
|
vx->x.x, vx->y.y, vx->z.z, \
|
|
|
|
((col >> 16) & 0xFF), ((col >> 8) & 0xFF), ((col >> 0) & 0xFF));\
|
|
|
|
} break; \
|
|
|
|
\
|
|
|
|
case D3DVT_TLVERTEX: { \
|
|
|
|
D3DTLVERTEX *vx = ((D3DTLVERTEX *) lpvertex) + INDEX; \
|
|
|
|
DWORD col = vx->c.color; \
|
|
|
|
\
|
|
|
|
glColor3f(((col >> 16) & 0xFF) / 255.0, \
|
|
|
|
((col >> 8) & 0xFF) / 255.0, \
|
|
|
|
((col >> 0) & 0xFF) / 255.0); \
|
|
|
|
glTexCoord2f(vx->u.tu, vx->v.tv); \
|
|
|
|
if (vx->r.rhw < 0.01) \
|
|
|
|
glVertex3f(vx->x.sx, \
|
|
|
|
vx->y.sy, \
|
|
|
|
vx->z.sz); \
|
|
|
|
else \
|
|
|
|
glVertex4f(vx->x.sx / vx->r.rhw, \
|
|
|
|
vx->y.sy / vx->r.rhw, \
|
|
|
|
vx->z.sz / vx->r.rhw, \
|
|
|
|
1.0 / vx->r.rhw); \
|
|
|
|
TRACE(" TLV: %f %f %f (%02lx %02lx %02lx) (%f %f) (%f)\n", \
|
|
|
|
vx->x.sx, vx->y.sy, vx->z.sz, \
|
|
|
|
((col >> 16) & 0xFF), ((col >> 8) & 0xFF), ((col >> 0) & 0xFF),\
|
|
|
|
vx->u.tu, vx->v.tv, vx->r.rhw); \
|
|
|
|
} break; \
|
|
|
|
\
|
|
|
|
default: \
|
|
|
|
FIXME("Unhandled vertex type\n"); \
|
|
|
|
break; \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
glEnd(); \
|
1999-06-26 21:09:08 +02:00
|
|
|
TRACE("End\n");
|
1999-01-03 18:00:19 +01:00
|
|
|
|
|
|
|
|
2000-04-09 16:30:50 +02:00
|
|
|
static HRESULT WINAPI MESA_IDirect3DDevice2Impl_DrawPrimitive(
|
|
|
|
LPDIRECT3DDEVICE2 iface, D3DPRIMITIVETYPE d3dp, D3DVERTEXTYPE d3dv,
|
|
|
|
LPVOID lpvertex, DWORD vertcount, DWORD dwFlags
|
|
|
|
) {
|
1999-03-27 17:56:13 +01:00
|
|
|
ICOM_THIS(IDirect3DDevice2Impl,iface);
|
2000-04-09 16:30:50 +02:00
|
|
|
D3DDPRIVATE(This);
|
1999-01-03 18:00:19 +01:00
|
|
|
int vx_index;
|
|
|
|
|
1999-06-26 21:09:08 +02:00
|
|
|
TRACE("(%p)->(%d,%d,%p,%ld,%08lx): stub\n", This, d3dp, d3dv, lpvertex, vertcount, dwFlags);
|
1999-01-03 18:00:19 +01:00
|
|
|
|
1999-05-13 20:53:05 +02:00
|
|
|
ENTER_GL();
|
1999-01-17 17:55:11 +01:00
|
|
|
DRAW_PRIMITIVE(vertcount, vx_index);
|
1999-05-13 20:53:05 +02:00
|
|
|
LEAVE_GL();
|
1999-01-03 18:00:19 +01:00
|
|
|
|
1999-01-17 17:55:11 +01:00
|
|
|
return D3D_OK;
|
2000-04-09 16:30:50 +02:00
|
|
|
}
|
1999-01-03 18:00:19 +01:00
|
|
|
|
2000-04-09 16:30:50 +02:00
|
|
|
static HRESULT WINAPI MESA_IDirect3DDevice2Impl_DrawIndexedPrimitive(
|
|
|
|
LPDIRECT3DDEVICE2 iface, D3DPRIMITIVETYPE d3dp, D3DVERTEXTYPE d3dv,
|
|
|
|
LPVOID lpvertex, DWORD vertcount, LPWORD lpindexes, DWORD indexcount,
|
|
|
|
DWORD dwFlags
|
|
|
|
) {
|
1999-03-27 17:56:13 +01:00
|
|
|
ICOM_THIS(IDirect3DDevice2Impl,iface);
|
2000-04-09 16:30:50 +02:00
|
|
|
D3DDPRIVATE(This);
|
1999-01-03 18:00:19 +01:00
|
|
|
int vx_index;
|
|
|
|
|
1999-06-26 21:09:08 +02:00
|
|
|
TRACE("(%p)->(%d,%d,%p,%ld,%p,%ld,%08lx): stub\n", This, d3dp, d3dv, lpvertex, vertcount, lpindexes, indexcount, dwFlags);
|
1999-01-03 18:00:19 +01:00
|
|
|
|
1999-05-13 20:53:05 +02:00
|
|
|
ENTER_GL();
|
1999-01-17 17:55:11 +01:00
|
|
|
DRAW_PRIMITIVE(indexcount, lpindexes[vx_index]);
|
1999-05-13 20:53:05 +02:00
|
|
|
LEAVE_GL();
|
1999-01-03 18:00:19 +01:00
|
|
|
|
1999-01-17 17:55:11 +01:00
|
|
|
return D3D_OK;
|
1999-01-03 18:00:19 +01:00
|
|
|
}
|
|
|
|
|
2000-04-10 15:45:17 +02:00
|
|
|
static HRESULT WINAPI MESA_IDirect3DDeviceImpl_CreateExecuteBuffer(
|
|
|
|
LPDIRECT3DDEVICE iface, LPD3DEXECUTEBUFFERDESC lpDesc,
|
|
|
|
LPDIRECT3DEXECUTEBUFFER *lplpDirect3DExecuteBuffer, IUnknown *pUnkOuter
|
|
|
|
) {
|
|
|
|
ICOM_THIS(IDirect3DDeviceImpl,iface);
|
|
|
|
TRACE("(%p)->(%p,%p,%p)\n", This, lpDesc, lplpDirect3DExecuteBuffer, pUnkOuter);
|
|
|
|
*lplpDirect3DExecuteBuffer = d3dexecutebuffer_create(This, lpDesc);
|
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-01-03 18:00:19 +01:00
|
|
|
/*******************************************************************************
|
|
|
|
* OpenGL-specific IDirect3DDevice2
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* OpenGL-specific VTable
|
|
|
|
*/
|
|
|
|
|
2000-04-09 16:30:50 +02:00
|
|
|
ICOM_VTABLE(IDirect3DDevice2) OpenGL_vtable =
|
1999-05-22 13:41:38 +02:00
|
|
|
{
|
|
|
|
ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
|
1999-03-27 17:56:13 +01:00
|
|
|
IDirect3DDevice2Impl_QueryInterface,
|
|
|
|
IDirect3DDevice2Impl_AddRef,
|
2000-04-09 16:30:50 +02:00
|
|
|
MESA_IDirect3DDevice2Impl_Release,
|
1999-01-03 18:00:19 +01:00
|
|
|
/*** IDirect3DDevice2 methods ***/
|
2000-04-09 16:30:50 +02:00
|
|
|
MESA_IDirect3DDevice2Impl_GetCaps,
|
1999-03-27 17:56:13 +01:00
|
|
|
IDirect3DDevice2Impl_SwapTextureHandles,
|
|
|
|
IDirect3DDevice2Impl_GetStats,
|
|
|
|
IDirect3DDevice2Impl_AddViewport,
|
|
|
|
IDirect3DDevice2Impl_DeleteViewport,
|
|
|
|
IDirect3DDevice2Impl_NextViewport,
|
2000-04-09 16:30:50 +02:00
|
|
|
MESA_IDirect3DDevice2Impl_EnumTextureFormats,
|
|
|
|
MESA_IDirect3DDevice2Impl_BeginScene,
|
|
|
|
MESA_IDirect3DDevice2Impl_EndScene,
|
1999-03-27 17:56:13 +01:00
|
|
|
IDirect3DDevice2Impl_GetDirect3D,
|
1999-01-03 18:00:19 +01:00
|
|
|
|
|
|
|
/*** DrawPrimitive API ***/
|
1999-03-27 17:56:13 +01:00
|
|
|
IDirect3DDevice2Impl_SetCurrentViewport,
|
|
|
|
IDirect3DDevice2Impl_GetCurrentViewport,
|
|
|
|
|
|
|
|
IDirect3DDevice2Impl_SetRenderTarget,
|
|
|
|
IDirect3DDevice2Impl_GetRenderTarget,
|
|
|
|
|
|
|
|
IDirect3DDevice2Impl_Begin,
|
|
|
|
IDirect3DDevice2Impl_BeginIndexed,
|
|
|
|
IDirect3DDevice2Impl_Vertex,
|
|
|
|
IDirect3DDevice2Impl_Index,
|
|
|
|
IDirect3DDevice2Impl_End,
|
|
|
|
|
|
|
|
IDirect3DDevice2Impl_GetRenderState,
|
2000-04-09 16:30:50 +02:00
|
|
|
MESA_IDirect3DDevice2Impl_SetRenderState,
|
1999-03-27 17:56:13 +01:00
|
|
|
IDirect3DDevice2Impl_GetLightState,
|
2000-04-09 16:30:50 +02:00
|
|
|
MESA_IDirect3DDevice2Impl_SetLightState,
|
|
|
|
MESA_IDirect3DDevice2Impl_SetTransform,
|
1999-03-27 17:56:13 +01:00
|
|
|
IDirect3DDevice2Impl_GetTransform,
|
|
|
|
IDirect3DDevice2Impl_MultiplyTransform,
|
|
|
|
|
2000-04-09 16:30:50 +02:00
|
|
|
MESA_IDirect3DDevice2Impl_DrawPrimitive,
|
|
|
|
MESA_IDirect3DDevice2Impl_DrawIndexedPrimitive,
|
1999-03-27 17:56:13 +01:00
|
|
|
|
|
|
|
IDirect3DDevice2Impl_SetClipStatus,
|
|
|
|
IDirect3DDevice2Impl_GetClipStatus,
|
1999-01-03 18:00:19 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* Direct3DDevice
|
|
|
|
*/
|
|
|
|
int d3d_OpenGL_dx3(LPD3DENUMDEVICESCALLBACK cb, LPVOID context) {
|
|
|
|
D3DDEVICEDESC d1,d2;
|
|
|
|
|
2000-07-16 16:40:35 +02:00
|
|
|
TRACE(" Enumerating OpenGL D3D device (IID %s).\n", debugstr_guid(&IID_D3DDEVICE_OpenGL));
|
1999-01-03 18:00:19 +01:00
|
|
|
|
|
|
|
fill_opengl_caps(&d1, &d2);
|
|
|
|
|
|
|
|
return cb((void*)&IID_D3DDEVICE_OpenGL,"WINE Direct3D using OpenGL","direct3d",&d1,&d2,context);
|
|
|
|
}
|
|
|
|
|
1999-03-27 17:56:13 +01:00
|
|
|
int is_OpenGL_dx3(REFCLSID rguid, IDirectDrawSurfaceImpl* surface, IDirect3DDeviceImpl** device)
|
1999-01-03 18:00:19 +01:00
|
|
|
{
|
|
|
|
if (!memcmp(&IID_D3DDEVICE_OpenGL,rguid,sizeof(IID_D3DDEVICE_OpenGL))) {
|
2000-04-09 16:30:50 +02:00
|
|
|
mesa_d3dd_private *odev;
|
1999-05-13 20:53:05 +02:00
|
|
|
#ifndef USE_OSMESA
|
|
|
|
int attributeList[]={ GLX_RGBA, GLX_DEPTH_SIZE, 16, GLX_DOUBLEBUFFER, None };
|
|
|
|
XVisualInfo *xvis;
|
|
|
|
#endif
|
1999-01-03 18:00:19 +01:00
|
|
|
|
2000-04-09 16:30:50 +02:00
|
|
|
*device = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(IDirect3DDeviceImpl));
|
|
|
|
(*device)->private = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(mesa_d3dd_private));
|
|
|
|
odev = (mesa_d3dd_private*)(*device)->private;
|
1999-01-03 18:00:19 +01:00
|
|
|
(*device)->ref = 1;
|
1999-10-31 02:59:23 +01:00
|
|
|
ICOM_VTBL(*device) = &OpenGL_vtable_dx3;
|
1999-01-03 18:00:19 +01:00
|
|
|
(*device)->d3d = NULL;
|
|
|
|
(*device)->surface = surface;
|
|
|
|
|
|
|
|
(*device)->viewport_list = NULL;
|
|
|
|
(*device)->current_viewport = NULL;
|
|
|
|
|
2000-04-09 16:30:50 +02:00
|
|
|
(*device)->set_context = (void*)set_context;
|
1999-01-03 18:00:19 +01:00
|
|
|
|
1999-06-26 21:09:08 +02:00
|
|
|
TRACE("OpenGL device created \n");
|
1999-01-03 18:00:19 +01:00
|
|
|
|
|
|
|
/* Create the OpenGL context */
|
1999-05-13 20:53:05 +02:00
|
|
|
#ifdef USE_OSMESA
|
1999-01-03 18:00:19 +01:00
|
|
|
odev->ctx = OSMesaCreateContext(OSMESA_RGBA, NULL);
|
|
|
|
odev->buffer = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,
|
|
|
|
surface->s.surface_desc.dwWidth * surface->s.surface_desc.dwHeight * 4);
|
1999-05-13 20:53:05 +02:00
|
|
|
#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)
|
1999-06-26 21:09:08 +02:00
|
|
|
ERR("No visual found !\n");
|
1999-05-13 20:53:05 +02:00
|
|
|
else
|
1999-06-26 21:09:08 +02:00
|
|
|
TRACE("Visual found\n");
|
1999-05-13 20:53:05 +02:00
|
|
|
/* Create the context */
|
|
|
|
odev->ctx = glXCreateContext(display,
|
|
|
|
xvis,
|
|
|
|
NULL,
|
|
|
|
GL_TRUE);
|
1999-06-26 21:09:08 +02:00
|
|
|
TRACE("Context created\n");
|
1999-05-13 20:53:05 +02:00
|
|
|
|
2000-04-09 16:30:50 +02:00
|
|
|
#if 0 /* non working currently */
|
1999-05-13 20:53:05 +02:00
|
|
|
/* Now override the surface's Flip method (if in double buffering) */
|
|
|
|
surface->s.d3d_device = (void *) odev;
|
1999-07-03 13:57:29 +02:00
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
2000-04-09 16:30:50 +02:00
|
|
|
#endif
|
1999-05-13 20:53:05 +02:00
|
|
|
#endif
|
1999-01-17 17:55:11 +01:00
|
|
|
odev->rs.src = GL_ONE;
|
|
|
|
odev->rs.dst = GL_ZERO;
|
|
|
|
odev->rs.mag = GL_NEAREST;
|
|
|
|
odev->rs.min = GL_NEAREST;
|
1999-01-03 18:00:19 +01:00
|
|
|
|
|
|
|
odev->world_mat = (LPD3DMATRIX) &id_mat;
|
|
|
|
odev->view_mat = (LPD3DMATRIX) &id_mat;
|
|
|
|
odev->proj_mat = (LPD3DMATRIX) &id_mat;
|
|
|
|
|
|
|
|
/* Initialisation */
|
|
|
|
(*device)->set_context(*device);
|
|
|
|
glClearColor(0.0, 0.0, 0.0, 0.0);
|
|
|
|
glColor3f(1.0, 1.0, 1.0);
|
|
|
|
|
2000-07-16 16:40:35 +02:00
|
|
|
fill_device_capabilities((IDirectDrawImpl *) surface->s.ddraw);
|
|
|
|
|
1999-01-03 18:00:19 +01:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* This is not the OpenGL UID */
|
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2000-04-09 16:30:50 +02:00
|
|
|
static ULONG WINAPI MESA_IDirect3DDeviceImpl_Release(LPDIRECT3DDEVICE iface)
|
1999-01-03 18:00:19 +01:00
|
|
|
{
|
1999-03-27 17:56:13 +01:00
|
|
|
ICOM_THIS(IDirect3DDeviceImpl,iface);
|
1999-06-26 21:09:08 +02:00
|
|
|
FIXME("(%p)->() decrementing from %lu.\n", This, This->ref );
|
1999-01-03 18:00:19 +01:00
|
|
|
|
1999-03-27 17:56:13 +01:00
|
|
|
if (!--(This->ref)) {
|
2000-04-09 16:30:50 +02:00
|
|
|
D3DDPRIVATE(This);
|
1999-05-13 20:53:05 +02:00
|
|
|
#ifdef USE_OSMESA
|
|
|
|
OSMesaDestroyContext(odev->ctx);
|
|
|
|
#else
|
|
|
|
ENTER_GL();
|
2000-04-09 16:30:50 +02:00
|
|
|
glXDestroyContext(display, odev->ctx);
|
1999-05-13 20:53:05 +02:00
|
|
|
LEAVE_GL();
|
|
|
|
#endif
|
2000-04-09 16:30:50 +02:00
|
|
|
This->private = NULL;
|
1999-03-27 17:56:13 +01:00
|
|
|
HeapFree(GetProcessHeap(),0,This);
|
1999-01-03 18:00:19 +01:00
|
|
|
return 0;
|
|
|
|
}
|
1999-03-27 17:56:13 +01:00
|
|
|
return This->ref;
|
1999-01-03 18:00:19 +01:00
|
|
|
}
|
|
|
|
|
2000-04-09 16:30:50 +02:00
|
|
|
static HRESULT WINAPI MESA_IDirect3DDeviceImpl_EnumTextureFormats(
|
|
|
|
LPDIRECT3DDEVICE iface,LPD3DENUMTEXTUREFORMATSCALLBACK lpd3dEnumTextureProc,
|
|
|
|
LPVOID lpArg)
|
1999-01-03 18:00:19 +01:00
|
|
|
{
|
1999-03-27 17:56:13 +01:00
|
|
|
ICOM_THIS(IDirect3DDeviceImpl,iface);
|
1999-06-26 21:09:08 +02:00
|
|
|
TRACE("(%p)->(%p,%p): stub\n", This, lpd3dEnumTextureProc, lpArg);
|
1999-01-03 18:00:19 +01:00
|
|
|
|
|
|
|
return enum_texture_format_OpenGL(lpd3dEnumTextureProc, lpArg);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-04-09 16:30:50 +02:00
|
|
|
static HRESULT WINAPI MESA_IDirect3DDeviceImpl_BeginScene(LPDIRECT3DDEVICE iface)
|
1999-01-03 18:00:19 +01:00
|
|
|
{
|
1999-03-27 17:56:13 +01:00
|
|
|
ICOM_THIS(IDirect3DDeviceImpl,iface);
|
|
|
|
/* OpenGL_IDirect3DDevice *odev = (OpenGL_IDirect3DDevice *) This; */
|
1999-01-03 18:00:19 +01:00
|
|
|
|
1999-06-26 21:09:08 +02:00
|
|
|
FIXME("(%p)->(): stub\n", This);
|
1999-01-03 18:00:19 +01:00
|
|
|
|
|
|
|
/* We get the pointer to the surface (should be done on flip) */
|
1999-03-27 17:56:13 +01:00
|
|
|
/* odev->zb->pbuf = This->surface->s.surface_desc.y.lpSurface; */
|
1999-01-03 18:00:19 +01:00
|
|
|
|
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* This is for the moment copy-pasted from IDirect3DDevice2...
|
|
|
|
Will make a common function ... */
|
2000-04-09 16:30:50 +02:00
|
|
|
static HRESULT WINAPI MESA_IDirect3DDeviceImpl_EndScene(LPDIRECT3DDEVICE iface)
|
1999-01-03 18:00:19 +01:00
|
|
|
{
|
1999-03-27 17:56:13 +01:00
|
|
|
ICOM_THIS(IDirect3DDeviceImpl,iface);
|
1999-05-13 20:53:05 +02:00
|
|
|
#ifdef USE_OSMESA
|
2000-04-09 16:30:50 +02:00
|
|
|
D3DDPRIVATE(This);
|
1999-03-27 17:56:13 +01:00
|
|
|
LPDIRECTDRAWSURFACE3 surf = (LPDIRECTDRAWSURFACE3) This->surface;
|
1999-01-03 18:00:19 +01:00
|
|
|
DDSURFACEDESC sdesc;
|
|
|
|
int x,y;
|
|
|
|
unsigned char *src;
|
|
|
|
unsigned short *dest;
|
1999-05-13 20:53:05 +02:00
|
|
|
#endif
|
1999-01-03 18:00:19 +01:00
|
|
|
|
1999-06-26 21:09:08 +02:00
|
|
|
FIXME("(%p)->(): stub\n", This);
|
1999-01-03 18:00:19 +01:00
|
|
|
|
1999-05-13 20:53:05 +02:00
|
|
|
#ifdef USE_OSMESA
|
1999-01-03 18:00:19 +01:00
|
|
|
/* Here we copy back the OpenGL scene to the the DDraw surface */
|
|
|
|
/* First, lock the surface */
|
1999-03-27 17:56:13 +01:00
|
|
|
IDirectDrawSurface3_Lock(surf,NULL,&sdesc,DDLOCK_WRITEONLY,0);
|
1999-01-03 18:00:19 +01:00
|
|
|
|
|
|
|
/* The copy the OpenGL buffer to this surface */
|
|
|
|
|
|
|
|
/* NOTE : this is only for debugging purpose. I KNOW it is really unoptimal.
|
|
|
|
I am currently working on a set of patches for Mesa to have OSMesa support
|
|
|
|
16 bpp surfaces => we will able to render directly onto the surface, no
|
|
|
|
need to do a bpp conversion */
|
|
|
|
dest = (unsigned short *) sdesc.y.lpSurface;
|
|
|
|
src = ((unsigned char *) odev->buffer) + 4 * (sdesc.dwWidth * (sdesc.dwHeight - 1));
|
|
|
|
for (y = 0; y < sdesc.dwHeight; y++) {
|
|
|
|
unsigned char *lsrc = src;
|
|
|
|
|
|
|
|
for (x = 0; x < sdesc.dwWidth ; x++) {
|
|
|
|
unsigned char r = *lsrc++;
|
|
|
|
unsigned char g = *lsrc++;
|
|
|
|
unsigned char b = *lsrc++;
|
|
|
|
lsrc++; /* Alpha */
|
1999-01-23 13:32:46 +01:00
|
|
|
|
1999-01-03 18:00:19 +01:00
|
|
|
*dest = ((r >> 3) << 11) | ((g >> 2) << 5) | (b >> 3);
|
|
|
|
|
|
|
|
dest++;
|
|
|
|
}
|
|
|
|
|
|
|
|
src -= 4 * sdesc.dwWidth;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Unlock the surface */
|
1999-03-27 17:56:13 +01:00
|
|
|
IDirectDrawSurface3_Unlock(surf,sdesc.y.lpSurface);
|
1999-05-13 20:53:05 +02:00
|
|
|
#else
|
|
|
|
/* No need to do anything here... */
|
|
|
|
#endif
|
1999-01-03 18:00:19 +01:00
|
|
|
|
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* Direct3DDevice VTable
|
|
|
|
*/
|
2000-04-09 16:30:50 +02:00
|
|
|
ICOM_VTABLE(IDirect3DDevice) OpenGL_vtable_dx3 =
|
1999-05-22 13:41:38 +02:00
|
|
|
{
|
|
|
|
ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
|
1999-03-27 17:56:13 +01:00
|
|
|
IDirect3DDeviceImpl_QueryInterface,
|
|
|
|
IDirect3DDeviceImpl_AddRef,
|
2000-04-09 16:30:50 +02:00
|
|
|
MESA_IDirect3DDeviceImpl_Release,
|
1999-03-27 17:56:13 +01:00
|
|
|
IDirect3DDeviceImpl_Initialize,
|
|
|
|
IDirect3DDeviceImpl_GetCaps,
|
|
|
|
IDirect3DDeviceImpl_SwapTextureHandles,
|
2000-04-10 15:45:17 +02:00
|
|
|
MESA_IDirect3DDeviceImpl_CreateExecuteBuffer,
|
1999-03-27 17:56:13 +01:00
|
|
|
IDirect3DDeviceImpl_GetStats,
|
|
|
|
IDirect3DDeviceImpl_Execute,
|
|
|
|
IDirect3DDeviceImpl_AddViewport,
|
|
|
|
IDirect3DDeviceImpl_DeleteViewport,
|
|
|
|
IDirect3DDeviceImpl_NextViewport,
|
|
|
|
IDirect3DDeviceImpl_Pick,
|
|
|
|
IDirect3DDeviceImpl_GetPickRecords,
|
2000-04-09 16:30:50 +02:00
|
|
|
MESA_IDirect3DDeviceImpl_EnumTextureFormats,
|
1999-03-27 17:56:13 +01:00
|
|
|
IDirect3DDeviceImpl_CreateMatrix,
|
|
|
|
IDirect3DDeviceImpl_SetMatrix,
|
|
|
|
IDirect3DDeviceImpl_GetMatrix,
|
|
|
|
IDirect3DDeviceImpl_DeleteMatrix,
|
2000-04-09 16:30:50 +02:00
|
|
|
MESA_IDirect3DDeviceImpl_BeginScene,
|
|
|
|
MESA_IDirect3DDeviceImpl_EndScene,
|
1999-03-27 17:56:13 +01:00
|
|
|
IDirect3DDeviceImpl_GetDirect3D,
|
1999-01-03 18:00:19 +01:00
|
|
|
};
|