Commit b44822a4 authored by Christian Costa's avatar Christian Costa Committed by Alexandre Julliard

Associate texture to the device when GetHandle is called and perform

the appropriate AddRef/Release. Fix 3_3_2 pixel format. Move some ENTER_GL() calls to the right place. Fix some FIXME/TRACE calls.
parent da9bac4d
......@@ -358,6 +358,7 @@ struct IDirect3DDeviceImpl
IDirect3DViewport2Impl* viewport_list;
IDirect3DViewport2Impl* current_viewport;
IDirect3DTexture2Impl* current_texture;
void (*set_context)(IDirect3DDeviceImpl*);
LPVOID private;
......@@ -377,6 +378,7 @@ struct IDirect3DDevice2Impl
IDirect3DViewport2Impl* viewport_list;
IDirect3DViewport2Impl* current_viewport;
IDirect3DTexture2Impl* current_texture;
void (*set_context)(IDirect3DDevice2Impl*);
LPVOID private;
......
......@@ -58,9 +58,13 @@ ULONG WINAPI IDirect3DDevice2Impl_AddRef(LPDIRECT3DDEVICE2 iface)
ULONG WINAPI IDirect3DDevice2Impl_Release(LPDIRECT3DDEVICE2 iface)
{
ICOM_THIS(IDirect3DDevice2Impl,iface);
FIXME("(%p)->() decrementing from %lu.\n", This, This->ref );
TRACE("(%p)->() decrementing from %lu.\n", This, This->ref );
if (!--(This->ref)) {
/* Release texture associated with the device */
if (This->current_texture)
IDirect3DTexture2Impl_Release((LPDIRECT3DTEXTURE2)This->current_texture);
HeapFree(GetProcessHeap(),0,This);
return 0;
}
......@@ -108,7 +112,7 @@ HRESULT WINAPI IDirect3DDevice2Impl_AddViewport(
) {
ICOM_THIS(IDirect3DDevice2Impl,iface);
IDirect3DViewport2Impl* ilpvp=(IDirect3DViewport2Impl*)lpvp;
FIXME("(%p)->(%p): stub\n", This, ilpvp);
TRACE("(%p)->(%p)\n", This, ilpvp);
/* Adds this viewport to the viewport list */
ilpvp->next = This->viewport_list;
......@@ -123,7 +127,7 @@ HRESULT WINAPI IDirect3DDevice2Impl_DeleteViewport(
ICOM_THIS(IDirect3DDevice2Impl,iface);
IDirect3DViewport2Impl* ilpvp=(IDirect3DViewport2Impl*)lpvp;
IDirect3DViewport2Impl *cur, *prev;
FIXME("(%p)->(%p): stub\n", This, lpvp);
TRACE("(%p)->(%p)\n", This, lpvp);
/* Finds this viewport in the list */
prev = NULL;
......@@ -150,7 +154,7 @@ HRESULT WINAPI IDirect3DDevice2Impl_NextViewport(
ICOM_THIS(IDirect3DDevice2Impl,iface);
IDirect3DViewport2Impl* ilpvp=(IDirect3DViewport2Impl*)lpvp;
IDirect3DViewport2Impl** ilplpvp=(IDirect3DViewport2Impl**)lplpvp;
FIXME("(%p)->(%p,%p,%08lx): stub\n", This, lpvp, lpvp, dwFlags);
TRACE("(%p)->(%p,%p,%08lx)\n", This, lpvp, lpvp, dwFlags);
switch (dwFlags) {
case D3DNEXT_NEXT:
......@@ -204,7 +208,7 @@ HRESULT WINAPI IDirect3DDevice2Impl_GetDirect3D(
LPDIRECT3DDEVICE2 iface, LPDIRECT3D2 *lpd3d2
) {
ICOM_THIS(IDirect3DDevice2Impl,iface);
TRACE("(%p)->(%p): stub\n", This, lpd3d2);
TRACE("(%p)->(%p)\n", This, lpd3d2);
*lpd3d2 = (LPDIRECT3D2)This->d3d;
return DD_OK;
}
......@@ -215,7 +219,7 @@ HRESULT WINAPI IDirect3DDevice2Impl_SetCurrentViewport(
) {
ICOM_THIS(IDirect3DDevice2Impl,iface);
IDirect3DViewport2Impl* ilpvp=(IDirect3DViewport2Impl*)lpvp;
FIXME("(%p)->(%p): stub\n", This, ilpvp);
TRACE("(%p)->(%p)\n", This, ilpvp);
/* Should check if the viewport was added or not */
......@@ -256,7 +260,7 @@ HRESULT WINAPI IDirect3DDevice2Impl_GetRenderTarget(
LPDIRECT3DDEVICE2 iface, LPDIRECTDRAWSURFACE *lplpdds
) {
ICOM_THIS(IDirect3DDevice2Impl,iface);
FIXME("(%p)->(%p): stub\n", This, lplpdds);
TRACE("(%p)->(%p)\n", This, lplpdds);
/* Returns the current rendering target (the surface on wich we render) */
*lplpdds = (LPDIRECTDRAWSURFACE)This->surface;
......@@ -385,7 +389,7 @@ HRESULT WINAPI IDirect3DDevice2Impl_DrawPrimitive(
) {
ICOM_THIS(IDirect3DDevice2Impl,iface);
TRACE("(%p)->(%d,%d,%p,%ld,%08lx): stub\n", This, d3dp, d3dv, lpvertex, vertcount, dwFlags);
FIXME("(%p)->(%d,%d,%p,%ld,%08lx): stub\n", This, d3dp, d3dv, lpvertex, vertcount, dwFlags);
return D3D_OK;
}
......@@ -396,7 +400,7 @@ HRESULT WINAPI IDirect3DDevice2Impl_DrawIndexedPrimitive(
DWORD dwFlags
) {
ICOM_THIS(IDirect3DDevice2Impl,iface);
TRACE("(%p)->(%d,%d,%p,%ld,%p,%ld,%08lx): stub\n", This, d3dp, d3dv, lpvertex, vertcount, lpindexes, indexcount, dwFlags);
FIXME("(%p)->(%d,%d,%p,%ld,%p,%ld,%08lx): stub\n", This, d3dp, d3dv, lpvertex, vertcount, lpindexes, indexcount, dwFlags);
return D3D_OK;
}
......@@ -440,9 +444,13 @@ ULONG WINAPI IDirect3DDeviceImpl_AddRef(LPDIRECT3DDEVICE iface)
ULONG WINAPI IDirect3DDeviceImpl_Release(LPDIRECT3DDEVICE iface)
{
ICOM_THIS(IDirect3DDeviceImpl,iface);
FIXME("(%p)->() decrementing from %lu.\n", This, This->ref );
TRACE("(%p)->() decrementing from %lu.\n", This, This->ref );
if (!--(This->ref)) {
/* Release texture associated with the device */
if (This->current_texture)
IDirect3DTexture2Impl_Release((LPDIRECT3DTEXTURE2)This->current_texture);
HeapFree(GetProcessHeap(),0,This);
return 0;
}
......@@ -454,7 +462,7 @@ HRESULT WINAPI IDirect3DDeviceImpl_Initialize(
LPD3DDEVICEDESC lpd3ddvdesc
) {
ICOM_THIS(IDirect3DDeviceImpl,iface);
TRACE("(%p)->(%p,%p,%p): stub\n", This, lpd3d,lpGUID, lpd3ddvdesc);
FIXME("(%p)->(%p,%p,%p): stub\n", This, lpd3d,lpGUID, lpd3ddvdesc);
return DDERR_ALREADYINITIALIZED;
}
......@@ -465,7 +473,7 @@ HRESULT WINAPI IDirect3DDeviceImpl_GetCaps(
LPD3DDEVICEDESC lpD3DSWDevDesc
) {
ICOM_THIS(IDirect3DDeviceImpl,iface);
TRACE("(%p)->(%p,%p): stub\n", This, lpD3DHWDevDesc, lpD3DSWDevDesc);
FIXME("(%p)->(%p,%p): stub\n", This, lpD3DHWDevDesc, lpD3DSWDevDesc);
return DD_OK;
}
......@@ -499,7 +507,7 @@ HRESULT WINAPI IDirect3DDeviceImpl_GetStats(
LPDIRECT3DDEVICE iface, LPD3DSTATS lpD3DStats
) {
ICOM_THIS(IDirect3DDeviceImpl,iface);
TRACE("(%p)->(%p): stub\n", This, lpD3DStats);
FIXME("(%p)->(%p): stub\n", This, lpD3DStats);
return DD_OK;
}
......@@ -510,7 +518,7 @@ HRESULT WINAPI IDirect3DDeviceImpl_Execute(
LPDIRECT3DVIEWPORT lpDirect3DViewport, DWORD dwFlags
) {
ICOM_THIS(IDirect3DDeviceImpl,iface);
TRACE("(%p)->(%p,%p,%08ld): stub\n", This, lpDirect3DExecuteBuffer, lpDirect3DViewport, dwFlags);
TRACE("(%p)->(%p,%p,%08ld)\n", This, lpDirect3DExecuteBuffer, lpDirect3DViewport, dwFlags);
/* Put this as the default context */
......@@ -525,7 +533,7 @@ HRESULT WINAPI IDirect3DDeviceImpl_AddViewport(
) {
ICOM_THIS(IDirect3DDeviceImpl,iface);
IDirect3DViewport2Impl* ilpvp=(IDirect3DViewport2Impl*)lpvp;
FIXME("(%p)->(%p): stub\n", This, ilpvp);
TRACE("(%p)->(%p)\n", This, ilpvp);
/* Adds this viewport to the viewport list */
ilpvp->next = This->viewport_list;
......@@ -542,7 +550,7 @@ HRESULT WINAPI IDirect3DDeviceImpl_DeleteViewport(
ICOM_THIS(IDirect3DDeviceImpl,iface);
IDirect3DViewport2Impl* ilpvp=(IDirect3DViewport2Impl*)lpvp;
IDirect3DViewport2Impl *cur, *prev;
FIXME("(%p)->(%p): stub\n", This, lpvp);
TRACE("(%p)->(%p)\n", This, lpvp);
/* Finds this viewport in the list */
prev = NULL;
......@@ -569,7 +577,7 @@ HRESULT WINAPI IDirect3DDeviceImpl_NextViewport(
ICOM_THIS(IDirect3DDeviceImpl,iface);
IDirect3DViewport2Impl* ilpvp=(IDirect3DViewport2Impl*)lpvp;
IDirect3DViewport2Impl** ilplpvp=(IDirect3DViewport2Impl**)lplpvp;
FIXME("(%p)->(%p,%p,%08lx): stub\n", This, ilpvp, ilplpvp, dwFlags);
TRACE("(%p)->(%p,%p,%08lx)\n", This, ilpvp, ilplpvp, dwFlags);
switch (dwFlags) {
case D3DNEXT_NEXT:
......@@ -603,7 +611,7 @@ HRESULT WINAPI IDirect3DDeviceImpl_GetPickRecords(
LPDIRECT3DDEVICE iface, LPDWORD lpCount, LPD3DPICKRECORD lpD3DPickRec
) {
ICOM_THIS(IDirect3DDeviceImpl,iface);
TRACE("(%p)->(%p,%p): stub\n", This, lpCount, lpD3DPickRec);
FIXME("(%p)->(%p,%p): stub\n", This, lpCount, lpD3DPickRec);
return DD_OK;
}
......@@ -614,7 +622,7 @@ HRESULT WINAPI IDirect3DDeviceImpl_EnumTextureFormats(
LPVOID lpArg
) {
ICOM_THIS(IDirect3DDeviceImpl,iface);
TRACE("(%p)->(%p,%p): stub\n", This, lpd3dEnumTextureProc, lpArg);
FIXME("(%p)->(%p,%p): stub\n", This, lpd3dEnumTextureProc, lpArg);
return D3D_OK;
}
......@@ -687,7 +695,7 @@ HRESULT WINAPI IDirect3DDeviceImpl_GetDirect3D(
LPDIRECT3DDEVICE iface, LPDIRECT3D *lpDirect3D
) {
ICOM_THIS(IDirect3DDeviceImpl,iface);
TRACE("(%p)->(%p): stub\n", This, lpDirect3D);
FIXME("(%p)->(%p): stub\n", This, lpDirect3D);
return DD_OK;
}
......
......@@ -225,6 +225,7 @@ is_OpenGL(
(*device)->surface = surface;
(*device)->viewport_list = NULL;
(*device)->current_viewport = NULL;
(*device)->current_texture = NULL;
(*device)->set_context = set_context;
TRACE("Creating OpenGL device for surface %p\n", surface);
......@@ -401,10 +402,10 @@ static HRESULT enum_texture_format_OpenGL(LPD3DENUMTEXTUREFORMATSCALLBACK cb,
TRACE("Enumerating GL_RGB packed GL_UNSIGNED_BYTE_3_3_2 (8)\n");
pformat->dwFlags = DDPF_RGB;
pformat->u1.dwRGBBitCount = 8;
pformat->u2.dwRBitMask = 0x0000F800;
pformat->u3.dwGBitMask = 0x000007C0;
pformat->u4.dwBBitMask = 0x0000003E;
pformat->u5.dwRGBAlphaBitMask = 0x00000001;
pformat->u2.dwRBitMask = 0x000000E0;
pformat->u3.dwGBitMask = 0x0000001C;
pformat->u4.dwBBitMask = 0x00000003;
pformat->u5.dwRGBAlphaBitMask = 0x00000000;
if (cb(&sdesc, context) == 0)
return DD_OK;
#endif
......@@ -891,6 +892,7 @@ int is_OpenGL_dx3(REFCLSID rguid, IDirectDrawSurfaceImpl* surface, IDirect3DDevi
(*device)->viewport_list = NULL;
(*device)->current_viewport = NULL;
(*device)->current_texture = NULL;
(*device)->set_context = (void*)set_context;
......
......@@ -298,13 +298,20 @@ HRESULT WINAPI IDirect3DTextureImpl_GetHandle(LPDIRECT3DTEXTURE iface,
*lpHandle = (D3DTEXTUREHANDLE) This;
/* Now, bind a new texture */
ENTER_GL();
ilpD3DDevice->set_context(ilpD3DDevice);
This->D3Ddevice = (void *) ilpD3DDevice;
ENTER_GL();
if (dtpriv->tex_name == 0)
glGenTextures(1, &(dtpriv->tex_name));
LEAVE_GL();
/* Associate the texture with the device and perform the appropriate AddRef/Release */
/* FIXME: Is there only one or several textures associated with the device ? */
if (ilpD3DDevice->current_texture)
IDirect3DTexture2Impl_Release((LPDIRECT3DTEXTURE2)ilpD3DDevice->current_texture);
IDirect3DTexture2Impl_AddRef((LPDIRECT3DTEXTURE2)iface);
ilpD3DDevice->current_texture = (IDirect3DTexture2Impl*)iface;
TRACE("OpenGL texture handle is : %d\n", dtpriv->tex_name);
return D3D_OK;
......@@ -342,13 +349,20 @@ HRESULT WINAPI IDirect3DTexture2Impl_GetHandle(LPDIRECT3DTEXTURE2 iface,
*lpHandle = (D3DTEXTUREHANDLE) This;
/* Now, bind a new texture */
ENTER_GL();
ilpD3DDevice2->set_context(ilpD3DDevice2);
This->D3Ddevice = (void *) ilpD3DDevice2;
ENTER_GL();
if (dtpriv->tex_name == 0)
glGenTextures(1, &(dtpriv->tex_name));
LEAVE_GL();
/* Associate the texture with the device and perform the appropriate AddRef/Release */
/* FIXME: Is there only one or several textures associated with the device ? */
if (ilpD3DDevice2->current_texture)
IDirect3DTexture2Impl_Release((LPDIRECT3DTEXTURE2)ilpD3DDevice2->current_texture);
IDirect3DTexture2Impl_AddRef(iface);
ilpD3DDevice2->current_texture = (IDirect3DTexture2Impl*)iface;
TRACE("OpenGL texture handle is : %d\n", dtpriv->tex_name);
return D3D_OK;
......@@ -430,7 +444,7 @@ HRESULT WINAPI IDirect3DTexture2Impl_Load(
/* ****************
Paletted Texture
**************** */
IDirectDrawPaletteImpl* pal = This->surface->palette;
IDirectDrawPaletteImpl* pal = ilpD3DTexture2->surface->palette;
BYTE table[256][4];
int i;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment