- 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
This commit is contained in:
Raphael Junqueira 2003-05-11 03:35:27 +00:00 committed by Alexandre Julliard
parent ebc9abd1a1
commit 89ec35fe43
11 changed files with 664 additions and 227 deletions

View File

@ -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;
};

View File

@ -994,9 +994,9 @@ GLenum StencilOp(DWORD op) {
case D3DSTENCILOP_INCRSAT : return GL_INCR;
case D3DSTENCILOP_DECRSAT : return GL_DECR;
case D3DSTENCILOP_INVERT : return GL_INVERT;
case D3DSTENCILOP_INCR : FIXME("Unsupported stencil op %ld\n", op);
case D3DSTENCILOP_INCR : FIXME("Unsupported stencil op D3DSTENCILOP_INCR\n");
return GL_INCR; /* Fixme - needs to support wrap */
case D3DSTENCILOP_DECR : FIXME("Unsupported stencil op %ld\n", op);
case D3DSTENCILOP_DECR : FIXME("Unsupported stencil op D3DSTENCILOP_DECR\n");
return GL_DECR; /* Fixme - needs to support wrap */
default:
FIXME("Invalid stencil op %ld\n", op);
@ -1004,6 +1004,72 @@ GLenum StencilOp(DWORD op) {
}
}
/**
* @nodoc: todo
*/
void GetSrcAndOpFromValue(DWORD iValue, BOOL isAlphaArg, GLenum* source, GLenum* operand)
{
BOOL isAlphaReplicate = FALSE;
BOOL isComplement = FALSE;
*operand = GL_SRC_COLOR;
*source = GL_TEXTURE;
/* Catch alpha replicate */
if (iValue & D3DTA_ALPHAREPLICATE) {
iValue = iValue & ~D3DTA_ALPHAREPLICATE;
isAlphaReplicate = TRUE;
}
/* Catch Complement */
if (iValue & D3DTA_COMPLEMENT) {
iValue = iValue & ~D3DTA_COMPLEMENT;
isComplement = TRUE;
}
/* Calculate the operand */
if (isAlphaReplicate && !isComplement) {
*operand = GL_SRC_ALPHA;
} else if (isAlphaReplicate && isComplement) {
*operand = GL_ONE_MINUS_SRC_ALPHA;
} else if (isComplement) {
if (isAlphaArg) {
*operand = GL_ONE_MINUS_SRC_ALPHA;
} else {
*operand = GL_ONE_MINUS_SRC_COLOR;
}
} else {
if (isAlphaArg) {
*operand = GL_SRC_ALPHA;
} else {
*operand = GL_SRC_COLOR;
}
}
/* Calculate the source */
switch (iValue & D3DTA_SELECTMASK) {
case D3DTA_CURRENT: *source = GL_PREVIOUS_EXT;
break;
case D3DTA_DIFFUSE: *source = GL_PRIMARY_COLOR_EXT;
break;
case D3DTA_TEXTURE: *source = GL_TEXTURE;
break;
case D3DTA_TFACTOR: *source = GL_CONSTANT_EXT;
break;
case D3DTA_SPECULAR:
/**
* According to the GL_ARB_texture_env_combine specs, SPECULAR is 'Secondary color' and
* isnt supported until base GL supports it
* There is no concept of temp registers as far as I can tell
*/
default:
FIXME("Unrecognized or unhandled texture arg %ld\n", iValue);
*source = GL_TEXTURE;
}
}
/* Apply the current values to the specified texture stage */
void setupTextureStates(LPDIRECT3DDEVICE8 iface, DWORD Stage) {
ICOM_THIS(IDirect3DDevice8Impl,iface);
@ -1154,7 +1220,9 @@ BOOL WINAPI IDirect3DDevice8Impl_ShowCursor(LPDIRECT3DDEVICE8 iface, BOOL b
}
HRESULT WINAPI IDirect3DDevice8Impl_CreateAdditionalSwapChain(LPDIRECT3DDEVICE8 iface, D3DPRESENT_PARAMETERS* pPresentationParameters, IDirect3DSwapChain8** pSwapChain) {
ICOM_THIS(IDirect3DDevice8Impl,iface);
FIXME("(%p) : stub\n", This); return D3D_OK;
FIXME("(%p) : stub\n", This);
*pSwapChain = NULL;
return D3D_OK;
}
HRESULT WINAPI IDirect3DDevice8Impl_Reset(LPDIRECT3DDEVICE8 iface, D3DPRESENT_PARAMETERS* pPresentationParameters) {
ICOM_THIS(IDirect3DDevice8Impl,iface);
@ -1173,11 +1241,16 @@ HRESULT WINAPI IDirect3DDevice8Impl_Present(LPDIRECT3DDEVICE8 iface, CONST REC
return D3D_OK;
}
HRESULT WINAPI IDirect3DDevice8Impl_GetBackBuffer(LPDIRECT3DDEVICE8 iface, UINT BackBuffer,D3DBACKBUFFER_TYPE Type,IDirect3DSurface8** ppBackBuffer) {
HRESULT WINAPI IDirect3DDevice8Impl_GetBackBuffer(LPDIRECT3DDEVICE8 iface, UINT BackBuffer, D3DBACKBUFFER_TYPE Type, IDirect3DSurface8** ppBackBuffer) {
ICOM_THIS(IDirect3DDevice8Impl,iface);
*ppBackBuffer = (LPDIRECT3DSURFACE8) This->backBuffer;
TRACE("(%p) : BackBuf %d Type %d returning %p\n", This, BackBuffer, Type, *ppBackBuffer);
if (BackBuffer > This->PresentParms.BackBufferCount - 1) {
FIXME("Only one backBuffer currently supported\n");
return D3DERR_INVALIDCALL;
}
/* Note inc ref on returned surface */
IDirect3DSurface8Impl_AddRef((LPDIRECT3DSURFACE8) *ppBackBuffer);
@ -1185,7 +1258,8 @@ HRESULT WINAPI IDirect3DDevice8Impl_GetBackBuffer(LPDIRECT3DDEVICE8 iface, UIN
}
HRESULT WINAPI IDirect3DDevice8Impl_GetRasterStatus(LPDIRECT3DDEVICE8 iface, D3DRASTER_STATUS* pRasterStatus) {
ICOM_THIS(IDirect3DDevice8Impl,iface);
FIXME("(%p) : stub\n", This); return D3D_OK;
FIXME("(%p) : stub\n", This);
return D3D_OK;
}
void WINAPI IDirect3DDevice8Impl_SetGammaRamp(LPDIRECT3DDEVICE8 iface, DWORD Flags,CONST D3DGAMMARAMP* pRamp) {
ICOM_THIS(IDirect3DDevice8Impl,iface);
@ -1217,6 +1291,7 @@ HRESULT WINAPI IDirect3DDevice8Impl_CreateTexture(LPDIRECT3DDEVICE8 iface, UIN
object->usage = Usage;
object->format = Format;
object->device = This;
/*IDirect3DDevice8Impl_AddRef((LPDIRECT3DDEVICE8) object->device);*/
/* Calculate levels for mip mapping */
if (Levels == 0) {
@ -1237,7 +1312,8 @@ HRESULT WINAPI IDirect3DDevice8Impl_CreateTexture(LPDIRECT3DDEVICE8 iface, UIN
for (i=0; i<object->levels; i++)
{
IDirect3DDevice8Impl_CreateImageSurface(iface, tmpW, tmpH, Format, (LPDIRECT3DSURFACE8*) &object->surfaces[i]);
object->surfaces[i]->Container = (IUnknown*) object; /* FIXME: AddRef(object) */
object->surfaces[i]->Container = (IUnknown*) object;
/*IUnknown_AddRef(object->surfaces[i]->Container);*/
object->surfaces[i]->myDesc.Usage = Usage;
object->surfaces[i]->myDesc.Pool = Pool ;
@ -1264,16 +1340,16 @@ HRESULT WINAPI IDirect3DDevice8Impl_CreateVolumeTexture(LPDIRECT3DDEVICE8 ifac
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DVolumeTexture8Impl));
object->lpVtbl = &Direct3DVolumeTexture8_Vtbl;
object->ResourceType = D3DRTYPE_VOLUMETEXTURE;
object->Device = This;
/*IDirect3DDevice8Impl_AddRef((LPDIRECT3DDEVICE8) object->Device);*/
object->ref = 1;
object->width = Width;
object->height = Height;
object->depth = Depth;
object->levels = Levels;
object->usage = Usage;
object->format = Format;
object->device = This;
/* Calculate levels for mip mapping */
if (Levels == 0) {
@ -1282,7 +1358,7 @@ HRESULT WINAPI IDirect3DDevice8Impl_CreateVolumeTexture(LPDIRECT3DDEVICE8 ifac
tmpH = Height;
tmpD = Depth;
while (tmpW > 1 && tmpH > 1 && tmpD > 1) {
tmpW = max(1,tmpW / 2);
tmpW = max(1, tmpW / 2);
tmpH = max(1, tmpH / 2);
tmpD = max(1, tmpD / 2);
object->levels++;
@ -1295,7 +1371,7 @@ HRESULT WINAPI IDirect3DDevice8Impl_CreateVolumeTexture(LPDIRECT3DDEVICE8 ifac
tmpH = Height;
tmpD = Depth;
for (i=0; i<object->levels; i++)
for (i = 0; i< object->levels; i++)
{
IDirect3DVolume8Impl *volume;
@ -1304,9 +1380,11 @@ HRESULT WINAPI IDirect3DDevice8Impl_CreateVolumeTexture(LPDIRECT3DDEVICE8 ifac
object->volumes[i] = (IDirect3DVolume8Impl *) volume;
volume->lpVtbl = &Direct3DVolume8_Vtbl;
volume->Device = This; /* FIXME: AddRef(This) */
volume->Device = This;
/*IDirect3DDevice8Impl_AddRef((LPDIRECT3DDEVICE8) volume->Device);*/
volume->ResourceType = D3DRTYPE_VOLUME;
volume->Container = object;
volume->Container = (IUnknown*) object;
/*IUnknown_AddRef(volume->Container);*/
volume->ref = 1;
volume->myDesc.Width = Width;
@ -1343,14 +1421,14 @@ HRESULT WINAPI IDirect3DDevice8Impl_CreateCubeTexture(LPDIRECT3DDEVICE8 iface,
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DCubeTexture8Impl));
object->lpVtbl = &Direct3DCubeTexture8_Vtbl;
object->ref = 1;
object->Device = This; /* FIXME: AddRef(This) */
object->Device = This;
/*IDirect3DDevice8Impl_AddRef((LPDIRECT3DDEVICE8) object->Device);*/
object->ResourceType = D3DRTYPE_CUBETEXTURE;
object->edgeLength = EdgeLength;
object->levels = Levels;
object->usage = Usage;
object->format = Format;
object->device = This;
/* Calculate levels for mip mapping */
if (Levels == 0) {
@ -1365,17 +1443,18 @@ HRESULT WINAPI IDirect3DDevice8Impl_CreateCubeTexture(LPDIRECT3DDEVICE8 iface,
/* Generate all the surfaces */
tmpW = EdgeLength;
for (i=0; i<object->levels; i++)
for (i = 0; i < object->levels; i++)
{
/* Create the 6 faces */
for (j=0;j<6;j++) {
for (j = 0;j < 6; j++) {
IDirect3DDevice8Impl_CreateImageSurface(iface, tmpW, tmpW, Format, (LPDIRECT3DSURFACE8*) &object->surfaces[j][i]);
object->surfaces[j][i]->Container = (IUnknown*) object;
/*IUnknown_AddRef(object->surfaces[j][i]->Container);*/
object->surfaces[j][i]->myDesc.Usage = Usage;
object->surfaces[j][i]->myDesc.Pool = Pool ;
TRACE("Created surface level %d @ %p, memory at %p\n", i, object->surfaces[j][i], object->surfaces[j][i]->allocatedMemory);
tmpW = max(1,tmpW / 2);
tmpW = max(1, tmpW / 2);
}
}
@ -1383,8 +1462,7 @@ HRESULT WINAPI IDirect3DDevice8Impl_CreateCubeTexture(LPDIRECT3DDEVICE8 iface,
*ppCubeTexture = (LPDIRECT3DCUBETEXTURE8)object;
return D3D_OK;
}
HRESULT WINAPI IDirect3DDevice8Impl_CreateVertexBuffer(LPDIRECT3DDEVICE8 iface, UINT Size, DWORD Usage,
DWORD FVF,D3DPOOL Pool, IDirect3DVertexBuffer8** ppVertexBuffer) {
HRESULT WINAPI IDirect3DDevice8Impl_CreateVertexBuffer(LPDIRECT3DDEVICE8 iface, UINT Size, DWORD Usage, DWORD FVF, D3DPOOL Pool, IDirect3DVertexBuffer8** ppVertexBuffer) {
IDirect3DVertexBuffer8Impl *object;
ICOM_THIS(IDirect3DDevice8Impl,iface);
@ -1393,6 +1471,7 @@ HRESULT WINAPI IDirect3DDevice8Impl_CreateVertexBuffer(LPDIRECT3DDEVICE8 iface
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DVertexBuffer8Impl));
object->lpVtbl = &Direct3DVertexBuffer8_Vtbl;
object->Device = This;
/*IDirect3DDevice8Impl_AddRef((LPDIRECT3DDEVICE8) object->Device);*/
object->ResourceType = D3DRTYPE_VERTEXBUFFER;
object->ref = 1;
object->allocatedMemory = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, Size);
@ -1407,8 +1486,7 @@ HRESULT WINAPI IDirect3DDevice8Impl_CreateVertexBuffer(LPDIRECT3DDEVICE8 iface
return D3D_OK;
}
HRESULT WINAPI IDirect3DDevice8Impl_CreateIndexBuffer(LPDIRECT3DDEVICE8 iface, UINT Length,DWORD Usage,D3DFORMAT Format,D3DPOOL Pool,IDirect3DIndexBuffer8** ppIndexBuffer) {
HRESULT WINAPI IDirect3DDevice8Impl_CreateIndexBuffer(LPDIRECT3DDEVICE8 iface, UINT Length, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DIndexBuffer8** ppIndexBuffer) {
IDirect3DIndexBuffer8Impl *object;
ICOM_THIS(IDirect3DDevice8Impl,iface);
@ -1417,8 +1495,9 @@ HRESULT WINAPI IDirect3DDevice8Impl_CreateIndexBuffer(LPDIRECT3DDEVICE8 iface,
/* Allocate the storage for the device */
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DIndexBuffer8Impl));
object->lpVtbl = &Direct3DIndexBuffer8_Vtbl;
object->ref = 1;
object->Device = This;
/*IDirect3DDevice8Impl_AddRef((LPDIRECT3DDEVICE8) object->Device);*/
object->ref = 1;
object->ResourceType = D3DRTYPE_INDEXBUFFER;
object->currentDesc.Type = D3DRTYPE_INDEXBUFFER;
@ -1435,17 +1514,7 @@ HRESULT WINAPI IDirect3DDevice8Impl_CreateIndexBuffer(LPDIRECT3DDEVICE8 iface,
return D3D_OK;
}
HRESULT WINAPI IDirect3DDevice8Impl_CreateRenderTarget(LPDIRECT3DDEVICE8 iface, UINT Width,UINT Height,D3DFORMAT Format,D3DMULTISAMPLE_TYPE MultiSample,BOOL Lockable,IDirect3DSurface8** ppSurface) {
ICOM_THIS(IDirect3DDevice8Impl,iface);
/* up ref count on surface, surface->container = This */
FIXME("(%p) : stub\n", This); return D3D_OK;
}
HRESULT WINAPI IDirect3DDevice8Impl_CreateDepthStencilSurface(LPDIRECT3DDEVICE8 iface, UINT Width,UINT Height,D3DFORMAT Format,D3DMULTISAMPLE_TYPE MultiSample,IDirect3DSurface8** ppSurface) {
ICOM_THIS(IDirect3DDevice8Impl,iface);
/* surface->container = This */
FIXME("(%p) : stub\n", This); return D3D_OK;
}
HRESULT WINAPI IDirect3DDevice8Impl_CreateImageSurface(LPDIRECT3DDEVICE8 iface, UINT Width,UINT Height,D3DFORMAT Format,IDirect3DSurface8** ppSurface) {
HRESULT WINAPI IDirect3DDevice8Impl_CreateRenderTarget(LPDIRECT3DDEVICE8 iface, UINT Width, UINT Height, D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, BOOL Lockable, IDirect3DSurface8** ppSurface) {
IDirect3DSurface8Impl *object;
ICOM_THIS(IDirect3DDevice8Impl,iface);
@ -1454,19 +1523,85 @@ HRESULT WINAPI IDirect3DDevice8Impl_CreateImageSurface(LPDIRECT3DDEVICE8 iface
*ppSurface = (LPDIRECT3DSURFACE8) object;
object->lpVtbl = &Direct3DSurface8_Vtbl;
object->Device = This;
/*IDirect3DDevice8Impl_AddRef((LPDIRECT3DDEVICE8) object->Device);*/
object->ResourceType = D3DRTYPE_SURFACE;
object->Container = (IUnknown*) This;
/*IUnknown_AddRef(object->Container);*/
object->ref = 1;
object->myDesc.Width = Width;
object->myDesc.Height= Height;
object->myDesc.Format= Format;
object->myDesc.Width = Width;
object->myDesc.Height = Height;
object->myDesc.Format = Format;
object->myDesc.Type = D3DRTYPE_SURFACE;
/*object->myDesc.Usage */
object->myDesc.Pool = D3DPOOL_SYSTEMMEM ;
object->myDesc.Usage = D3DUSAGE_RENDERTARGET;
object->myDesc.Pool = D3DPOOL_MANAGED;
object->myDesc.MultiSampleType = MultiSample;
object->bytesPerPixel = bytesPerPixel(Format);
object->myDesc.Size = (Width * object->bytesPerPixel) * Height;
object->allocatedMemory = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, object->myDesc.Size);
object->lockable = Lockable;
object->locked = FALSE;
TRACE("(%p) : w(%d) h(%d) fmt(%d) lockable(%d) surf@%p, surfmem@%p, %d bytes\n", This, Width, Height, Format, Lockable, *ppSurface, object->allocatedMemory, object->myDesc.Size);
return D3D_OK;
}
HRESULT WINAPI IDirect3DDevice8Impl_CreateDepthStencilSurface(LPDIRECT3DDEVICE8 iface, UINT Width, UINT Height, D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, IDirect3DSurface8** ppSurface) {
IDirect3DSurface8Impl *object;
ICOM_THIS(IDirect3DDevice8Impl,iface);
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DSurface8Impl));
*ppSurface = (LPDIRECT3DSURFACE8) object;
object->lpVtbl = &Direct3DSurface8_Vtbl;
object->Device = This;
/*IDirect3DDevice8Impl_AddRef((LPDIRECT3DDEVICE8) object->Device);*/
object->ResourceType = D3DRTYPE_SURFACE;
object->Container = (IUnknown*) This;
/*IUnknown_AddRef(object->Container);*/
object->ref = 1;
object->myDesc.Width = Width;
object->myDesc.Height = Height;
object->myDesc.Format = Format;
object->myDesc.Type = D3DRTYPE_SURFACE;
object->myDesc.Usage = D3DUSAGE_DEPTHSTENCIL;
object->myDesc.Pool = D3DPOOL_MANAGED;
object->myDesc.MultiSampleType = MultiSample;
object->bytesPerPixel = bytesPerPixel(Format);
object->myDesc.Size = (Width * object->bytesPerPixel) * Height;
object->allocatedMemory = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, object->myDesc.Size);
object->lockable = TRUE;
object->locked = FALSE;
TRACE("(%p) : w(%d) h(%d) fmt(%d) surf@%p, surfmem@%p, %d bytes\n", This, Width, Height, Format, *ppSurface, object->allocatedMemory, object->myDesc.Size);
return D3D_OK;
}
HRESULT WINAPI IDirect3DDevice8Impl_CreateImageSurface(LPDIRECT3DDEVICE8 iface, UINT Width, UINT Height, D3DFORMAT Format, IDirect3DSurface8** ppSurface) {
IDirect3DSurface8Impl *object;
ICOM_THIS(IDirect3DDevice8Impl,iface);
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DSurface8Impl));
*ppSurface = (LPDIRECT3DSURFACE8) object;
object->lpVtbl = &Direct3DSurface8_Vtbl;
object->Device = This;
/*IDirect3DDevice8Impl_AddRef((LPDIRECT3DDEVICE8) object->Device);*/
object->ResourceType = D3DRTYPE_SURFACE;
object->Container = (IUnknown*) This;
/*IUnknown_AddRef(object->Container);*/
object->ref = 1;
object->myDesc.Width = Width;
object->myDesc.Height = Height;
object->myDesc.Format = Format;
object->myDesc.Type = D3DRTYPE_SURFACE;
object->myDesc.Usage = 0;
object->myDesc.Pool = D3DPOOL_SYSTEMMEM;
object->bytesPerPixel = bytesPerPixel(Format);
object->myDesc.Size = (Width * object->bytesPerPixel) * Height;
object->allocatedMemory = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, object->myDesc.Size);
object->lockable = TRUE;
object->locked = FALSE;
TRACE("(%p) : w(%d) h(%d) fmt(%d) surf@%p, surfmem@%p, %d bytes\n", This, Width, Height, Format, *ppSurface, object->allocatedMemory, object->myDesc.Size);
return D3D_OK;
@ -1597,29 +1732,66 @@ HRESULT WINAPI IDirect3DDevice8Impl_UpdateTexture(LPDIRECT3DDEVICE8 iface, IDi
FIXME("(%p) : stub\n", This); return D3D_OK;
}
HRESULT WINAPI IDirect3DDevice8Impl_GetFrontBuffer(LPDIRECT3DDEVICE8 iface, IDirect3DSurface8* pDestSurface) {
HRESULT hr;
D3DLOCKED_RECT lockedRect;
GLint prev_store;
GLenum prev_read;
ICOM_THIS(IDirect3DDevice8Impl,iface);
FIXME("(%p) : stub\n", This); return D3D_OK;
FIXME("(%p) : stub\n", This);
if (D3DFMT_A8R8G8B8 != ((IDirect3DSurface8Impl*) pDestSurface)->myDesc.Format) {
return D3DERR_INVALIDCALL;
}
hr = IDirect3DSurface8Impl_LockRect(pDestSurface, &lockedRect, NULL, 0);
if (FAILED(hr)) {
return D3DERR_INVALIDCALL;
}
ENTER_GL();
glFlush();
vcheckGLcall("glFlush");
glGetIntegerv(GL_READ_BUFFER, &prev_read);
vcheckGLcall("glIntegerv");
glGetIntegerv(GL_PACK_SWAP_BYTES, &prev_store);
vcheckGLcall("glIntegerv");
glReadBuffer(GL_FRONT);
vcheckGLcall("glReadBuffer");
glPixelStorei(GL_PACK_SWAP_BYTES, TRUE);
vcheckGLcall("glPixelStorei");
glReadPixels(0, 0, This->PresentParms.BackBufferWidth, This->PresentParms.BackBufferHeight,
GL_BGRA, GL_UNSIGNED_BYTE, lockedRect.pBits);
vcheckGLcall("glReadPixels");
glPixelStorei(GL_PACK_SWAP_BYTES, prev_store);
vcheckGLcall("glPixelStorei");
glReadBuffer(prev_read);
vcheckGLcall("glReadBuffer");
LEAVE_GL();
hr = IDirect3DSurface8Impl_UnlockRect(pDestSurface);
return hr;
}
HRESULT WINAPI IDirect3DDevice8Impl_SetRenderTarget(LPDIRECT3DDEVICE8 iface, IDirect3DSurface8* pRenderTarget,IDirect3DSurface8* pNewZStencil) {
ICOM_THIS(IDirect3DDevice8Impl,iface);
FIXME("(%p) : stub\n", This);
FIXME("(%p) : invalid stub expect crash\n", This);
return D3D_OK;
}
HRESULT WINAPI IDirect3DDevice8Impl_GetRenderTarget(LPDIRECT3DDEVICE8 iface, IDirect3DSurface8** ppRenderTarget) {
ICOM_THIS(IDirect3DDevice8Impl,iface);
/*TRACE("(%p) : returning %p\n", This, This->renderTarget); */
FIXME("(%p) : stub\n", This);
/*
**ppRenderTarget = (LPDIRECT3DSURFACE8) This->renderTarget;
*IDirect3DSurface8Impl_AddRef((LPDIRECT3DSURFACE8) *ppRenderTarget);
*/
TRACE("(%p)->(%p)\n", This, This->frontBuffer);
*ppRenderTarget = (LPDIRECT3DSURFACE8) This->frontBuffer;
IDirect3DSurface8Impl_AddRef((LPDIRECT3DSURFACE8) *ppRenderTarget);
return D3D_OK;
}
HRESULT WINAPI IDirect3DDevice8Impl_GetDepthStencilSurface(LPDIRECT3DDEVICE8 iface, IDirect3DSurface8** ppZStencilSurface) {
ICOM_THIS(IDirect3DDevice8Impl,iface);
TRACE("(%p)->(%p)\n", This, ppZStencilSurface);
@ -1674,7 +1846,7 @@ HRESULT WINAPI IDirect3DDevice8Impl_Clear(LPDIRECT3DDEVICE8 iface, DWORD Count
curRect = NULL;
}
for (i=0;i<Count || i==0; i++) {
for (i = 0; i < Count || i == 0; i++) {
if (curRect) {
/* Note gl uses lower left, width/height */
@ -1852,14 +2024,14 @@ HRESULT WINAPI IDirect3DDevice8Impl_SetTransform(LPDIRECT3DDEVICE8 iface, D3DT
}
/* Reapply texture transforms as based off modelview when applied */
for (Stage=0; Stage<This->TextureUnits; Stage++) {
for (Stage = 0; Stage < This->TextureUnits; Stage++) {
/* Now apply texture transforms if not applying to the dummy textures */
#if defined(GL_VERSION_1_3)
#if defined(GL_VERSION_1_3)
glActiveTexture(GL_TEXTURE0 + Stage);
#else
#else
glActiveTextureARB(GL_TEXTURE0_ARB + Stage);
#endif
#endif
checkGLcall("glActiveTexture(GL_TEXTURE0 + Stage);");
glMatrixMode(GL_TEXTURE);
@ -1966,7 +2138,7 @@ HRESULT WINAPI IDirect3DDevice8Impl_SetTransform(LPDIRECT3DDEVICE8 iface, D3DT
m.u.s._21 = 1.0f; m.u.s._22 = 1.0f; m.u.s._23 = 1.0f; m.u.s._24 = 1.0f;
m.u.s._31 = 1.0f; m.u.s._32 = 1.0f; m.u.s._33 = 1.0f; m.u.s._34 = 1.0f;
m.u.s._41 = 1.0f; m.u.s._42 = 1.0f; m.u.s._43 = 1.0f; m.u.s._44 = 1.0f;
if (viewChanged==FALSE) {
if (viewChanged == FALSE) {
glLoadMatrixf((float *) &This->StateBlock->transforms[D3DTS_VIEW].u.m[0][0]);
checkGLcall("glLoadMatrixf");
}
@ -3039,7 +3211,7 @@ HRESULT WINAPI IDirect3DDevice8Impl_BeginStateBlock(LPDIRECT3DDEVICE8 iface) {
TRACE("(%p)\n", This);
return IDirect3DDeviceImpl_BeginStateBlock(This);
return IDirect3DDeviceImpl_BeginStateBlock(This);
}
HRESULT WINAPI IDirect3DDevice8Impl_EndStateBlock(LPDIRECT3DDEVICE8 iface, DWORD* pToken) {
IDirect3DStateBlockImpl* pSB;
@ -3357,69 +3529,19 @@ HRESULT WINAPI IDirect3DDevice8Impl_SetTextureStageState(LPDIRECT3DDEVICE8 ifa
case D3DTSS_COLORARG0 :
case D3DTSS_ALPHAARG0 :
/* FIXME: Mesa seems to struggle setting these at the moment */
break;
/*FIXME("COLORARG0/ALPHAARG0 support still a stub, Stage=%ld, Type=%d, Value =%ld\n", Stage, Type, Value);*/
/*break;*/
case D3DTSS_COLORARG1 :
case D3DTSS_COLORARG2 :
case D3DTSS_ALPHAARG1 :
case D3DTSS_ALPHAARG2 :
{
BOOL isAlphaReplicate = FALSE;
BOOL isComplement = FALSE;
BOOL isAlphaArg = (Type == D3DTSS_ALPHAARG1 || Type == D3DTSS_ALPHAARG2 || Type == D3DTSS_ALPHAARG0);
int operand= GL_SRC_COLOR;
BOOL isAlphaArg = (Type == D3DTSS_ALPHAARG1 || Type == D3DTSS_ALPHAARG2 || Type == D3DTSS_ALPHAARG0);
int operand = GL_SRC_COLOR;
int source = GL_TEXTURE;
/* Catch alpha replicate */
if (Value & D3DTA_ALPHAREPLICATE) {
Value = Value & ~D3DTA_ALPHAREPLICATE;
isAlphaReplicate = TRUE;
}
/* Catch Complement */
if (Value & D3DTA_COMPLEMENT) {
Value = Value & ~D3DTA_COMPLEMENT;
isComplement = TRUE;
}
/* Calculate the operand */
if (isAlphaReplicate && !isComplement) {
operand = GL_SRC_ALPHA;
} else if (isAlphaReplicate && isComplement) {
operand = GL_ONE_MINUS_SRC_ALPHA;
} else if (isComplement) {
if (isAlphaArg) {
operand = GL_ONE_MINUS_SRC_ALPHA;
} else {
operand = GL_ONE_MINUS_SRC_COLOR;
}
} else {
if (isAlphaArg) {
operand = GL_SRC_ALPHA;
} else {
operand = GL_SRC_COLOR;
}
}
/* Calculate the source */
switch (Value) {
case D3DTA_CURRENT: source = GL_PREVIOUS_EXT;
break;
case D3DTA_DIFFUSE: source = GL_PRIMARY_COLOR_EXT;
break;
case D3DTA_TEXTURE: source = GL_TEXTURE;
break;
case D3DTA_TFACTOR: source = GL_CONSTANT_EXT;
break;
/* According to the GL_ARB_texture_env_combine specs, SPECULAR is 'Secondary color' and
isnt supported until base GL supports it
There is no concept of temp registers as far as I can tell */
default:
FIXME("Unrecognized or unhandled texture arg %ld\n", Value);
}
GetSrcAndOpFromValue(Value, isAlphaArg, &source, &operand);
if (isAlphaArg) {
TRACE("Source %x = %x, Operand %x = %x\n", SOURCEx_ALPHA_EXT(Type), source, OPERANDx_ALPHA_EXT(Type), operand);
glTexEnvi(GL_TEXTURE_ENV, SOURCEx_ALPHA_EXT(Type), source);
@ -3492,10 +3614,92 @@ HRESULT WINAPI IDirect3DDevice8Impl_SetTextureStageState(LPDIRECT3DDEVICE8 ifa
break;
case D3DTOP_SELECTARG1 :
glTexEnvi(GL_TEXTURE_ENV, Parm, GL_REPLACE);
checkGLcall("glTexEnvi(GL_TEXTURE_ENV, Parm, GL_REPLACE)");
{
FIXME("see if D3DTOP_SELECTARG1 behavior is correct now!\n");
glTexEnvi(GL_TEXTURE_ENV, Parm, GL_REPLACE);
checkGLcall("glTexEnvi(GL_TEXTURE_ENV, Parm, GL_REPLACE)");
#if 0 /* don't seem to do anything */
BOOL isAlphaOp = (Type == D3DTSS_ALPHAOP);
DWORD dwValue = 0;
GLenum source;
GLenum operand;
dwValue = This->StateBlock->texture_state[Stage][(isAlphaOp) ? D3DTSS_ALPHAARG1 : D3DTSS_COLORARG1];
GetSrcAndOpFromValue(dwValue, isAlphaOp, &source, &operand);
if (isAlphaOp) {
TRACE("Source %x = %x, Operand %x = %x\n", GL_SOURCE0_ALPHA_EXT, source, GL_OPERAND0_ALPHA_EXT, operand);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_EXT, source);
checkGLcall("glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_EXT, 'source')");
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_EXT, operand);
checkGLcall("glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_EXT, 'operand')");
} else {
TRACE("Source %x = %x, Operand %x = %x\n", GL_SOURCE0_RGB_EXT, source, GL_OPERAND0_RGB_EXT, operand);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, source);
checkGLcall("glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, 'source')");
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_EXT, operand);
checkGLcall("glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_EXT, 'operand')");
}
dwValue = This->StateBlock->texture_state[Stage][(isAlphaOp) ? D3DTSS_ALPHAARG2 : D3DTSS_COLORARG2];
GetSrcAndOpFromValue(dwValue, isAlphaOp, &source, &operand);
if (isAlphaOp) {
TRACE("Source %x = %x, Operand %x = %x\n", GL_SOURCE1_ALPHA_EXT, source, GL_OPERAND1_ALPHA_EXT, operand);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA_EXT, source);
checkGLcall("glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA_EXT, 'source')");
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_ALPHA_EXT, operand);
checkGLcall("glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_ALPHA_EXT, 'operand')");
} else {
TRACE("Source %x = %x, Operand %x = %x\n", GL_SOURCE1_RGB_EXT, source, GL_OPERAND1_RGB_EXT, operand);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, source);
checkGLcall("glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, 'source')");
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_EXT, operand);
checkGLcall("glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_EXT, 'operand')");
}
#endif
}
break;
case D3DTOP_SELECTARG2 :
{
BOOL isAlphaOp = (Type == D3DTSS_ALPHAOP);
DWORD dwValue = 0;
GLenum source;
GLenum operand;
FIXME("see if D3DTOP_SELECTARG2 behavior is correct now!\n");
glTexEnvi(GL_TEXTURE_ENV, Parm, GL_REPLACE);
checkGLcall("glTexEnvi(GL_TEXTURE_ENV, Parm, GL_REPLACE)");
/* GL_REPLACE, swap args 0 and 1? */
dwValue = This->StateBlock->texture_state[Stage][(isAlphaOp) ? D3DTSS_ALPHAARG2 : D3DTSS_COLORARG2];
GetSrcAndOpFromValue(dwValue, isAlphaOp, &source, &operand);
if (isAlphaOp) {
TRACE("Source %x = %x, Operand %x = %x\n", GL_SOURCE0_ALPHA_EXT, source, GL_OPERAND0_ALPHA_EXT, operand);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_EXT, source);
checkGLcall("glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_EXT, 'source')");
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_EXT, operand);
checkGLcall("glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_EXT, 'operand')");
} else {
TRACE("Source %x = %x, Operand %x = %x\n", GL_SOURCE0_RGB_EXT, source, GL_OPERAND0_RGB_EXT, operand);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, source);
checkGLcall("glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, 'source')");
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_EXT, operand);
checkGLcall("glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_EXT, 'operand')");
}
dwValue = This->StateBlock->texture_state[Stage][(isAlphaOp) ? D3DTSS_ALPHAARG1 : D3DTSS_COLORARG1];
GetSrcAndOpFromValue(dwValue, isAlphaOp, &source, &operand);
if (isAlphaOp) {
TRACE("Source %x = %x, Operand %x = %x\n", GL_SOURCE1_ALPHA_EXT, source, GL_OPERAND1_ALPHA_EXT, operand);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA_EXT, source);
checkGLcall("glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA_EXT, 'source')");
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_ALPHA_EXT, operand);
checkGLcall("glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_ALPHA_EXT, 'operand')");
} else {
TRACE("Source %x = %x, Operand %x = %x\n", GL_SOURCE1_RGB_EXT, source, GL_OPERAND1_RGB_EXT, operand);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, source);
checkGLcall("glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, 'source')");
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_EXT, operand);
checkGLcall("glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_EXT, 'operand')");
}
}
break;
case D3DTOP_MODULATE4X : Scale = Scale * 2; /* Drop through */
case D3DTOP_MODULATE2X : Scale = Scale * 2; /* Drop through */
case D3DTOP_MODULATE :
@ -3535,9 +3739,17 @@ HRESULT WINAPI IDirect3DDevice8Impl_SetTextureStageState(LPDIRECT3DDEVICE8 ifa
break;
case D3DTOP_SUBTRACT :
/* glTexEnvi(GL_TEXTURE_ENV, Parm, GL_SUBTRACT); Missing? */
case D3DTOP_SELECTARG2 :
/* GL_REPLACE, swap args 0 and 1? */
#if defined(GL_VERSION_1_3)
glTexEnvi(GL_TEXTURE_ENV, Parm, GL_SUBTRACT);
checkGLcall("glTexEnvi(GL_TEXTURE_ENV, Parm, GL_SUBTRACT)");
break;
#else
/**
* @TODO: to check:
* if ARB_texture_env_combine is supported
* we can use GL_SUBTRACT_ARB here
*/
#endif
case D3DTOP_ADDSMOOTH :
case D3DTOP_BLENDDIFFUSEALPHA :
case D3DTOP_BLENDTEXTUREALPHA :
@ -3619,52 +3831,77 @@ HRESULT WINAPI IDirect3DDevice8Impl_SetTextureStageState(LPDIRECT3DDEVICE8 ifa
break;
case D3DTSS_TEXCOORDINDEX :
/* CameraSpacePosition means use the vertex position, transformed to camera space,
as the input texture coordinates for this stage's texture transformation. This
equates roughly to EYE_LINEAR */
if (Value & D3DTSS_TCI_CAMERASPACEPOSITION) {
float s_plane[] = { 1.0, 0.0, 0.0, 0.0 };
float t_plane[] = { 0.0, 1.0, 0.0, 0.0 };
float r_plane[] = { 0.0, 0.0, 1.0, 0.0 };
float q_plane[] = { 0.0, 0.0, 0.0, 1.0 };
TRACE("D3DTSS_TCI_CAMERASPACEPOSITION - Set eye plane\n");
{
/* CameraSpacePosition means use the vertex position, transformed to camera space,
as the input texture coordinates for this stage's texture transformation. This
equates roughly to EYE_LINEAR */
/**
* To Jason: i don't understand what to do with the (Value & 0x00FF) index
* it seems a texture coordinate index (0 <= x <= 7) seeing msdn and logs
* have you any idea ?
*/
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
glTexGenfv(GL_S, GL_EYE_PLANE, s_plane);
glTexGenfv(GL_T, GL_EYE_PLANE, t_plane);
glTexGenfv(GL_R, GL_EYE_PLANE, r_plane);
glTexGenfv(GL_Q, GL_EYE_PLANE, q_plane);
glPopMatrix();
/**
* Be carefull the value of the mask 0xF0000 come from d3d8types.h infos
*/
switch (Value & 0xFFFFFF00) {
case D3DTSS_TCI_PASSTHRU:
/*Use the specified texture coordinates contained within the vertex format. This value resolves to zero.*/
break;
TRACE("D3DTSS_TCI_CAMERASPACEPOSITION - Set GL_TEXTURE_GEN_x and GL_x, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR\n");
glEnable(GL_TEXTURE_GEN_S);
checkGLcall("glEnable(GL_TEXTURE_GEN_S);");
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
checkGLcall("glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR)");
glEnable(GL_TEXTURE_GEN_T);
checkGLcall("glEnable(GL_TEXTURE_GEN_T);");
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
checkGLcall("glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR)");
glEnable(GL_TEXTURE_GEN_R);
checkGLcall("glEnable(GL_TEXTURE_GEN_R);");
glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
checkGLcall("glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR)");
}
case D3DTSS_TCI_CAMERASPACEPOSITION:
{
float s_plane[] = { 1.0, 0.0, 0.0, 0.0 };
float t_plane[] = { 0.0, 1.0, 0.0, 0.0 };
float r_plane[] = { 0.0, 0.0, 1.0, 0.0 };
float q_plane[] = { 0.0, 0.0, 0.0, 1.0 };
TRACE("D3DTSS_TCI_CAMERASPACEPOSITION - Set eye plane\n");
/* Todo: */
if (Value && Value != D3DTSS_TCI_CAMERASPACEPOSITION) {
/* ? disable GL_TEXTURE_GEN_n ? */
FIXME("Unhandled D3DTSS_TEXCOORDINDEX %lx\n", Value);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
glTexGenfv(GL_S, GL_EYE_PLANE, s_plane);
glTexGenfv(GL_T, GL_EYE_PLANE, t_plane);
glTexGenfv(GL_R, GL_EYE_PLANE, r_plane);
glTexGenfv(GL_Q, GL_EYE_PLANE, q_plane);
glPopMatrix();
TRACE("D3DTSS_TCI_CAMERASPACEPOSITION - Set GL_TEXTURE_GEN_x and GL_x, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR\n");
glEnable(GL_TEXTURE_GEN_S);
checkGLcall("glEnable(GL_TEXTURE_GEN_S);");
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
checkGLcall("glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR)");
glEnable(GL_TEXTURE_GEN_T);
checkGLcall("glEnable(GL_TEXTURE_GEN_T);");
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
checkGLcall("glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR)");
glEnable(GL_TEXTURE_GEN_R);
checkGLcall("glEnable(GL_TEXTURE_GEN_R);");
glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
checkGLcall("glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR)");
}
break;
default:
/* Todo: */
/* ? disable GL_TEXTURE_GEN_n ? */
FIXME("Unhandled D3DTSS_TEXCOORDINDEX %lx\n", Value);
break;
}
}
break;
/* Unhandled */
case D3DTSS_BUMPENVMAT00 :
case D3DTSS_BUMPENVMAT01 :
TRACE("BUMPENVMAT0%u Still a stub, Stage=%ld, Type=%d, Value =%ld\n", Type - D3DTSS_BUMPENVMAT00, Stage, Type, Value);
break;
case D3DTSS_BUMPENVMAT10 :
case D3DTSS_BUMPENVMAT11 :
TRACE("BUMPENVMAT1%u Still a stub, Stage=%ld, Type=%d, Value =%ld\n", Type - D3DTSS_BUMPENVMAT10, Stage, Type, Value);
break;
case D3DTSS_MIPMAPLODBIAS :
case D3DTSS_MAXMIPLEVEL :
case D3DTSS_MAXANISOTROPY :

View File

@ -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;

View File

@ -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) {

View File

@ -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) {

View File

@ -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])) {

View File

@ -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);
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 {
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);
TRACE("(%p) : stub\n", This);
if (This->Container) {
IDirect3DBaseTexture8 *cont = (IDirect3DBaseTexture8*) This->Container;
if (FALSE == This->locked) {
ERR("trying to lock unlocked surf@%p\n", This);
return D3DERR_INVALIDCALL;
}
/* Now setup the texture appropraitly */
int containerType = IDirect3DBaseTexture8Impl_GetType(cont);
if (containerType == D3DRTYPE_TEXTURE) {
TRACE("(%p) : stub\n", This);
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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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) {

View File

@ -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]);