Commit 89ec35fe authored by Raphael Junqueira's avatar Raphael Junqueira Committed by Alexandre Julliard

- minor COM fixes (fixes some crashes on stupid games)

- minor indentation changes - fix SELECTARG2 behavior (with help from Lionel Ulmer) - surface locking/unlocking (only rendering and textures surfaces supported now) - beginning of Target/Front surface support - try to get D3DTOP_SELECTARG_* working - implemented D3DTOP_SUBTRACT: currently only if OpenGL1.3 is used, we have to use GL_SUBTRACT_ARB for other versions
parent ebc9abd1
......@@ -247,6 +247,7 @@ struct IDirect3DDevice8Impl
/* IDirect3DDevice8 fields */
IDirect3D8Impl *direct3d8;
IDirect3DSurface8Impl *frontBuffer;
IDirect3DSurface8Impl *backBuffer;
IDirect3DSurface8Impl *depthStencilBuffer;
D3DPRESENT_PARAMETERS PresentParms;
......@@ -413,7 +414,7 @@ struct IDirect3DVolume8Impl
IDirect3DDevice8Impl *Device;
D3DRESOURCETYPE ResourceType;
void *Container;
IUnknown *Container;
D3DVOLUME_DESC myDesc;
BYTE *allocatedMemory;
UINT textureName;
......@@ -493,6 +494,9 @@ struct IDirect3DSurface8Impl
BYTE *allocatedMemory;
UINT textureName;
UINT bytesPerPixel;
BOOL lockable;
BOOL locked;
RECT lockedRect;
};
/* IUnknown: */
......@@ -721,7 +725,6 @@ struct IDirect3DCubeTexture8Impl
UINT levels;
D3DFORMAT format;
IDirect3DDevice8Impl *device;
IDirect3DSurface8Impl *surfaces[6][MAX_LEVELS];
BOOL Dirty;
};
......@@ -848,7 +851,6 @@ struct IDirect3DVolumeTexture8Impl
DWORD usage;
D3DFORMAT format;
IDirect3DDevice8Impl *device;
IDirect3DVolume8Impl *volumes[MAX_LEVELS];
BOOL Dirty;
};
......
......@@ -378,15 +378,14 @@ HRESULT WINAPI IDirect3D8Impl_GetDeviceCaps (LPDIRECT3D8 iface,
{
GLint gl_max;
#if defined(GL_VERSION_1_3)
glGetIntegerv(GL_MAX_TEXTURE_UNITS, &gl_max);
#else
glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, &gl_max);
#endif
TRACE("GLCaps: GL_MAX_TEXTURE_UNITS_ARB=%d\n", gl_max);
pCaps->MaxTextureBlendStages = min(8, gl_max);
pCaps->MaxSimultaneousTextures = min(8, gl_max);
TRACE("GLCaps: GL_MAX_TEXTURE_UNITS_ARB=%ld\n", pCaps->MaxTextureBlendStages);
glGetIntegerv(GL_MAX_CLIP_PLANES, &gl_max);
pCaps->MaxUserClipPlanes = min(MAX_CLIPPLANES, gl_max);
......@@ -563,18 +562,27 @@ HRESULT WINAPI IDirect3D8Impl_CreateDevice (LPDIRECT3D8 iface,
}
}
IDirect3DDevice8Impl_CreateImageSurface((LPDIRECT3DDEVICE8) object,
IDirect3DDevice8Impl_CreateRenderTarget((LPDIRECT3DDEVICE8) object,
pPresentationParameters->BackBufferWidth,
pPresentationParameters->BackBufferHeight,
pPresentationParameters->BackBufferFormat,
D3DMULTISAMPLE_NONE, TRUE,
(LPDIRECT3DSURFACE8*) &object->frontBuffer);
IDirect3DDevice8Impl_CreateRenderTarget((LPDIRECT3DDEVICE8) object,
pPresentationParameters->BackBufferWidth,
pPresentationParameters->BackBufferHeight,
pPresentationParameters->BackBufferFormat,
D3DMULTISAMPLE_NONE, TRUE,
(LPDIRECT3DSURFACE8*) &object->backBuffer);
if (pPresentationParameters->EnableAutoDepthStencil)
IDirect3DDevice8Impl_CreateImageSurface((LPDIRECT3DDEVICE8) object,
pPresentationParameters->BackBufferWidth,
pPresentationParameters->BackBufferHeight,
pPresentationParameters->AutoDepthStencilFormat,
(LPDIRECT3DSURFACE8*) &object->depthStencilBuffer);
IDirect3DDevice8Impl_CreateDepthStencilSurface((LPDIRECT3DDEVICE8) object,
pPresentationParameters->BackBufferWidth,
pPresentationParameters->BackBufferHeight,
pPresentationParameters->AutoDepthStencilFormat,
D3DMULTISAMPLE_NONE,
(LPDIRECT3DSURFACE8*) &object->depthStencilBuffer);
/* Now override the surface's Flip method (if in double buffering) ?COPIED from DDRAW!?
((x11_ds_private *) surface->private)->opengl_flip = TRUE;
......
......@@ -69,6 +69,7 @@ HRESULT WINAPI IDirect3DIndexBuffer8Impl_GetDevice(LPDIRECT3DINDEXBUFFER
ICOM_THIS(IDirect3DIndexBuffer8Impl,iface);
TRACE("(%p) : returning %p\n", This, This->Device);
*ppDevice = (LPDIRECT3DDEVICE8) This->Device;
IDirect3DDevice8Impl_AddRef(*ppDevice);
return D3D_OK;
}
HRESULT WINAPI IDirect3DIndexBuffer8Impl_SetPrivateData(LPDIRECT3DINDEXBUFFER8 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
......
......@@ -66,6 +66,7 @@ HRESULT WINAPI IDirect3DResource8Impl_GetDevice(LPDIRECT3DRESOURCE8 ifac
ICOM_THIS(IDirect3DResource8Impl,iface);
TRACE("(%p) : returning %p\n", This, This->Device);
*ppDevice = (LPDIRECT3DDEVICE8) This->Device;
IDirect3DDevice8Impl_AddRef(*ppDevice);
return D3D_OK;
}
HRESULT WINAPI IDirect3DResource8Impl_SetPrivateData(LPDIRECT3DRESOURCE8 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
......
......@@ -200,9 +200,13 @@ HRESULT WINAPI IDirect3DDeviceImpl_InitStartupStateBlock(IDirect3DDevice8Impl* T
/* Make appropriate texture active */
if (This->isMultiTexture) {
#if defined(GL_VERSION_1_3)
glActiveTexture(GL_TEXTURE0 + i);
#else
glActiveTextureARB(GL_TEXTURE0_ARB + i);
#endif
checkGLcall("glActiveTextureARB");
} else if (i>0) {
} else if (i > 0) {
FIXME("Program using multiple concurrent textures which this opengl implementation doesnt support\n");
}
......@@ -241,7 +245,7 @@ HRESULT WINAPI IDirect3DDeviceImpl_CreateStateBlock(IDirect3DDevice8Impl* This,
if (object) {
if (NULL == This->StateBlock) { /** if it the main stateblock only do init and returns */
/*object->lpVtbl = &Direct3DStateBlock9_Vtbl;*/
object->device = This; /* FIXME: AddRef(This) */
object->device = This;
object->ref = 1;
object->blockType = Type;
This->StateBlock = object;
......@@ -254,7 +258,7 @@ HRESULT WINAPI IDirect3DDeviceImpl_CreateStateBlock(IDirect3DDevice8Impl* This,
return E_OUTOFMEMORY;
}
/*object->lpVtbl = &Direct3DStateBlock9_Vtbl;*/
object->device = This; /* FIXME: AddRef(This) */
object->device = This;
object->ref = 1;
object->blockType = Type;
......@@ -331,7 +335,7 @@ HRESULT WINAPI IDirect3DDeviceImpl_BeginStateBlock(IDirect3DDevice8Impl* This) {
return E_OUTOFMEMORY;
}
/*object->lpVtbl = &Direct3DVextexShaderDeclaration8_Vtbl;*/
object->device = This; /* FIXME: AddRef(This) */
object->device = This;
object->ref = 1;
This->isRecordingState = TRUE;
......@@ -350,7 +354,7 @@ HRESULT WINAPI IDirect3DDeviceImpl_EndStateBlock(IDirect3DDevice8Impl* This, IDi
}
This->UpdateStateBlock->blockType = D3DSBT_RECORDED;
*ppStateBlock = This->UpdateStateBlock;
*ppStateBlock = This->UpdateStateBlock; /* FIXME: AddRef() */
This->isRecordingState = FALSE;
This->UpdateStateBlock = This->StateBlock;
......@@ -369,7 +373,7 @@ HRESULT WINAPI IDirect3DDeviceImpl_ApplyStateBlock(IDirect3DDevice8Impl* This,
if (pSB->blockType == D3DSBT_RECORDED || pSB->blockType == D3DSBT_ALL || pSB->blockType == D3DSBT_VERTEXSTATE) {
for (i=0; i<This->maxLights; i++) {
for (i = 0; i < This->maxLights; i++) {
if (pSB->Set.lightEnable[i] && pSB->Changed.lightEnable[i])
IDirect3DDevice8Impl_LightEnable(iface, i, pSB->lightEnable[i]);
......@@ -393,7 +397,7 @@ HRESULT WINAPI IDirect3DDeviceImpl_ApplyStateBlock(IDirect3DDevice8Impl* This,
/* Others + Render & Texture */
if (pSB->blockType == D3DSBT_RECORDED || pSB->blockType == D3DSBT_ALL) {
for (i=0; i<HIGHEST_TRANSFORMSTATE; i++) {
for (i = 0; i < HIGHEST_TRANSFORMSTATE; i++) {
if (pSB->Set.transform[i] && pSB->Changed.transform[i])
IDirect3DDevice8Impl_SetTransform(iface, i, &pSB->transforms[i]);
}
......@@ -412,7 +416,7 @@ HRESULT WINAPI IDirect3DDeviceImpl_ApplyStateBlock(IDirect3DDevice8Impl* This,
IDirect3DDevice8Impl_SetStreamSource(iface, i, pSB->stream_source[i], pSB->stream_stride[i]);
}
for (i=0; i<This->clipPlanes; i++) {
for (i = 0; i < This->clipPlanes; i++) {
if (pSB->Set.clipplane[i] && pSB->Changed.clipplane[i]) {
float clip[4];
......@@ -425,11 +429,9 @@ HRESULT WINAPI IDirect3DDeviceImpl_ApplyStateBlock(IDirect3DDevice8Impl* This,
}
/* Render */
for (i=0; i<HIGHEST_RENDER_STATE; i++) {
for (i = 0; i < HIGHEST_RENDER_STATE; i++) {
if (pSB->Set.renderstate[i] && pSB->Changed.renderstate[i])
IDirect3DDevice8Impl_SetRenderState(iface, i, pSB->renderstate[i]);
}
/* Texture */
......@@ -447,15 +449,14 @@ HRESULT WINAPI IDirect3DDeviceImpl_ApplyStateBlock(IDirect3DDevice8Impl* This,
} else if (pSB->blockType == D3DSBT_PIXELSTATE) {
for (i=0; i<NUM_SAVEDPIXELSTATES_R; i++) {
for (i = 0; i < NUM_SAVEDPIXELSTATES_R; i++) {
if (pSB->Set.renderstate[SavedPixelStates_R[i]] && pSB->Changed.renderstate[SavedPixelStates_R[i]])
IDirect3DDevice8Impl_SetRenderState(iface, SavedPixelStates_R[i], pSB->renderstate[SavedPixelStates_R[i]]);
}
for (j=0; j<This->TextureUnits; i++) {
for (i=0; i<NUM_SAVEDPIXELSTATES_T; i++) {
for (j = 0; j < This->TextureUnits; i++) {
for (i = 0; i < NUM_SAVEDPIXELSTATES_T; i++) {
if (pSB->Set.texture_state[j][SavedPixelStates_T[i]] &&
pSB->Changed.texture_state[j][SavedPixelStates_T[i]])
IDirect3DDevice8Impl_SetTextureStageState(iface, j, SavedPixelStates_T[i], pSB->texture_state[j][SavedPixelStates_T[i]]);
......@@ -464,15 +465,13 @@ HRESULT WINAPI IDirect3DDeviceImpl_ApplyStateBlock(IDirect3DDevice8Impl* This,
} else if (pSB->blockType == D3DSBT_VERTEXSTATE) {
for (i=0; i<NUM_SAVEDVERTEXSTATES_R; i++) {
for (i = 0; i < NUM_SAVEDVERTEXSTATES_R; i++) {
if (pSB->Set.renderstate[SavedVertexStates_R[i]] && pSB->Changed.renderstate[SavedVertexStates_R[i]])
IDirect3DDevice8Impl_SetRenderState(iface, SavedVertexStates_R[i], pSB->renderstate[SavedVertexStates_R[i]]);
}
for (j=0; j<This->TextureUnits; i++) {
for (i=0; i<NUM_SAVEDVERTEXSTATES_T; i++) {
for (j = 0; j < This->TextureUnits; i++) {
for (i = 0; i < NUM_SAVEDVERTEXSTATES_T; i++) {
if (pSB->Set.texture_state[j][SavedVertexStates_T[i]] &&
pSB->Changed.texture_state[j][SavedVertexStates_T[i]])
IDirect3DDevice8Impl_SetTextureStageState(iface, j, SavedVertexStates_T[i], pSB->texture_state[j][SavedVertexStates_T[i]]);
......@@ -505,7 +504,7 @@ HRESULT WINAPI IDirect3DDeviceImpl_CaptureStateBlock(IDirect3DDevice8Impl* This,
across this action */
} else {
int i,j;
int i, j;
/* Recorded => Only update 'changed' values */
if (updateBlock->Set.vertexShader && updateBlock->VertexShader != This->StateBlock->VertexShader) {
......@@ -515,7 +514,7 @@ HRESULT WINAPI IDirect3DDeviceImpl_CaptureStateBlock(IDirect3DDevice8Impl* This,
/* TODO: Vertex Shader Constants */
for (i=0; i<This->maxLights; i++) {
for (i = 0; i < This->maxLights; i++) {
if (updateBlock->Set.lightEnable[i] && This->StateBlock->lightEnable[i] != updateBlock->lightEnable[i]) {
TRACE("Updating light enable for light %d to %d\n", i, This->StateBlock->lightEnable[i]);
updateBlock->lightEnable[i] = This->StateBlock->lightEnable[i];
......@@ -538,7 +537,7 @@ HRESULT WINAPI IDirect3DDeviceImpl_CaptureStateBlock(IDirect3DDevice8Impl* This,
/* TODO: Pixel Shader Constants */
/* Others + Render & Texture */
for (i=0; i<HIGHEST_TRANSFORMSTATE; i++) {
for (i = 0; i < HIGHEST_TRANSFORMSTATE; i++) {
if (updateBlock->Set.transform[i] && memcmp(&This->StateBlock->transforms[i],
&updateBlock->transforms[i],
sizeof(D3DMATRIX)) != 0) {
......@@ -569,7 +568,7 @@ HRESULT WINAPI IDirect3DDeviceImpl_CaptureStateBlock(IDirect3DDevice8Impl* This,
memcpy(&updateBlock->viewport, &This->StateBlock->viewport, sizeof(D3DVIEWPORT8));
}
for (i=0; i<MAX_STREAMS; i++) {
for (i = 0; i < MAX_STREAMS; i++) {
if (updateBlock->Set.stream_source[i] &&
((updateBlock->stream_stride[i] != This->StateBlock->stream_stride[i]) ||
(updateBlock->stream_source[i] != This->StateBlock->stream_source[i]))) {
......@@ -580,7 +579,7 @@ HRESULT WINAPI IDirect3DDeviceImpl_CaptureStateBlock(IDirect3DDevice8Impl* This,
}
}
for (i=0; i<This->clipPlanes; i++) {
for (i = 0; i < This->clipPlanes; i++) {
if (updateBlock->Set.clipplane[i] && memcmp(&This->StateBlock->clipplane[i],
&updateBlock->clipplane[i],
sizeof(updateBlock->clipplane)) != 0) {
......@@ -592,7 +591,7 @@ HRESULT WINAPI IDirect3DDeviceImpl_CaptureStateBlock(IDirect3DDevice8Impl* This,
}
/* Render */
for (i=0; i<HIGHEST_RENDER_STATE; i++) {
for (i = 0; i < HIGHEST_RENDER_STATE; i++) {
if (updateBlock->Set.renderstate[i] && (updateBlock->renderstate[i] !=
This->StateBlock->renderstate[i])) {
......@@ -602,8 +601,8 @@ HRESULT WINAPI IDirect3DDeviceImpl_CaptureStateBlock(IDirect3DDevice8Impl* This,
}
/* Texture */
for (j=0; j<This->TextureUnits; j++) {
for (i=0; i<HIGHEST_TEXTURE_STATE; i++) {
for (j = 0; j < This->TextureUnits; j++) {
for (i = 0; i < HIGHEST_TEXTURE_STATE; i++) {
if (updateBlock->Set.texture_state[j][i] && (updateBlock->texture_state[j][i] !=
This->StateBlock->texture_state[j][i])) {
......
......@@ -30,6 +30,14 @@
WINE_DEFAULT_DEBUG_CHANNEL(d3d);
/* trace: */
#if 1
# define VTRACE(A) FIXME A
#else
# define VTRACE(A)
#endif
/* IDirect3DVolume IUnknown parts follow: */
HRESULT WINAPI IDirect3DSurface8Impl_QueryInterface(LPDIRECT3DSURFACE8 iface,REFIID riid,LPVOID *ppobj)
{
......@@ -57,8 +65,8 @@ ULONG WINAPI IDirect3DSurface8Impl_Release(LPDIRECT3DSURFACE8 iface) {
ULONG ref = --This->ref;
TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref);
if (ref == 0) {
HeapFree(GetProcessHeap(), 0, This->allocatedMemory);
HeapFree(GetProcessHeap(), 0, This);
HeapFree(GetProcessHeap(), 0, This->allocatedMemory);
HeapFree(GetProcessHeap(), 0, This);
}
return ref;
}
......@@ -90,11 +98,6 @@ HRESULT WINAPI IDirect3DSurface8Impl_FreePrivateData(LPDIRECT3DSURFACE8 iface, R
HRESULT WINAPI IDirect3DSurface8Impl_GetContainer(LPDIRECT3DSURFACE8 iface, REFIID riid, void** ppContainer) {
ICOM_THIS(IDirect3DSurface8Impl,iface);
HRESULT res;
/*
TRACE("(%p) : returning %p\n", This, This->Container);
*ppContainer = This->Container;
return D3D_OK;
*/
res = IUnknown_QueryInterface(This->Container, riid, ppContainer);
if (E_NOINTERFACE == res) {
/**
......@@ -114,40 +117,226 @@ HRESULT WINAPI IDirect3DSurface8Impl_GetDesc(LPDIRECT3DSURFACE8 iface, D3DSURFAC
memcpy(pDesc, &This->myDesc, sizeof(D3DSURFACE_DESC));
return D3D_OK;
}
HRESULT WINAPI IDirect3DSurface8Impl_LockRect(LPDIRECT3DSURFACE8 iface, D3DLOCKED_RECT* pLockedRect, CONST RECT* pRect,DWORD Flags) {
HRESULT WINAPI IDirect3DSurface8Impl_LockRect(LPDIRECT3DSURFACE8 iface, D3DLOCKED_RECT* pLockedRect, CONST RECT* pRect, DWORD Flags) {
ICOM_THIS(IDirect3DSurface8Impl,iface);
/* fixme: should we really lock as such? */
if (FALSE == This->lockable) {
ERR("trying to lock unlockable surf@%p\n", This);
return D3DERR_INVALIDCALL;
}
TRACE("(%p) : rect=%p, output prect=%p, allMem=%p\n", This, pRect, pLockedRect, This->allocatedMemory);
pLockedRect->Pitch = This->bytesPerPixel * This->myDesc.Width; /* Bytes / row */
pLockedRect->Pitch = This->bytesPerPixel * This->myDesc.Width; /* Bytes / row */
if (!pRect) {
pLockedRect->pBits = This->allocatedMemory;
pLockedRect->pBits = This->allocatedMemory;
This->lockedRect.left = 0;
This->lockedRect.top = 0;
This->lockedRect.right = This->myDesc.Width;
This->lockedRect.bottom = This->myDesc.Height;
} else {
TRACE("Lock Rect (%p) = l %ld, t %ld, r %ld, b %ld\n", pRect, pRect->left, pRect->top, pRect->right, pRect->bottom);
pLockedRect->pBits = This->allocatedMemory + (pLockedRect->Pitch * pRect->top) + (pRect->left * This->bytesPerPixel);
This->lockedRect.left = pRect->left;
This->lockedRect.top = pRect->top;
This->lockedRect.right = pRect->right;
This->lockedRect.bottom = pRect->bottom;
}
if (0 == This->myDesc.Usage) { /* classic surface */
/* Nothing to do ;) */
} else if (D3DUSAGE_RENDERTARGET & This->myDesc.Usage) { /* render surfaces */
if (This == This->Device->backBuffer || This == This->Device->frontBuffer) {
GLint prev_store;
GLenum prev_read;
ENTER_GL();
/**
* for render->surface copy begin to begin of allocatedMemory
* unlock can be more easy
*/
pLockedRect->pBits = This->allocatedMemory;
glFlush();
vcheckGLcall("glFlush");
glGetIntegerv(GL_READ_BUFFER, &prev_read);
vcheckGLcall("glIntegerv");
glGetIntegerv(GL_PACK_SWAP_BYTES, &prev_store);
vcheckGLcall("glIntegerv");
if (This == This->Device->backBuffer) {
glReadBuffer(GL_BACK);
} else if (This == This->Device->frontBuffer) {
glReadBuffer(GL_FRONT);
}
vcheckGLcall("glReadBuffer");
switch (This->myDesc.Format) {
case D3DFMT_R5G6B5:
{
glReadPixels(This->lockedRect.left, This->lockedRect.top,
This->lockedRect.right - This->lockedRect.left, This->lockedRect.bottom - This->lockedRect.top,
GL_RGB, GL_UNSIGNED_SHORT_5_6_5, pLockedRect->pBits);
vcheckGLcall("glReadPixels");
}
break;
case D3DFMT_R8G8B8:
{
glReadPixels(This->lockedRect.left, This->lockedRect.top,
This->lockedRect.right - This->lockedRect.left, This->lockedRect.bottom - This->lockedRect.top,
GL_RGB, GL_UNSIGNED_BYTE, pLockedRect->pBits);
vcheckGLcall("glReadPixels");
}
break;
case D3DFMT_A8R8G8B8:
{
glPixelStorei(GL_PACK_SWAP_BYTES, TRUE);
vcheckGLcall("glPixelStorei");
glReadPixels(This->lockedRect.left, This->lockedRect.top,
This->lockedRect.right - This->lockedRect.left, This->lockedRect.bottom - This->lockedRect.top,
GL_BGRA, GL_UNSIGNED_BYTE, pLockedRect->pBits);
vcheckGLcall("glReadPixels");
glPixelStorei(GL_PACK_SWAP_BYTES, prev_store);
vcheckGLcall("glPixelStorei");
}
break;
default:
FIXME("Unsupported Format %u in locking func\n", This->myDesc.Format);
}
glReadBuffer(prev_read);
vcheckGLcall("glReadBuffer");
LEAVE_GL();
} else {
FIXME("unsupported locking to Rendering surface surf@%p usage(%lu)\n", This, This->myDesc.Usage);
}
} else if (D3DUSAGE_DEPTHSTENCIL & This->myDesc.Usage) { /* stencil surfaces */
FIXME("TODO stencil depth surface locking surf@%p usage(%lu)\n", This, This->myDesc.Usage);
} else {
TRACE("Lock Rect (%p) = l %ld, t %ld, r %ld, b %ld\n", pRect, pRect->left, pRect->top, pRect->right, pRect->bottom);
pLockedRect->pBits = This->allocatedMemory + (pLockedRect->Pitch * pRect->top) + (pRect->left * This->bytesPerPixel);
FIXME("unsupported locking to surface surf@%p usage(%lu)\n", This, This->myDesc.Usage);
}
TRACE("returning pBits=%p, pitch=%d\n", pLockedRect->pBits, pLockedRect->Pitch);
This->locked = TRUE;
return D3D_OK;
}
HRESULT WINAPI IDirect3DSurface8Impl_UnlockRect(LPDIRECT3DSURFACE8 iface) {
HRESULT hr;
ICOM_THIS(IDirect3DSurface8Impl,iface);
if (FALSE == This->locked) {
ERR("trying to lock unlocked surf@%p\n", This);
return D3DERR_INVALIDCALL;
}
TRACE("(%p) : stub\n", This);
if (This->Container) {
IDirect3DBaseTexture8 *cont = (IDirect3DBaseTexture8*) This->Container;
/* Now setup the texture appropraitly */
int containerType = IDirect3DBaseTexture8Impl_GetType(cont);
if (containerType == D3DRTYPE_TEXTURE) {
if (0 == This->myDesc.Usage) { /* classic surface */
if (This->Container) {
IDirect3DBaseTexture8* cont = NULL;
hr = IUnknown_QueryInterface(This->Container, &IID_IDirect3DBaseTexture8, (void**) &cont);
if (SUCCEEDED(hr) && NULL != cont) {
/* Now setup the texture appropraitly */
int containerType = IDirect3DBaseTexture8Impl_GetType(cont);
if (containerType == D3DRTYPE_TEXTURE) {
IDirect3DTexture8Impl *pTexture = (IDirect3DTexture8Impl *)cont;
pTexture->Dirty = TRUE;
} else if (containerType == D3DRTYPE_CUBETEXTURE) {
} else if (containerType == D3DRTYPE_CUBETEXTURE) {
IDirect3DCubeTexture8Impl *pTexture = (IDirect3DCubeTexture8Impl *)cont;
pTexture->Dirty = TRUE;
} else {
} else {
FIXME("Set dirty on container type %d\n", containerType);
}
}
IDirect3DBaseTexture8_Release(cont);
cont = NULL;
}
}
} else if (D3DUSAGE_RENDERTARGET & This->myDesc.Usage) { /* render surfaces */
if (This == This->Device->backBuffer || This == This->Device->frontBuffer) {
GLint prev_store;
GLenum prev_draw;
ENTER_GL();
glFlush();
vcheckGLcall("glFlush");
glGetIntegerv(GL_DRAW_BUFFER, &prev_draw);
vcheckGLcall("glIntegerv");
glGetIntegerv(GL_PACK_SWAP_BYTES, &prev_store);
vcheckGLcall("glIntegerv");
if (This == This->Device->backBuffer) {
glDrawBuffer(GL_BACK);
} else if (This == This->Device->frontBuffer) {
glDrawBuffer(GL_FRONT);
}
vcheckGLcall("glDrawBuffer");
glRasterPos2i(This->lockedRect.left, This->lockedRect.top);
vcheckGLcall("glRasterPos2f");
switch (This->myDesc.Format) {
case D3DFMT_R5G6B5:
{
glDrawPixels(This->lockedRect.right - This->lockedRect.left, This->lockedRect.bottom - This->lockedRect.top,
GL_RGB, GL_UNSIGNED_SHORT_5_6_5, This->allocatedMemory);
vcheckGLcall("glDrawPixels");
}
break;
case D3DFMT_R8G8B8:
{
glDrawPixels(This->lockedRect.right - This->lockedRect.left, This->lockedRect.bottom - This->lockedRect.top,
GL_RGB, GL_UNSIGNED_BYTE, This->allocatedMemory);
vcheckGLcall("glDrawPixels");
}
break;
case D3DFMT_A8R8G8B8:
{
glPixelStorei(GL_PACK_SWAP_BYTES, TRUE);
vcheckGLcall("glPixelStorei");
glDrawPixels(This->lockedRect.right - This->lockedRect.left, This->lockedRect.bottom - This->lockedRect.top,
GL_BGRA, GL_UNSIGNED_BYTE, This->allocatedMemory);
vcheckGLcall("glDrawPixels");
glPixelStorei(GL_PACK_SWAP_BYTES, prev_store);
vcheckGLcall("glPixelStorei");
}
break;
default:
FIXME("Unsupported Format %u in locking func\n", This->myDesc.Format);
}
glDrawBuffer(prev_draw);
vcheckGLcall("glDrawBuffer");
LEAVE_GL();
} else {
FIXME("unsupported unlocking to Rendering surface surf@%p usage(%lu)\n", This, This->myDesc.Usage);
}
} else if (D3DUSAGE_DEPTHSTENCIL & This->myDesc.Usage) { /* stencil surfaces */
if (This == This->Device->depthStencilBuffer) {
FIXME("TODO stencil depth surface unlocking surf@%p usage(%lu)\n", This, This->myDesc.Usage);
} else {
FIXME("unsupported unlocking to StencilDepth surface surf@%p usage(%lu)\n", This, This->myDesc.Usage);
}
} else {
FIXME("unsupported unlocking to surface surf@%p usage(%lu)\n", This, This->myDesc.Usage);
}
This->locked = FALSE;
return D3D_OK;
}
......
......@@ -64,11 +64,14 @@ ULONG WINAPI IDirect3DSwapChain8Impl_Release(LPDIRECT3DSWAPCHAIN8 iface) {
/* IDirect3DSwapChain parts follow: */
HRESULT WINAPI IDirect3DSwapChain8Impl_Present(LPDIRECT3DSWAPCHAIN8 iface, CONST RECT* pSourceRect, CONST RECT* pDestRect, HWND hDestWindowOverride,CONST RGNDATA* pDirtyRegion) {
ICOM_THIS(IDirect3DSwapChain8Impl,iface);
FIXME("(%p) : stub\n", This); return D3D_OK;
FIXME("(%p) : stub\n", This);
return D3D_OK;
}
HRESULT WINAPI IDirect3DSwapChain8Impl_GetBackBuffer(LPDIRECT3DSWAPCHAIN8 iface, UINT BackBuffer, D3DBACKBUFFER_TYPE Type,IDirect3DSurface8** ppBackBuffer) {
ICOM_THIS(IDirect3DSwapChain8Impl,iface);
FIXME("(%p) : stub\n", This); return D3D_OK;
FIXME("(%p) : stub\n", This);
*ppBackBuffer = NULL;
return D3D_OK;
}
......
......@@ -69,6 +69,7 @@ HRESULT WINAPI IDirect3DVertexBuffer8Impl_GetDevice(LPDIRECT3DVERTEXBUFF
ICOM_THIS(IDirect3DVertexBuffer8Impl,iface);
TRACE("(%p) : returning %p\n", This, This->Device);
*ppDevice = (LPDIRECT3DDEVICE8) This->Device;
IDirect3DDevice8Impl_AddRef(*ppDevice);
return D3D_OK;
}
HRESULT WINAPI IDirect3DVertexBuffer8Impl_SetPrivateData(LPDIRECT3DVERTEXBUFFER8 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
......@@ -118,12 +119,12 @@ HRESULT WINAPI IDirect3DVertexBuffer8Impl_GetDesc(LPDIRECT3DVERTEXBUFFER
ICOM_THIS(IDirect3DVertexBuffer8Impl,iface);
TRACE("(%p)\n", This);
pDesc->Format= This->currentDesc.Format;
pDesc->Type= This->currentDesc.Type;
pDesc->Usage= This->currentDesc.Usage;
pDesc->Pool= This->currentDesc.Pool;
pDesc->Size= This->currentDesc.Size;
pDesc->FVF= This->currentDesc.FVF;
pDesc->Format = This->currentDesc.Format;
pDesc->Type = This->currentDesc.Type;
pDesc->Usage = This->currentDesc.Usage;
pDesc->Pool = This->currentDesc.Pool;
pDesc->Size = This->currentDesc.Size;
pDesc->FVF = This->currentDesc.FVF;
return D3D_OK;
}
......
......@@ -92,6 +92,7 @@ HRESULT WINAPI IDirect3DVolume8Impl_GetContainer(LPDIRECT3DVOLUME8 iface, REFIID
ICOM_THIS(IDirect3DVolume8Impl,iface);
TRACE("(%p) : returning %p\n", This, This->Container);
*ppContainer = This->Container;
IUnknown_AddRef(This->Container);
return D3D_OK;
}
HRESULT WINAPI IDirect3DVolume8Impl_GetDesc(LPDIRECT3DVOLUME8 iface, D3DVOLUME_DESC* pDesc) {
......@@ -113,8 +114,7 @@ HRESULT WINAPI IDirect3DVolume8Impl_LockBox(LPDIRECT3DVOLUME8 iface, D3DLOCKED_B
TRACE("No box supplied - all is ok\n");
pLockedVolume->pBits = This->allocatedMemory;
} else {
TRACE("Lock Box (%p) = l %d, t %d, r %d, b %d, fr %d, ba %d\n", pBox, pBox->Left, pBox->Top,
pBox->Right, pBox->Bottom, pBox->Front, pBox->Back);
TRACE("Lock Box (%p) = l %d, t %d, r %d, b %d, fr %d, ba %d\n", pBox, pBox->Left, pBox->Top, pBox->Right, pBox->Bottom, pBox->Front, pBox->Back);
pLockedVolume->pBits = This->allocatedMemory +
(pLockedVolume->SlicePitch * pBox->Front) + /* FIXME: is front < back or vica versa? */
(pLockedVolume->RowPitch * pBox->Top) +
......@@ -122,16 +122,12 @@ HRESULT WINAPI IDirect3DVolume8Impl_LockBox(LPDIRECT3DVOLUME8 iface, D3DLOCKED_B
}
TRACE("returning pBits=%p, rpitch=%d, spitch=%d\n", pLockedVolume->pBits, pLockedVolume->RowPitch, pLockedVolume->SlicePitch);
return D3D_OK;
return D3D_OK;
}
HRESULT WINAPI IDirect3DVolume8Impl_UnlockBox(LPDIRECT3DVOLUME8 iface) {
ICOM_THIS(IDirect3DVolume8Impl,iface);
TRACE("(%p) : stub\n", This);
if (This->Container) {
IDirect3DVolumeTexture8 *cont = This->Container;
IDirect3DVolumeTexture8* cont = (IDirect3DVolumeTexture8*) This->Container;
int containerType = IDirect3DBaseTexture8Impl_GetType((LPDIRECT3DBASETEXTURE8) cont);
if (containerType == D3DRTYPE_VOLUMETEXTURE) {
......
......@@ -62,7 +62,7 @@ ULONG WINAPI IDirect3DVolumeTexture8Impl_Release(LPDIRECT3DVOLUMETEXTURE8 iface)
TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref);
if (ref == 0) {
for (i=0; i<This->levels; i++) {
for (i = 0; i < This->levels; i++) {
if (This->volumes[i] != NULL) {
TRACE("(%p) : Releasing volume %p\n", This, This->volumes[i]);
IDirect3DVolume8Impl_Release((LPDIRECT3DVOLUME8) This->volumes[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