- implemented render to surfaces (and render to new rendertargets)

using glx pbuffers (with a useful debug code to display rendered
  surface into window drawable)
- better cubetextures
- split utilities functions into utils.c and added more
- more readable debug again
- a better caps code (not perfect but i'll use glx code later)
- use of the new caps code
- begin of UpdateTexture
- begin of Cursor support
- cleaning most of deprecated #if 0/#endif
- correct some lockable/unlockable behavior
- correct some returns code
This commit is contained in:
Raphael Junqueira 2003-06-04 21:55:29 +00:00 committed by Alexandre Julliard
parent c312ff950b
commit 3cae8cfa69
14 changed files with 1541 additions and 825 deletions

View File

@ -23,6 +23,7 @@ C_SRCS = \
surface.c \
swapchain.c \
texture.c \
utils.c \
vertexbuffer.c \
volume.c \
volumetexture.c \

View File

@ -123,6 +123,21 @@ DWORD WINAPI IDirect3DBaseTexture8Impl_GetLevelCount(LPDIRECT3DBASETEX
return 0;
}
BOOL WINAPI IDirect3DBaseTexture8Impl_IsDirty(LPDIRECT3DBASETEXTURE8 iface) {
ICOM_THIS(IDirect3DBaseTexture8Impl,iface);
return This->Dirty;
}
BOOL WINAPI IDirect3DBaseTexture8Impl_SetDirty(LPDIRECT3DBASETEXTURE8 iface, BOOL dirty) {
BOOL old;
ICOM_THIS(IDirect3DBaseTexture8Impl,iface);
old = This->Dirty;
This->Dirty = dirty;
return old;
}
ICOM_VTABLE(IDirect3DBaseTexture8) Direct3DBaseTexture8_Vtbl =
{
ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE

View File

@ -140,7 +140,7 @@ void WINAPI IDirect3DCubeTexture8Impl_PreLoad(LPDIRECT3DCUBETEXTURE8
if (i == 0 && This->surfaces[0][i]->textureName != 0 && This->Dirty == FALSE) {
glEnable(GL_TEXTURE_CUBE_MAP_ARB);
#if defined(GL_VERSION_1_3)
glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, This->surfaces[0][i]->textureName);
glBindTexture(GL_TEXTURE_CUBE_MAP, This->surfaces[0][i]->textureName);
#else
glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, This->surfaces[0][i]->textureName);
#endif
@ -173,10 +173,17 @@ void WINAPI IDirect3DCubeTexture8Impl_PreLoad(LPDIRECT3DCUBETEXTURE8
}
for (j = 0; j < 6; j++) {
TRACE("Calling glTexImage2D %x i=%d, intfmt=%x, w=%d, h=%d,d=%d, glFmt=%x, glType=%lx, Mem=%p\n",
cube_targets[j], i, fmt2glintFmt(This->format),
This->surfaces[j][i]->myDesc.Width, This->surfaces[j][i]->myDesc.Height,
0, fmt2glFmt(This->format), fmt2glType(This->format),
IDirect3DSurface8Impl_CreateGLTexture((LPDIRECT3DSURFACE8) This->surfaces[j][i], cube_targets[j], i);
#if 0
TRACE("Calling glTexImage2D %x i=%d, intfmt=%x, w=%d, h=%d,d=%d, glFmt=%x, glType=%x, Mem=%p\n",
cube_targets[j],
i,
fmt2glintFmt(This->format),
This->surfaces[j][i]->myDesc.Width,
This->surfaces[j][i]->myDesc.Height,
0,
fmt2glFmt(This->format),
fmt2glType(This->format),
This->surfaces[j][i]->allocatedMemory);
glTexImage2D(cube_targets[j],
i,
@ -188,6 +195,7 @@ void WINAPI IDirect3DCubeTexture8Impl_PreLoad(LPDIRECT3DCUBETEXTURE8
fmt2glType(This->format),
This->surfaces[j][i]->allocatedMemory);
checkGLcall("glTexImage2D");
#endif
}
/* Removed glTexParameterf now TextureStageStates are initialized at startup */
This->Dirty = FALSE;

View File

@ -153,8 +153,61 @@ void CreateStateBlock(LPDIRECT3DDEVICE8 iface);
} \
}
#define checkGLSupport(ExtName) FALSE/*(TRUE == This->direct3d8->glInfo.supported[ExtName])*/
#define GLExtCall(FuncName) /*(This->direct3d8->glInfo.FuncName)*/
typedef enum _GL_SupportedExt {
/* ARB */
ARB_MULTISAMPLE,
ARB_MULTITEXTURE,
ARB_POINT_PARAMETERS,
ARB_TEXTURE_COMPRESSION,
ARB_TEXTURE_CUBE_MAP,
ARB_TEXTURE_ENV_DOT3,
ARB_VERTEX_PROGRAM,
ARB_VERTEX_BLEND,
/* EXT */
EXT_FOG_COORD,
EXT_PALETTED_TEXTURE,
EXT_SECONDARY_COLOR,
EXT_TEXTURE_COMPRESSION_S3TC,
EXT_TEXTURE_LOD,
EXT_TEXTURE_LOD_BIAS,
EXT_VERTEX_WEIGHTING,
/* NVIDIA */
NV_VERTEX_PROGRAM,
/* ATI */
EXT_VERTEX_SHADER,
OPENGL_SUPPORTED_EXT_END
} GL_SupportedExt;
typedef enum _GL_VSVersion {
VS_VERSION_NOT_SUPPORTED = 0x0,
VS_VERSION_10 = 0x10,
VS_VERSION_11 = 0x11,
VS_VERSION_20 = 0x20,
VS_VERSION_30 = 0x30,
/*Force 32-bits*/
VS_VERSION_FORCE_DWORD = 0x7FFFFFFF
} GL_VSVersion;
typedef struct _GL_Info {
/**
* CAPS Constants
*/
UINT max_lights;
UINT max_textures;
UINT max_clipplanes;
GL_VSVersion vs_arb_version;
GL_VSVersion vs_nv_version;
GL_VSVersion vs_ati_version;
BOOL supported[25];
} GL_Info;
#define GL_LIMITS(ExtName) (This->direct3d8->gl_info.max_##ExtName)
#define GL_SUPPORT(ExtName) (TRUE == This->direct3d8->gl_info.supported[ExtName])
#define GL_SUPPORT_DEV(ExtName, dev) (TRUE == (dev)->direct3d8->gl_info.supported[ExtName])
#define GLExtCall(FuncName) /*(This->direct3d8->glInfo.FuncName)*/
#define D3DCOLOR_R(dw) (((float) (((dw) >> 16) & 0xFF)) / 255.0f)
@ -204,6 +257,7 @@ struct IDirect3D8Impl
DWORD ref;
/* IDirect3D8 fields */
GL_Info gl_info;
};
/* IUnknown: */
@ -252,9 +306,14 @@ struct IDirect3DDevice8Impl
/* IDirect3DDevice8 fields */
IDirect3D8Impl *direct3d8;
IDirect3DSurface8Impl *frontBuffer;
IDirect3DSurface8Impl *backBuffer;
IDirect3DSurface8Impl *depthStencilBuffer;
IDirect3DSurface8Impl *renderTarget;
IDirect3DSurface8Impl *stencilBufferTarget;
D3DPRESENT_PARAMETERS PresentParms;
D3DDEVICE_CREATION_PARAMETERS CreateParms;
@ -288,19 +347,31 @@ struct IDirect3DDevice8Impl
XVisualInfo *visInfo;
Display *display;
Window win;
GLXContext render_ctx;
Drawable drawable;
/* OpenGL Extension related */
#if 0
BOOL isMultiTexture;
BOOL isDot3;
UINT TextureUnits;
UINT clipPlanes;
UINT maxLights;
#endif
/* Cursor management */
BOOL bCursorVisible;
UINT xHotSpot;
UINT yHotSpot;
UINT xScreenSpace;
UINT yScreenSpace;
GLint cursor;
UINT dummyTextureName[8];
};
/* IUnknown: */
extern HRESULT WINAPI IDirect3DDevice8Impl_QueryInterface(LPDIRECT3DDEVICE8 iface,REFIID refiid,LPVOID *obj);
extern HRESULT WINAPI IDirect3DDevice8Impl_QueryInterface(LPDIRECT3DDEVICE8 iface, REFIID refiid, LPVOID *obj);
extern ULONG WINAPI IDirect3DDevice8Impl_AddRef(LPDIRECT3DDEVICE8 iface);
extern ULONG WINAPI IDirect3DDevice8Impl_Release(LPDIRECT3DDEVICE8 iface);
@ -313,47 +384,47 @@ extern HRESULT WINAPI IDirect3DDevice8Impl_GetDeviceCaps(LPDIRECT3DDEVICE8 ifa
extern HRESULT WINAPI IDirect3DDevice8Impl_GetDisplayMode(LPDIRECT3DDEVICE8 iface, D3DDISPLAYMODE* pMode);
extern HRESULT WINAPI IDirect3DDevice8Impl_GetCreationParameters(LPDIRECT3DDEVICE8 iface, D3DDEVICE_CREATION_PARAMETERS* pParameters);
extern HRESULT WINAPI IDirect3DDevice8Impl_SetCursorProperties(LPDIRECT3DDEVICE8 iface, UINT XHotSpot, UINT YHotSpot, IDirect3DSurface8* pCursorBitmap);
extern void WINAPI IDirect3DDevice8Impl_SetCursorPosition(LPDIRECT3DDEVICE8 iface, UINT XScreenSpace, UINT YScreenSpace,DWORD Flags);
extern void WINAPI IDirect3DDevice8Impl_SetCursorPosition(LPDIRECT3DDEVICE8 iface, UINT XScreenSpace, UINT YScreenSpace, DWORD Flags);
extern BOOL WINAPI IDirect3DDevice8Impl_ShowCursor(LPDIRECT3DDEVICE8 iface, BOOL bShow);
extern HRESULT WINAPI IDirect3DDevice8Impl_CreateAdditionalSwapChain(LPDIRECT3DDEVICE8 iface, D3DPRESENT_PARAMETERS* pPresentationParameters, IDirect3DSwapChain8** pSwapChain);
extern HRESULT WINAPI IDirect3DDevice8Impl_Reset(LPDIRECT3DDEVICE8 iface, D3DPRESENT_PARAMETERS* pPresentationParameters);
extern HRESULT WINAPI IDirect3DDevice8Impl_Present(LPDIRECT3DDEVICE8 iface, CONST RECT* pSourceRect,CONST RECT* pDestRect,HWND hDestWindowOverride,CONST RGNDATA* pDirtyRegion);
extern HRESULT WINAPI IDirect3DDevice8Impl_GetBackBuffer(LPDIRECT3DDEVICE8 iface, UINT BackBuffer,D3DBACKBUFFER_TYPE Type,IDirect3DSurface8** ppBackBuffer);
extern HRESULT WINAPI IDirect3DDevice8Impl_Present(LPDIRECT3DDEVICE8 iface, CONST RECT* pSourceRect, CONST RECT* pDestRect, HWND hDestWindowOverride, CONST RGNDATA* pDirtyRegion);
extern HRESULT WINAPI IDirect3DDevice8Impl_GetBackBuffer(LPDIRECT3DDEVICE8 iface, UINT BackBuffer, D3DBACKBUFFER_TYPE Type, IDirect3DSurface8** ppBackBuffer);
extern HRESULT WINAPI IDirect3DDevice8Impl_GetRasterStatus(LPDIRECT3DDEVICE8 iface, D3DRASTER_STATUS* pRasterStatus);
extern void WINAPI IDirect3DDevice8Impl_SetGammaRamp(LPDIRECT3DDEVICE8 iface, DWORD Flags,CONST D3DGAMMARAMP* pRamp);
extern void WINAPI IDirect3DDevice8Impl_SetGammaRamp(LPDIRECT3DDEVICE8 iface, DWORD Flags, CONST D3DGAMMARAMP* pRamp);
extern void WINAPI IDirect3DDevice8Impl_GetGammaRamp(LPDIRECT3DDEVICE8 iface, D3DGAMMARAMP* pRamp);
extern HRESULT WINAPI IDirect3DDevice8Impl_CreateTexture(LPDIRECT3DDEVICE8 iface, UINT Width,UINT Height,UINT Levels,DWORD Usage,D3DFORMAT Format,D3DPOOL Pool,IDirect3DTexture8** ppTexture);
extern HRESULT WINAPI IDirect3DDevice8Impl_CreateVolumeTexture(LPDIRECT3DDEVICE8 iface, UINT Width,UINT Height,UINT Depth,UINT Levels,DWORD Usage,D3DFORMAT Format,D3DPOOL Pool,IDirect3DVolumeTexture8** ppVolumeTexture);
extern HRESULT WINAPI IDirect3DDevice8Impl_CreateCubeTexture(LPDIRECT3DDEVICE8 iface, UINT EdgeLength,UINT Levels,DWORD Usage,D3DFORMAT Format,D3DPOOL Pool,IDirect3DCubeTexture8** ppCubeTexture);
extern HRESULT WINAPI IDirect3DDevice8Impl_CreateVertexBuffer(LPDIRECT3DDEVICE8 iface, UINT Length,DWORD Usage,DWORD FVF,D3DPOOL Pool,IDirect3DVertexBuffer8** ppVertexBuffer);
extern HRESULT WINAPI IDirect3DDevice8Impl_CreateIndexBuffer(LPDIRECT3DDEVICE8 iface, UINT Length,DWORD Usage,D3DFORMAT Format,D3DPOOL Pool,IDirect3DIndexBuffer8** ppIndexBuffer);
extern HRESULT WINAPI IDirect3DDevice8Impl_CreateRenderTarget(LPDIRECT3DDEVICE8 iface, UINT Width,UINT Height,D3DFORMAT Format,D3DMULTISAMPLE_TYPE MultiSample,BOOL Lockable,IDirect3DSurface8** ppSurface);
extern HRESULT WINAPI IDirect3DDevice8Impl_CreateDepthStencilSurface(LPDIRECT3DDEVICE8 iface, UINT Width,UINT Height,D3DFORMAT Format,D3DMULTISAMPLE_TYPE MultiSample,IDirect3DSurface8** ppSurface);
extern HRESULT WINAPI IDirect3DDevice8Impl_CreateImageSurface(LPDIRECT3DDEVICE8 iface, UINT Width,UINT Height,D3DFORMAT Format,IDirect3DSurface8** ppSurface);
extern HRESULT WINAPI IDirect3DDevice8Impl_CopyRects(LPDIRECT3DDEVICE8 iface, IDirect3DSurface8* pSourceSurface,CONST RECT* pSourceRectsArray,UINT cRects,IDirect3DSurface8* pDestinationSurface,CONST POINT* pDestPointsArray);
extern HRESULT WINAPI IDirect3DDevice8Impl_UpdateTexture(LPDIRECT3DDEVICE8 iface, IDirect3DBaseTexture8* pSourceTexture,IDirect3DBaseTexture8* pDestinationTexture);
extern HRESULT WINAPI IDirect3DDevice8Impl_CreateTexture(LPDIRECT3DDEVICE8 iface, UINT Width, UINT Height, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DTexture8** ppTexture);
extern HRESULT WINAPI IDirect3DDevice8Impl_CreateVolumeTexture(LPDIRECT3DDEVICE8 iface, UINT Width, UINT Height, UINT Depth, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DVolumeTexture8** ppVolumeTexture);
extern HRESULT WINAPI IDirect3DDevice8Impl_CreateCubeTexture(LPDIRECT3DDEVICE8 iface, UINT EdgeLength, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DCubeTexture8** ppCubeTexture);
extern HRESULT WINAPI IDirect3DDevice8Impl_CreateVertexBuffer(LPDIRECT3DDEVICE8 iface, UINT Length, DWORD Usage, DWORD FVF, D3DPOOL Pool, IDirect3DVertexBuffer8** ppVertexBuffer);
extern HRESULT WINAPI IDirect3DDevice8Impl_CreateIndexBuffer(LPDIRECT3DDEVICE8 iface, UINT Length, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DIndexBuffer8** ppIndexBuffer);
extern HRESULT WINAPI IDirect3DDevice8Impl_CreateRenderTarget(LPDIRECT3DDEVICE8 iface, UINT Width, UINT Height, D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, BOOL Lockable, IDirect3DSurface8** ppSurface);
extern HRESULT WINAPI IDirect3DDevice8Impl_CreateDepthStencilSurface(LPDIRECT3DDEVICE8 iface, UINT Width, UINT Height, D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, IDirect3DSurface8** ppSurface);
extern HRESULT WINAPI IDirect3DDevice8Impl_CreateImageSurface(LPDIRECT3DDEVICE8 iface, UINT Width, UINT Height, D3DFORMAT Format, IDirect3DSurface8** ppSurface);
extern HRESULT WINAPI IDirect3DDevice8Impl_CopyRects(LPDIRECT3DDEVICE8 iface, IDirect3DSurface8* pSourceSurface, CONST RECT* pSourceRectsArray, UINT cRects, IDirect3DSurface8* pDestinationSurface, CONST POINT* pDestPointsArray);
extern HRESULT WINAPI IDirect3DDevice8Impl_UpdateTexture(LPDIRECT3DDEVICE8 iface, IDirect3DBaseTexture8* pSourceTexture, IDirect3DBaseTexture8* pDestinationTexture);
extern HRESULT WINAPI IDirect3DDevice8Impl_GetFrontBuffer(LPDIRECT3DDEVICE8 iface, IDirect3DSurface8* pDestSurface);
extern HRESULT WINAPI IDirect3DDevice8Impl_SetRenderTarget(LPDIRECT3DDEVICE8 iface, IDirect3DSurface8* pRenderTarget,IDirect3DSurface8* pNewZStencil);
extern HRESULT WINAPI IDirect3DDevice8Impl_SetRenderTarget(LPDIRECT3DDEVICE8 iface, IDirect3DSurface8* pRenderTarget, IDirect3DSurface8* pNewZStencil);
extern HRESULT WINAPI IDirect3DDevice8Impl_GetRenderTarget(LPDIRECT3DDEVICE8 iface, IDirect3DSurface8** ppRenderTarget);
extern HRESULT WINAPI IDirect3DDevice8Impl_GetDepthStencilSurface(LPDIRECT3DDEVICE8 iface, IDirect3DSurface8** ppZStencilSurface);
extern HRESULT WINAPI IDirect3DDevice8Impl_BeginScene(LPDIRECT3DDEVICE8 iface);
extern HRESULT WINAPI IDirect3DDevice8Impl_EndScene(LPDIRECT3DDEVICE8 iface);
extern HRESULT WINAPI IDirect3DDevice8Impl_Clear(LPDIRECT3DDEVICE8 iface, DWORD Count,CONST D3DRECT* pRects,DWORD Flags,D3DCOLOR Color,float Z,DWORD Stencil);
extern HRESULT WINAPI IDirect3DDevice8Impl_SetTransform(LPDIRECT3DDEVICE8 iface, D3DTRANSFORMSTATETYPE State,CONST D3DMATRIX* pMatrix);
extern HRESULT WINAPI IDirect3DDevice8Impl_GetTransform(LPDIRECT3DDEVICE8 iface, D3DTRANSFORMSTATETYPE State,D3DMATRIX* pMatrix);
extern HRESULT WINAPI IDirect3DDevice8Impl_Clear(LPDIRECT3DDEVICE8 iface, DWORD Count, CONST D3DRECT* pRects, DWORD Flags, D3DCOLOR Color, float Z, DWORD Stencil);
extern HRESULT WINAPI IDirect3DDevice8Impl_SetTransform(LPDIRECT3DDEVICE8 iface, D3DTRANSFORMSTATETYPE State, CONST D3DMATRIX* pMatrix);
extern HRESULT WINAPI IDirect3DDevice8Impl_GetTransform(LPDIRECT3DDEVICE8 iface, D3DTRANSFORMSTATETYPE State, D3DMATRIX* pMatrix);
extern HRESULT WINAPI IDirect3DDevice8Impl_MultiplyTransform(LPDIRECT3DDEVICE8 iface, D3DTRANSFORMSTATETYPE State, CONST D3DMATRIX* pMatrix);
extern HRESULT WINAPI IDirect3DDevice8Impl_SetViewport(LPDIRECT3DDEVICE8 iface, CONST D3DVIEWPORT8* pViewport);
extern HRESULT WINAPI IDirect3DDevice8Impl_GetViewport(LPDIRECT3DDEVICE8 iface, D3DVIEWPORT8* pViewport);
extern HRESULT WINAPI IDirect3DDevice8Impl_SetMaterial(LPDIRECT3DDEVICE8 iface, CONST D3DMATERIAL8* pMaterial);
extern HRESULT WINAPI IDirect3DDevice8Impl_GetMaterial(LPDIRECT3DDEVICE8 iface, D3DMATERIAL8* pMaterial);
extern HRESULT WINAPI IDirect3DDevice8Impl_SetLight(LPDIRECT3DDEVICE8 iface, DWORD Index,CONST D3DLIGHT8* pLight);
extern HRESULT WINAPI IDirect3DDevice8Impl_GetLight(LPDIRECT3DDEVICE8 iface, DWORD Index,D3DLIGHT8* pLight);
extern HRESULT WINAPI IDirect3DDevice8Impl_LightEnable(LPDIRECT3DDEVICE8 iface, DWORD Index,BOOL Enable);
extern HRESULT WINAPI IDirect3DDevice8Impl_GetLightEnable(LPDIRECT3DDEVICE8 iface, DWORD Index,BOOL* pEnable);
extern HRESULT WINAPI IDirect3DDevice8Impl_SetClipPlane(LPDIRECT3DDEVICE8 iface, DWORD Index,CONST float* pPlane);
extern HRESULT WINAPI IDirect3DDevice8Impl_GetClipPlane(LPDIRECT3DDEVICE8 iface, DWORD Index,float* pPlane);
extern HRESULT WINAPI IDirect3DDevice8Impl_SetRenderState(LPDIRECT3DDEVICE8 iface, D3DRENDERSTATETYPE State,DWORD Value);
extern HRESULT WINAPI IDirect3DDevice8Impl_GetRenderState(LPDIRECT3DDEVICE8 iface, D3DRENDERSTATETYPE State,DWORD* pValue);
extern HRESULT WINAPI IDirect3DDevice8Impl_SetLight(LPDIRECT3DDEVICE8 iface, DWORD Index, CONST D3DLIGHT8* pLight);
extern HRESULT WINAPI IDirect3DDevice8Impl_GetLight(LPDIRECT3DDEVICE8 iface, DWORD Index, D3DLIGHT8* pLight);
extern HRESULT WINAPI IDirect3DDevice8Impl_LightEnable(LPDIRECT3DDEVICE8 iface, DWORD Index, BOOL Enable);
extern HRESULT WINAPI IDirect3DDevice8Impl_GetLightEnable(LPDIRECT3DDEVICE8 iface, DWORD Index, BOOL* pEnable);
extern HRESULT WINAPI IDirect3DDevice8Impl_SetClipPlane(LPDIRECT3DDEVICE8 iface, DWORD Index, CONST float* pPlane);
extern HRESULT WINAPI IDirect3DDevice8Impl_GetClipPlane(LPDIRECT3DDEVICE8 iface, DWORD Index, float* pPlane);
extern HRESULT WINAPI IDirect3DDevice8Impl_SetRenderState(LPDIRECT3DDEVICE8 iface, D3DRENDERSTATETYPE State, DWORD Value);
extern HRESULT WINAPI IDirect3DDevice8Impl_GetRenderState(LPDIRECT3DDEVICE8 iface, D3DRENDERSTATETYPE State, DWORD* pValue);
extern HRESULT WINAPI IDirect3DDevice8Impl_BeginStateBlock(LPDIRECT3DDEVICE8 iface);
extern HRESULT WINAPI IDirect3DDevice8Impl_EndStateBlock(LPDIRECT3DDEVICE8 iface, DWORD* pToken);
extern HRESULT WINAPI IDirect3DDevice8Impl_ApplyStateBlock(LPDIRECT3DDEVICE8 iface, DWORD Token);
@ -362,20 +433,20 @@ extern HRESULT WINAPI IDirect3DDevice8Impl_DeleteStateBlock(LPDIRECT3DDEVICE8
extern HRESULT WINAPI IDirect3DDevice8Impl_CreateStateBlock(LPDIRECT3DDEVICE8 iface, D3DSTATEBLOCKTYPE Type,DWORD* pToken);
extern HRESULT WINAPI IDirect3DDevice8Impl_SetClipStatus(LPDIRECT3DDEVICE8 iface, CONST D3DCLIPSTATUS8* pClipStatus);
extern HRESULT WINAPI IDirect3DDevice8Impl_GetClipStatus(LPDIRECT3DDEVICE8 iface, D3DCLIPSTATUS8* pClipStatus);
extern HRESULT WINAPI IDirect3DDevice8Impl_GetTexture(LPDIRECT3DDEVICE8 iface, DWORD Stage,IDirect3DBaseTexture8** ppTexture);
extern HRESULT WINAPI IDirect3DDevice8Impl_SetTexture(LPDIRECT3DDEVICE8 iface, DWORD Stage,IDirect3DBaseTexture8* pTexture);
extern HRESULT WINAPI IDirect3DDevice8Impl_GetTextureStageState(LPDIRECT3DDEVICE8 iface, DWORD Stage,D3DTEXTURESTAGESTATETYPE Type,DWORD* pValue);
extern HRESULT WINAPI IDirect3DDevice8Impl_SetTextureStageState(LPDIRECT3DDEVICE8 iface, DWORD Stage,D3DTEXTURESTAGESTATETYPE Type,DWORD Value);
extern HRESULT WINAPI IDirect3DDevice8Impl_GetTexture(LPDIRECT3DDEVICE8 iface, DWORD Stage, IDirect3DBaseTexture8** ppTexture);
extern HRESULT WINAPI IDirect3DDevice8Impl_SetTexture(LPDIRECT3DDEVICE8 iface, DWORD Stage, IDirect3DBaseTexture8* pTexture);
extern HRESULT WINAPI IDirect3DDevice8Impl_GetTextureStageState(LPDIRECT3DDEVICE8 iface, DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD* pValue);
extern HRESULT WINAPI IDirect3DDevice8Impl_SetTextureStageState(LPDIRECT3DDEVICE8 iface, DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD Value);
extern HRESULT WINAPI IDirect3DDevice8Impl_ValidateDevice(LPDIRECT3DDEVICE8 iface, DWORD* pNumPasses);
extern HRESULT WINAPI IDirect3DDevice8Impl_GetInfo(LPDIRECT3DDEVICE8 iface, DWORD DevInfoID,void* pDevInfoStruct,DWORD DevInfoStructSize);
extern HRESULT WINAPI IDirect3DDevice8Impl_SetPaletteEntries(LPDIRECT3DDEVICE8 iface, UINT PaletteNumber,CONST PALETTEENTRY* pEntries);
extern HRESULT WINAPI IDirect3DDevice8Impl_GetPaletteEntries(LPDIRECT3DDEVICE8 iface, UINT PaletteNumber,PALETTEENTRY* pEntries);
extern HRESULT WINAPI IDirect3DDevice8Impl_GetInfo(LPDIRECT3DDEVICE8 iface, DWORD DevInfoID, void* pDevInfoStruct, DWORD DevInfoStructSize);
extern HRESULT WINAPI IDirect3DDevice8Impl_SetPaletteEntries(LPDIRECT3DDEVICE8 iface, UINT PaletteNumber, CONST PALETTEENTRY* pEntries);
extern HRESULT WINAPI IDirect3DDevice8Impl_GetPaletteEntries(LPDIRECT3DDEVICE8 iface, UINT PaletteNumber, PALETTEENTRY* pEntries);
extern HRESULT WINAPI IDirect3DDevice8Impl_SetCurrentTexturePalette(LPDIRECT3DDEVICE8 iface, UINT PaletteNumber);
extern HRESULT WINAPI IDirect3DDevice8Impl_GetCurrentTexturePalette(LPDIRECT3DDEVICE8 iface, UINT *PaletteNumber);
extern HRESULT WINAPI IDirect3DDevice8Impl_DrawPrimitive(LPDIRECT3DDEVICE8 iface, D3DPRIMITIVETYPE PrimitiveType,UINT StartVertex,UINT PrimitiveCount);
extern HRESULT WINAPI IDirect3DDevice8Impl_DrawIndexedPrimitive(LPDIRECT3DDEVICE8 iface, D3DPRIMITIVETYPE PrimitiveType,UINT minIndex,UINT NumVertices,UINT startIndex,UINT primCount);
extern HRESULT WINAPI IDirect3DDevice8Impl_DrawPrimitiveUP(LPDIRECT3DDEVICE8 iface, D3DPRIMITIVETYPE PrimitiveType,UINT PrimitiveCount,CONST void* pVertexStreamZeroData,UINT VertexStreamZeroStride);
extern HRESULT WINAPI IDirect3DDevice8Impl_DrawIndexedPrimitiveUP(LPDIRECT3DDEVICE8 iface, D3DPRIMITIVETYPE PrimitiveType,UINT MinVertexIndex,UINT NumVertexIndices,UINT PrimitiveCount,CONST void* pIndexData,D3DFORMAT IndexDataFormat,CONST void* pVertexStreamZeroData,UINT VertexStreamZeroStride);
extern HRESULT WINAPI IDirect3DDevice8Impl_DrawPrimitive(LPDIRECT3DDEVICE8 iface, D3DPRIMITIVETYPE PrimitiveType, UINT StartVertex, UINT PrimitiveCount);
extern HRESULT WINAPI IDirect3DDevice8Impl_DrawIndexedPrimitive(LPDIRECT3DDEVICE8 iface, D3DPRIMITIVETYPE PrimitiveType, UINT minIndex, UINT NumVertices, UINT startIndex, UINT primCount);
extern HRESULT WINAPI IDirect3DDevice8Impl_DrawPrimitiveUP(LPDIRECT3DDEVICE8 iface, D3DPRIMITIVETYPE PrimitiveType, UINT PrimitiveCount, CONST void* pVertexStreamZeroData, UINT VertexStreamZeroStride);
extern HRESULT WINAPI IDirect3DDevice8Impl_DrawIndexedPrimitiveUP(LPDIRECT3DDEVICE8 iface, D3DPRIMITIVETYPE PrimitiveType, UINT MinVertexIndex, UINT NumVertexIndices, UINT PrimitiveCount, CONST void* pIndexData, D3DFORMAT IndexDataFormat, CONST void* pVertexStreamZeroData, UINT VertexStreamZeroStride);
extern HRESULT WINAPI IDirect3DDevice8Impl_ProcessVertices(LPDIRECT3DDEVICE8 iface, UINT SrcStartIndex,UINT DestIndex,UINT VertexCount,IDirect3DVertexBuffer8* pDestBuffer,DWORD Flags);
extern HRESULT WINAPI IDirect3DDevice8Impl_CreateVertexShader(LPDIRECT3DDEVICE8 iface, CONST DWORD* pDeclaration,CONST DWORD* pFunction,DWORD* pHandle,DWORD Usage);
extern HRESULT WINAPI IDirect3DDevice8Impl_SetVertexShader(LPDIRECT3DDEVICE8 iface, DWORD Handle);
@ -400,6 +471,11 @@ extern HRESULT WINAPI IDirect3DDevice8Impl_DrawRectPatch(LPDIRECT3DDEVICE8 ifa
extern HRESULT WINAPI IDirect3DDevice8Impl_DrawTriPatch(LPDIRECT3DDEVICE8 iface, UINT Handle,CONST float* pNumSegs,CONST D3DTRIPATCH_INFO* pTriPatchInfo);
extern HRESULT WINAPI IDirect3DDevice8Impl_DeletePatch(LPDIRECT3DDEVICE8 iface, UINT Handle);
/* internal Interfaces */
extern HRESULT WINAPI IDirect3DDevice8Impl_CleanRender(LPDIRECT3DDEVICE8 iface);
extern HRESULT WINAPI IDirect3DDevice8Impl_ActiveRender(LPDIRECT3DDEVICE8 iface, IDirect3DSurface8* RenderSurface, IDirect3DSurface8* StencilSurface);
/* ---------------- */
/* IDirect3DVolume8 */
/* ---------------- */
@ -444,6 +520,7 @@ extern HRESULT WINAPI IDirect3DVolume8Impl_GetDesc(LPDIRECT3DVOLUME8 iface, D3DV
extern HRESULT WINAPI IDirect3DVolume8Impl_LockBox(LPDIRECT3DVOLUME8 iface, D3DLOCKED_BOX* pLockedVolume,CONST D3DBOX* pBox, DWORD Flags);
extern HRESULT WINAPI IDirect3DVolume8Impl_UnlockBox(LPDIRECT3DVOLUME8 iface);
/* ------------------- */
/* IDirect3DSwapChain8 */
/* ------------------- */
@ -477,6 +554,7 @@ extern ULONG WINAPI IDirect3DSwapChain8Impl_Release(LPDIRECT3DSWAPCHAIN8 iface
extern HRESULT WINAPI IDirect3DSwapChain8Impl_Present(LPDIRECT3DSWAPCHAIN8 iface, CONST RECT* pSourceRect, CONST RECT* pDestRect, HWND hDestWindowOverride,CONST RGNDATA* pDirtyRegion);
extern HRESULT WINAPI IDirect3DSwapChain8Impl_GetBackBuffer(LPDIRECT3DSWAPCHAIN8 iface, UINT BackBuffer, D3DBACKBUFFER_TYPE Type,IDirect3DSurface8** ppBackBuffer);
/* ----------------- */
/* IDirect3DSurface8 */
/* ----------------- */
@ -500,15 +578,16 @@ struct IDirect3DSurface8Impl
D3DRESOURCETYPE ResourceType;
IUnknown *Container;
D3DSURFACE_DESC myDesc;
BYTE *allocatedMemory;
UINT textureName;
UINT bytesPerPixel;
BOOL lockable;
BOOL locked;
RECT lockedRect;
BOOL Dirty;
};
/* IUnknown: */
@ -526,6 +605,10 @@ extern HRESULT WINAPI IDirect3DSurface8Impl_GetDesc(LPDIRECT3DSURFACE8 iface, D3
extern HRESULT WINAPI IDirect3DSurface8Impl_LockRect(LPDIRECT3DSURFACE8 iface, D3DLOCKED_RECT* pLockedRect, CONST RECT* pRect,DWORD Flags);
extern HRESULT WINAPI IDirect3DSurface8Impl_UnlockRect(LPDIRECT3DSURFACE8 iface);
/* internal Interfaces */
extern HRESULT WINAPI IDirect3DSurface8Impl_CreateGLTexture(LPDIRECT3DSURFACE8 iface, GLenum gl_target, GLenum gl_level);
/* ------------------ */
/* IDirect3DResource8 */
/* ------------------ */
@ -564,6 +647,10 @@ extern DWORD WINAPI IDirect3DResource8Impl_GetPriority(LPDIRECT3DRESOU
extern void WINAPI IDirect3DResource8Impl_PreLoad(LPDIRECT3DRESOURCE8 iface);
extern D3DRESOURCETYPE WINAPI IDirect3DResource8Impl_GetType(LPDIRECT3DRESOURCE8 iface);
/* internal Interfaces */
extern D3DPOOL WINAPI IDirect3DResource8Impl_GetPool(LPDIRECT3DRESOURCE8 iface);
/* ---------------------- */
/* IDirect3DVertexBuffer8 */
/* ---------------------- */
@ -611,6 +698,7 @@ extern HRESULT WINAPI IDirect3DVertexBuffer8Impl_Lock(LPDIRECT3DVERTEXBU
extern HRESULT WINAPI IDirect3DVertexBuffer8Impl_Unlock(LPDIRECT3DVERTEXBUFFER8 iface);
extern HRESULT WINAPI IDirect3DVertexBuffer8Impl_GetDesc(LPDIRECT3DVERTEXBUFFER8 iface, D3DVERTEXBUFFER_DESC *pDesc);
/* --------------------- */
/* IDirect3DIndexBuffer8 */
/* --------------------- */
@ -658,6 +746,7 @@ extern HRESULT WINAPI IDirect3DIndexBuffer8Impl_Lock(LPDIRECT3DINDEXBUFF
extern HRESULT WINAPI IDirect3DIndexBuffer8Impl_Unlock(LPDIRECT3DINDEXBUFFER8 iface);
extern HRESULT WINAPI IDirect3DIndexBuffer8Impl_GetDesc(LPDIRECT3DINDEXBUFFER8 iface, D3DINDEXBUFFER_DESC *pDesc);
/* --------------------- */
/* IDirect3DBaseTexture8 */
/* --------------------- */
@ -682,7 +771,8 @@ struct IDirect3DBaseTexture8Impl
/* IDirect3DBaseTexture8 fields */
BOOL Dirty;
D3DFORMAT format;
UINT levels;
/*
*BOOL isManaged;
*DWORD lod;
@ -709,6 +799,11 @@ extern DWORD WINAPI IDirect3DBaseTexture8Impl_SetLOD(LPDIRECT3DBASETEX
extern DWORD WINAPI IDirect3DBaseTexture8Impl_GetLOD(LPDIRECT3DBASETEXTURE8 iface);
extern DWORD WINAPI IDirect3DBaseTexture8Impl_GetLevelCount(LPDIRECT3DBASETEXTURE8 iface);
/* internal Interfaces */
extern BOOL WINAPI IDirect3DBaseTexture8Impl_IsDirty(LPDIRECT3DBASETEXTURE8 iface);
extern BOOL WINAPI IDirect3DBaseTexture8Impl_SetDirty(LPDIRECT3DBASETEXTURE8 iface, BOOL dirty);
/* --------------------- */
/* IDirect3DCubeTexture8 */
/* --------------------- */
@ -733,12 +828,12 @@ struct IDirect3DCubeTexture8Impl
/* IDirect3DBaseTexture8 fields */
BOOL Dirty;
D3DFORMAT format;
UINT levels;
/* IDirect3DCubeTexture8 fields */
UINT edgeLength;
DWORD usage;
UINT levels;
D3DFORMAT format;
IDirect3DSurface8Impl *surfaces[6][MAX_LEVELS];
};
@ -764,11 +859,12 @@ extern DWORD WINAPI IDirect3DCubeTexture8Impl_GetLOD(LPDIRECT3DCUBETEX
extern DWORD WINAPI IDirect3DCubeTexture8Impl_GetLevelCount(LPDIRECT3DCUBETEXTURE8 iface);
/* IDirect3DCubeTexture8 */
extern HRESULT WINAPI IDirect3DCubeTexture8Impl_GetLevelDesc(LPDIRECT3DCUBETEXTURE8 iface,UINT Level,D3DSURFACE_DESC *pDesc);
extern HRESULT WINAPI IDirect3DCubeTexture8Impl_GetCubeMapSurface(LPDIRECT3DCUBETEXTURE8 iface,D3DCUBEMAP_FACES FaceType,UINT Level,IDirect3DSurface8** ppCubeMapSurface);
extern HRESULT WINAPI IDirect3DCubeTexture8Impl_LockRect(LPDIRECT3DCUBETEXTURE8 iface,D3DCUBEMAP_FACES FaceType,UINT Level,D3DLOCKED_RECT* pLockedRect,CONST RECT* pRect,DWORD Flags);
extern HRESULT WINAPI IDirect3DCubeTexture8Impl_UnlockRect(LPDIRECT3DCUBETEXTURE8 iface,D3DCUBEMAP_FACES FaceType,UINT Level);
extern HRESULT WINAPI IDirect3DCubeTexture8Impl_AddDirtyRect(LPDIRECT3DCUBETEXTURE8 iface,D3DCUBEMAP_FACES FaceType,CONST RECT* pDirtyRect);
extern HRESULT WINAPI IDirect3DCubeTexture8Impl_GetLevelDesc(LPDIRECT3DCUBETEXTURE8 iface, UINT Level, D3DSURFACE_DESC* pDesc);
extern HRESULT WINAPI IDirect3DCubeTexture8Impl_GetCubeMapSurface(LPDIRECT3DCUBETEXTURE8 iface, D3DCUBEMAP_FACES FaceType, UINT Level, IDirect3DSurface8** ppCubeMapSurface);
extern HRESULT WINAPI IDirect3DCubeTexture8Impl_LockRect(LPDIRECT3DCUBETEXTURE8 iface, D3DCUBEMAP_FACES FaceType, UINT Level, D3DLOCKED_RECT* pLockedRect, CONST RECT* pRect, DWORD Flags);
extern HRESULT WINAPI IDirect3DCubeTexture8Impl_UnlockRect(LPDIRECT3DCUBETEXTURE8 iface, D3DCUBEMAP_FACES FaceType, UINT Level);
extern HRESULT WINAPI IDirect3DCubeTexture8Impl_AddDirtyRect(LPDIRECT3DCUBETEXTURE8 iface, D3DCUBEMAP_FACES FaceType, CONST RECT* pDirtyRect);
/* ----------------- */
/* IDirect3DTexture8 */
@ -794,13 +890,13 @@ struct IDirect3DTexture8Impl
/* IDirect3DBaseTexture8 fields */
BOOL Dirty;
D3DFORMAT format;
UINT levels;
/* IDirect3DTexture8 fields */
UINT width;
UINT height;
UINT levels;
DWORD usage;
D3DFORMAT format;
IDirect3DSurface8Impl *surfaces[MAX_LEVELS];
};
@ -826,12 +922,13 @@ extern DWORD WINAPI IDirect3DTexture8Impl_GetLOD(LPDIRECT3DTEXTURE8 if
extern DWORD WINAPI IDirect3DTexture8Impl_GetLevelCount(LPDIRECT3DTEXTURE8 iface);
/* IDirect3DTexture8: */
extern HRESULT WINAPI IDirect3DTexture8Impl_GetLevelDesc(LPDIRECT3DTEXTURE8 iface, UINT Level,D3DSURFACE_DESC* pDesc);
extern HRESULT WINAPI IDirect3DTexture8Impl_GetSurfaceLevel(LPDIRECT3DTEXTURE8 iface, UINT Level,IDirect3DSurface8** ppSurfaceLevel);
extern HRESULT WINAPI IDirect3DTexture8Impl_LockRect(LPDIRECT3DTEXTURE8 iface, UINT Level,D3DLOCKED_RECT* pLockedRect,CONST RECT* pRect,DWORD Flags);
extern HRESULT WINAPI IDirect3DTexture8Impl_GetLevelDesc(LPDIRECT3DTEXTURE8 iface, UINT Level, D3DSURFACE_DESC* pDesc);
extern HRESULT WINAPI IDirect3DTexture8Impl_GetSurfaceLevel(LPDIRECT3DTEXTURE8 iface, UINT Level, IDirect3DSurface8** ppSurfaceLevel);
extern HRESULT WINAPI IDirect3DTexture8Impl_LockRect(LPDIRECT3DTEXTURE8 iface, UINT Level, D3DLOCKED_RECT* pLockedRect, CONST RECT* pRect, DWORD Flags);
extern HRESULT WINAPI IDirect3DTexture8Impl_UnlockRect(LPDIRECT3DTEXTURE8 iface, UINT Level);
extern HRESULT WINAPI IDirect3DTexture8Impl_AddDirtyRect(LPDIRECT3DTEXTURE8 iface, CONST RECT* pDirtyRect);
/* ----------------------- */
/* IDirect3DVolumeTexture8 */
/* ----------------------- */
@ -856,14 +953,14 @@ struct IDirect3DVolumeTexture8Impl
/* IDirect3DBaseTexture8 fields */
BOOL Dirty;
D3DFORMAT format;
UINT levels;
/* IDirect3DVolumeTexture8 fields */
UINT width;
UINT height;
UINT depth;
UINT levels;
DWORD usage;
D3DFORMAT format;
IDirect3DVolume8Impl *volumes[MAX_LEVELS];
};
@ -889,12 +986,13 @@ extern DWORD WINAPI IDirect3DVolumeTexture8Impl_GetLOD(LPDIRECT3DVOLUM
extern DWORD WINAPI IDirect3DVolumeTexture8Impl_GetLevelCount(LPDIRECT3DVOLUMETEXTURE8 iface);
/* IDirect3DVolumeTexture8: */
extern HRESULT WINAPI IDirect3DVolumeTexture8Impl_GetLevelDesc(LPDIRECT3DVOLUMETEXTURE8 iface, UINT Level,D3DVOLUME_DESC *pDesc);
extern HRESULT WINAPI IDirect3DVolumeTexture8Impl_GetVolumeLevel(LPDIRECT3DVOLUMETEXTURE8 iface, UINT Level,IDirect3DVolume8** ppVolumeLevel);
extern HRESULT WINAPI IDirect3DVolumeTexture8Impl_LockBox(LPDIRECT3DVOLUMETEXTURE8 iface, UINT Level,D3DLOCKED_BOX* pLockedVolume,CONST D3DBOX* pBox,DWORD Flags);
extern HRESULT WINAPI IDirect3DVolumeTexture8Impl_GetLevelDesc(LPDIRECT3DVOLUMETEXTURE8 iface, UINT Level, D3DVOLUME_DESC *pDesc);
extern HRESULT WINAPI IDirect3DVolumeTexture8Impl_GetVolumeLevel(LPDIRECT3DVOLUMETEXTURE8 iface, UINT Level, IDirect3DVolume8** ppVolumeLevel);
extern HRESULT WINAPI IDirect3DVolumeTexture8Impl_LockBox(LPDIRECT3DVOLUMETEXTURE8 iface, UINT Level, D3DLOCKED_BOX* pLockedVolume, CONST D3DBOX* pBox, DWORD Flags);
extern HRESULT WINAPI IDirect3DVolumeTexture8Impl_UnlockBox(LPDIRECT3DVOLUMETEXTURE8 iface, UINT Level);
extern HRESULT WINAPI IDirect3DVolumeTexture8Impl_AddDirtyBox(LPDIRECT3DVOLUMETEXTURE8 iface, CONST D3DBOX* pDirtyBox);
/* ==============================================================================
Private interfactes: beginning of cleaning/splitting for HAL and d3d9 support
============================================================================== */
@ -1127,11 +1225,29 @@ extern DWORD WINAPI IDirect3DPixelShaderImpl_GetVersion(IDirect3DPixelShaderImpl
*
* to see how not defined it here
*/
void setupTextureStates(LPDIRECT3DDEVICE8 iface, DWORD Stage);
SHORT bytesPerPixel(D3DFORMAT fmt);
GLint fmt2glintFmt(D3DFORMAT fmt);
void setupTextureStates(LPDIRECT3DDEVICE8 iface, DWORD Stage);
SHORT bytesPerPixel(D3DFORMAT fmt);
GLint fmt2glintFmt(D3DFORMAT fmt);
GLenum fmt2glFmt(D3DFORMAT fmt);
DWORD fmt2glType(D3DFORMAT fmt);
GLenum fmt2glType(D3DFORMAT fmt);
SHORT D3DFmtGetBpp(D3DFORMAT fmt);
GLint D3DFmt2GLIntFmt(D3DFORMAT fmt);
GLenum D3DFmt2GLFmt(D3DFORMAT fmt);
GLenum D3DFmt2GLType(D3DFORMAT fmt);
GLenum D3DFmt2GLDepthFmt(D3DFORMAT fmt);
GLenum D3DFmt2GLDepthType(D3DFORMAT fmt);
int D3DPrimitiveListGetVertexSize(D3DPRIMITIVETYPE PrimitiveType, int iNumPrim);
int D3DPrimitive2GLenum(D3DPRIMITIVETYPE PrimitiveType);
int D3DFVFGetSize(D3DFORMAT fvf);
int SOURCEx_RGB_EXT(DWORD arg);
int OPERANDx_RGB_EXT(DWORD arg);
int SOURCEx_ALPHA_EXT(DWORD arg);
int OPERANDx_ALPHA_EXT(DWORD arg);
GLenum StencilOp(DWORD op);
/**
* Internals debug functions
@ -1140,5 +1256,6 @@ const char* debug_d3ddevicetype(D3DDEVTYPE devtype);
const char* debug_d3dusage(DWORD usage);
const char* debug_d3dformat(D3DFORMAT fmt);
const char* debug_d3dressourcetype(D3DRESOURCETYPE res);
const char* debug_d3dprimitivetype(D3DPRIMITIVETYPE PrimitiveType);
#endif /* __WINE_D3DX8_PRIVATE_H */

File diff suppressed because it is too large Load Diff

View File

@ -85,18 +85,6 @@ static const D3DFORMAT device_formats[NUM_FORMATS] = {
D3DFMT_X8R8G8B8
};
inline static int get_bpp_from_format(D3DFORMAT fmt) {
switch (fmt) {
case D3DFMT_P8: return 8;
case D3DFMT_R3G3B2: return 8;
case D3DFMT_R5G6B5: return 16;
case D3DFMT_X1R5G5B5: return 16;
case D3DFMT_X4R4G4B4: return 16;
case D3DFMT_R8G8B8: return 24;
case D3DFMT_X8R8G8B8: return 32;
default: return 16;
}
}
/* retrieve the X display to use on a given DC */
inline static Display *get_display( HDC hdc )
@ -415,33 +403,91 @@ HRESULT WINAPI IDirect3D8Impl_GetDeviceCaps (LPDIRECT3D8 iface,
pCaps->CursorCaps = 0;
pCaps->DevCaps = D3DDEVCAPS_DRAWPRIMTLVERTEX | D3DDEVCAPS_HWTRANSFORMANDLIGHT | D3DDEVCAPS_PUREDEVICE;
pCaps->DevCaps = D3DDEVCAPS_DRAWPRIMTLVERTEX |
D3DDEVCAPS_HWTRANSFORMANDLIGHT |
D3DDEVCAPS_PUREDEVICE;
pCaps->PrimitiveMiscCaps = D3DPMISCCAPS_CULLCCW | D3DPMISCCAPS_CULLCW | D3DPMISCCAPS_COLORWRITEENABLE | D3DPMISCCAPS_CLIPTLVERTS |
D3DPMISCCAPS_CLIPPLANESCALEDPOINTS | D3DPMISCCAPS_MASKZ; /*NOT: D3DPMISCCAPS_TSSARGTEMP*/
pCaps->RasterCaps = D3DPRASTERCAPS_DITHER | D3DPRASTERCAPS_PAT;
pCaps->ZCmpCaps = D3DPCMPCAPS_ALWAYS | D3DPCMPCAPS_EQUAL | D3DPCMPCAPS_GREATER | D3DPCMPCAPS_GREATEREQUAL |
D3DPCMPCAPS_LESS | D3DPCMPCAPS_LESSEQUAL | D3DPCMPCAPS_NEVER | D3DPCMPCAPS_NOTEQUAL;
pCaps->PrimitiveMiscCaps = D3DPMISCCAPS_CULLCCW |
D3DPMISCCAPS_CULLCW |
D3DPMISCCAPS_COLORWRITEENABLE |
D3DPMISCCAPS_CLIPTLVERTS |
D3DPMISCCAPS_CLIPPLANESCALEDPOINTS |
D3DPMISCCAPS_MASKZ;
/*NOT: D3DPMISCCAPS_TSSARGTEMP*/
pCaps->RasterCaps = D3DPRASTERCAPS_DITHER |
D3DPRASTERCAPS_PAT |
D3DPRASTERCAPS_FOGRANGE;
/* FIXME Add:
D3DPRASTERCAPS_FOGVERTEX
D3DPRASTERCAPS_FOGTABLE
D3DPRASTERCAPS_MIPMAPLODBIAS
D3DPRASTERCAPS_ZBIAS
D3DPRASTERCAPS_ANISOTROPY
D3DPRASTERCAPS_WFOG
D3DPRASTERCAPS_ZFOG
D3DPRASTERCAPS_COLORPERSPECTIVE
D3DPRASTERCAPS_STRETCHBLTMULTISAMPLE
D3DPRASTERCAPS_ANTIALIASEDGES
D3DPRASTERCAPS_ZBUFFERLESSHSR
D3DPRASTERCAPS_WBUFFER */
pCaps->ZCmpCaps = D3DPCMPCAPS_ALWAYS |
D3DPCMPCAPS_EQUAL |
D3DPCMPCAPS_GREATER |
D3DPCMPCAPS_GREATEREQUAL |
D3DPCMPCAPS_LESS |
D3DPCMPCAPS_LESSEQUAL |
D3DPCMPCAPS_NEVER |
D3DPCMPCAPS_NOTEQUAL;
pCaps->SrcBlendCaps = 0xFFFFFFFF; /*FIXME: Tidy up later */
pCaps->DestBlendCaps = 0xFFFFFFFF; /*FIXME: Tidy up later */
pCaps->AlphaCmpCaps = 0xFFFFFFFF; /*FIXME: Tidy up later */
pCaps->ShadeCaps = D3DPSHADECAPS_SPECULARGOURAUDRGB | D3DPSHADECAPS_COLORGOURAUDRGB ;
pCaps->TextureCaps = D3DPTEXTURECAPS_ALPHA | D3DPTEXTURECAPS_ALPHAPALETTE | D3DPTEXTURECAPS_CUBEMAP | D3DPTEXTURECAPS_MIPCUBEMAP | D3DPTEXTURECAPS_CUBEMAP_POW2 | D3DPTEXTURECAPS_POW2 | D3DPTEXTURECAPS_VOLUMEMAP | D3DPTEXTURECAPS_MIPMAP;
pCaps->TextureFilterCaps = D3DPTFILTERCAPS_MAGFLINEAR | D3DPTFILTERCAPS_MAGFPOINT | D3DPTFILTERCAPS_MINFLINEAR | D3DPTFILTERCAPS_MINFPOINT |
D3DPTFILTERCAPS_MIPFLINEAR | D3DPTFILTERCAPS_MIPFPOINT ;
pCaps->ShadeCaps = D3DPSHADECAPS_SPECULARGOURAUDRGB |
D3DPSHADECAPS_COLORGOURAUDRGB;
pCaps->TextureCaps = D3DPTEXTURECAPS_ALPHA |
D3DPTEXTURECAPS_ALPHAPALETTE |
D3DPTEXTURECAPS_POW2 |
D3DPTEXTURECAPS_VOLUMEMAP |
D3DPTEXTURECAPS_MIPMAP;
#if defined(GL_VERSION_1_3) || defined(GL_ARB_texture_cube_map)
pCaps->TextureCaps |= D3DPTEXTURECAPS_CUBEMAP |
D3DPTEXTURECAPS_MIPCUBEMAP |
D3DPTEXTURECAPS_CUBEMAP_POW2;
#endif
pCaps->TextureFilterCaps = D3DPTFILTERCAPS_MAGFLINEAR |
D3DPTFILTERCAPS_MAGFPOINT |
D3DPTFILTERCAPS_MINFLINEAR |
D3DPTFILTERCAPS_MINFPOINT |
D3DPTFILTERCAPS_MIPFLINEAR |
D3DPTFILTERCAPS_MIPFPOINT;
pCaps->CubeTextureFilterCaps = 0;
pCaps->VolumeTextureFilterCaps = 0;
pCaps->TextureAddressCaps = D3DPTADDRESSCAPS_BORDER | D3DPTADDRESSCAPS_CLAMP | D3DPTADDRESSCAPS_WRAP;
pCaps->TextureAddressCaps = D3DPTADDRESSCAPS_BORDER |
D3DPTADDRESSCAPS_CLAMP |
D3DPTADDRESSCAPS_WRAP;
#if defined(GL_VERSION_1_3)
pCaps->TextureAddressCaps |= D3DPTADDRESSCAPS_MIRROR;
#endif
/* FIXME: Add
D3DPTADDRESSCAPS_BORDER
D3DPTADDRESSCAPS_MIRRORONCE */
pCaps->VolumeTextureAddressCaps = 0;
pCaps->LineCaps = D3DLINECAPS_TEXTURE | D3DLINECAPS_ZTEST;
pCaps->LineCaps = D3DLINECAPS_TEXTURE |
D3DLINECAPS_ZTEST;
/* FIXME: Add
D3DLINECAPS_BLEND
D3DLINECAPS_ALPHACMP
D3DLINECAPS_FOG */
/*pCaps->MaxTextureWidth = 16384;
pCaps->MaxTextureHeight = 16384;*/
{
GLint gl_tex_size;
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &gl_tex_size);
@ -453,7 +499,6 @@ HRESULT WINAPI IDirect3D8Impl_GetDeviceCaps (LPDIRECT3D8 iface,
pCaps->MaxTextureRepeat = 32768;
pCaps->MaxTextureAspectRatio = 32768;
pCaps->MaxAnisotropy = 0;
pCaps->MaxVertexW = 1.0;
pCaps->GuardBandLeft = 0;
@ -463,26 +508,52 @@ HRESULT WINAPI IDirect3D8Impl_GetDeviceCaps (LPDIRECT3D8 iface,
pCaps->ExtentsAdjust = 0;
pCaps->StencilCaps = D3DSTENCILCAPS_DECRSAT | D3DSTENCILCAPS_INCRSAT |
D3DSTENCILCAPS_INVERT | D3DSTENCILCAPS_KEEP |
D3DSTENCILCAPS_REPLACE | D3DSTENCILCAPS_ZERO /* | D3DSTENCILCAPS_DECR | D3DSTENCILCAPS_INCR */;
pCaps->StencilCaps = D3DSTENCILCAPS_DECRSAT |
D3DSTENCILCAPS_INCRSAT |
D3DSTENCILCAPS_INVERT |
D3DSTENCILCAPS_KEEP |
D3DSTENCILCAPS_REPLACE |
D3DSTENCILCAPS_ZERO;
/* FIXME: Add
D3DSTENCILCAPS_DECR
D3DSTENCILCAPS_INCR */
pCaps->FVFCaps = D3DFVFCAPS_PSIZE | 0x80000;
pCaps->TextureOpCaps = D3DTEXOPCAPS_ADD | D3DTEXOPCAPS_ADDSIGNED | D3DTEXOPCAPS_ADDSIGNED2X |
D3DTEXOPCAPS_MODULATE | D3DTEXOPCAPS_MODULATE2X | D3DTEXOPCAPS_MODULATE4X |
D3DTEXOPCAPS_SELECTARG1 | D3DTEXOPCAPS_SELECTARG2 | D3DTEXOPCAPS_DISABLE;
pCaps->TextureOpCaps = D3DTEXOPCAPS_ADD |
D3DTEXOPCAPS_ADDSIGNED |
D3DTEXOPCAPS_ADDSIGNED2X |
D3DTEXOPCAPS_MODULATE |
D3DTEXOPCAPS_MODULATE2X |
D3DTEXOPCAPS_MODULATE4X |
D3DTEXOPCAPS_SELECTARG1 |
D3DTEXOPCAPS_SELECTARG2 |
D3DTEXOPCAPS_DISABLE;
#if defined(GL_VERSION_1_3)
pCaps->TextureOpCaps |= D3DTEXOPCAPS_DOTPRODUCT3 | D3DTEXOPCAPS_SUBTRACT;
pCaps->TextureOpCaps |= D3DTEXOPCAPS_DOTPRODUCT3 |
D3DTEXOPCAPS_SUBTRACT;
#endif
/* FIXME: Add D3DTEXOPCAPS_ADDSMOOTH D3DTEXOPCAPS_BLENDCURRENTALPHA D3DTEXOPCAPS_BLENDDIFFUSEALPHA D3DTEXOPCAPS_BLENDFACTORALPHA
D3DTEXOPCAPS_BLENDTEXTUREALPHA D3DTEXOPCAPS_BLENDTEXTUREALPHAPM D3DTEXOPCAPS_BUMPENVMAP D3DTEXOPCAPS_BUMPENVMAPLUMINANCE
D3DTEXOPCAPS_LERP D3DTEXOPCAPS_MODULATEALPHA_ADDCOLOR D3DTEXOPCAPS_MODULATECOLOR_ADDALPHA
D3DTEXOPCAPS_MODULATEINVALPHA_ADDCOLOR D3DTEXOPCAPS_MODULATEINVCOLOR_ADDALPHA D3DTEXOPCAPS_MULTIPLYADD
D3DTEXOPCAPS_PREMODULATE */
/* FIXME: Add
D3DTEXOPCAPS_ADDSMOOTH
D3DTEXOPCAPS_BLENDCURRENTALPHA
D3DTEXOPCAPS_BLENDDIFFUSEALPHA
D3DTEXOPCAPS_BLENDFACTORALPHA
D3DTEXOPCAPS_BLENDTEXTUREALPHA
D3DTEXOPCAPS_BLENDTEXTUREALPHAPM
D3DTEXOPCAPS_BUMPENVMAP
D3DTEXOPCAPS_BUMPENVMAPLUMINANCE
D3DTEXOPCAPS_LERP
D3DTEXOPCAPS_MODULATEALPHA_ADDCOLOR
D3DTEXOPCAPS_MODULATECOLOR_ADDALPHA
D3DTEXOPCAPS_MODULATEINVALPHA_ADDCOLOR
D3DTEXOPCAPS_MODULATEINVCOLOR_ADDALPHA
D3DTEXOPCAPS_MULTIPLYADD
D3DTEXOPCAPS_PREMODULATE */
{
GLint gl_max;
GLfloat gl_float;
#if defined(GL_VERSION_1_3)
glGetIntegerv(GL_MAX_TEXTURE_UNITS, &gl_max);
#else
@ -499,14 +570,34 @@ HRESULT WINAPI IDirect3D8Impl_GetDeviceCaps (LPDIRECT3D8 iface,
glGetIntegerv(GL_MAX_LIGHTS, &gl_max);
pCaps->MaxActiveLights = min(MAX_ACTIVE_LIGHTS, gl_max);
TRACE("GLCaps: GL_MAX_LIGHTS=%ld\n", pCaps->MaxActiveLights);
#if defined(GL_ARB_vertex_blend)
glGetIntegerv(GL_MAX_VERTEX_UNITS_ARB, &gl_max);
pCaps->MaxVertexBlendMatrices = gl_max;
pCaps->MaxVertexBlendMatrixIndex = 1;
#else
pCaps->MaxVertexBlendMatrices = 0;
pCaps->MaxVertexBlendMatrixIndex = 1;
#endif
#if defined(GL_EXT_texture_filter_anisotropic)
glGetIntegerv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &gl_max);
pCaps->MaxAnisotropy = gl_max;
#else
pCaps->MaxAnisotropy = 0;
#endif
glGetFloatv(GL_POINT_SIZE_RANGE, &gl_float);
pCaps->MaxPointSize = gl_float;
}
pCaps->VertexProcessingCaps = D3DVTXPCAPS_DIRECTIONALLIGHTS | D3DVTXPCAPS_MATERIALSOURCE7 | D3DVTXPCAPS_POSITIONALLIGHTS | D3DVTXPCAPS_TEXGEN;
pCaps->MaxVertexBlendMatrices = 1;
pCaps->MaxVertexBlendMatrixIndex = 1;
pCaps->MaxPointSize = 128.0;
pCaps->VertexProcessingCaps = D3DVTXPCAPS_DIRECTIONALLIGHTS |
D3DVTXPCAPS_MATERIALSOURCE7 |
D3DVTXPCAPS_POSITIONALLIGHTS |
D3DVTXPCAPS_TEXGEN;
/* FIXME: Add
D3DVTXPCAPS_LOCALVIEWER
D3DVTXPCAPS_TWEENING */
pCaps->MaxPrimitiveCount = 0xFFFFFFFF;
pCaps->MaxVertexIndex = 0xFFFFFFFF;
@ -718,24 +809,39 @@ HRESULT WINAPI IDirect3D8Impl_CreateDevice (LPDIRECT3D8 iface,
pPresentationParameters->BackBufferWidth,
pPresentationParameters->BackBufferHeight,
pPresentationParameters->BackBufferFormat,
D3DMULTISAMPLE_NONE, TRUE,
pPresentationParameters->MultiSampleType,
TRUE,
(LPDIRECT3DSURFACE8*) &object->frontBuffer);
IDirect3DDevice8Impl_CreateRenderTarget((LPDIRECT3DDEVICE8) object,
pPresentationParameters->BackBufferWidth,
pPresentationParameters->BackBufferHeight,
pPresentationParameters->BackBufferFormat,
D3DMULTISAMPLE_NONE, TRUE,
pPresentationParameters->MultiSampleType,
TRUE,
(LPDIRECT3DSURFACE8*) &object->backBuffer);
if (pPresentationParameters->EnableAutoDepthStencil)
IDirect3DDevice8Impl_CreateDepthStencilSurface((LPDIRECT3DDEVICE8) object,
pPresentationParameters->BackBufferWidth,
pPresentationParameters->BackBufferHeight,
pPresentationParameters->AutoDepthStencilFormat,
D3DMULTISAMPLE_NONE,
(LPDIRECT3DSURFACE8*) &object->depthStencilBuffer);
if (pPresentationParameters->EnableAutoDepthStencil) {
IDirect3DDevice8Impl_CreateDepthStencilSurface((LPDIRECT3DDEVICE8) object,
pPresentationParameters->BackBufferWidth,
pPresentationParameters->BackBufferHeight,
pPresentationParameters->AutoDepthStencilFormat,
D3DMULTISAMPLE_NONE,
(LPDIRECT3DSURFACE8*) &object->depthStencilBuffer);
} else {
object->depthStencilBuffer = NULL;
}
/* init the default renderTarget management */
object->drawable = object->win;
object->render_ctx = object->glCtx;
object->renderTarget = object->frontBuffer;
IDirect3DSurface8Impl_AddRef((LPDIRECT3DSURFACE8) object->renderTarget);
object->stencilBufferTarget = object->depthStencilBuffer;
if (NULL != object->stencilBufferTarget)
IDirect3DSurface8Impl_AddRef((LPDIRECT3DSURFACE8) object->stencilBufferTarget);
/* Now override the surface's Flip method (if in double buffering) ?COPIED from DDRAW!?
((x11_ds_private *) surface->private)->opengl_flip = TRUE;
{
@ -768,25 +874,29 @@ HRESULT WINAPI IDirect3D8Impl_CreateDevice (LPDIRECT3D8 iface,
checkGLcall("glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE);");
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
checkGLcall("glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);");
checkGLcall("glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);");
/* Initialize openGL extension related variables */
object->isMultiTexture = FALSE;
object->isDot3 = FALSE;
object->TextureUnits = 1;
/*
* Initialize openGL extension related variables
* with Default values
*/
memset(&This->gl_info.supported, 0, sizeof(This->gl_info.supported));
This->gl_info.max_textures = 1;
This->gl_info.vs_arb_version = VS_VERSION_NOT_SUPPORTED;
This->gl_info.vs_nv_version = VS_VERSION_NOT_SUPPORTED;
/* Retrieve opengl defaults */
glGetIntegerv(GL_MAX_CLIP_PLANES, &gl_max);
object->clipPlanes = min(MAX_CLIPPLANES, gl_max);
This->gl_info.max_clipplanes = min(MAX_CLIPPLANES, gl_max);
TRACE("ClipPlanes support - num Planes=%d\n", gl_max);
glGetIntegerv(GL_MAX_LIGHTS, &gl_max);
object->maxLights = min(MAX_ACTIVE_LIGHTS, gl_max);
This->gl_info.max_lights = min(MAX_ACTIVE_LIGHTS, gl_max);
TRACE("Lights support - max lights=%d\n", gl_max);
/* Parse the gl supported features, in theory enabling parts of our code appropriately */
GL_Extensions = glGetString(GL_EXTENSIONS);
TRACE("GL_Extensions reported:\n");
FIXME("GL_Extensions reported:\n");
if (NULL == GL_Extensions) {
ERR(" GL_Extensions returns NULL\n");
@ -800,17 +910,78 @@ HRESULT WINAPI IDirect3D8Impl_CreateDevice (LPDIRECT3D8 iface,
GL_Extensions++;
}
memcpy(ThisExtn, Start, (GL_Extensions - Start));
TRACE (" %s\n", ThisExtn);
FIXME("- %s\n", ThisExtn);
/**
* ARB
*/
if (strcmp(ThisExtn, "GL_ARB_multisample") == 0) {
FIXME(" FOUND: ARB Multisample support\n");
This->gl_info.supported[ARB_MULTISAMPLE] = TRUE;
} else if (strcmp(ThisExtn, "GL_ARB_multitexture") == 0) {
glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, &gl_max);
FIXME(" FOUND: ARB Multitexture support - GL_MAX_TEXTURE_UNITS_ARB=%u\n", gl_max);
This->gl_info.supported[ARB_MULTITEXTURE] = TRUE;
This->gl_info.max_textures = min(8, gl_max);
} else if (strcmp(ThisExtn, "GL_ARB_texture_cube_map") == 0) {
FIXME(" FOUND: ARB Texture Cube Map support\n");
This->gl_info.supported[ARB_TEXTURE_CUBE_MAP] = TRUE;
} else if (strcmp(ThisExtn, "GL_ARB_texture_compression") == 0) {
FIXME(" FOUND: ARB Texture Compression support\n");
This->gl_info.supported[ARB_TEXTURE_COMPRESSION] = TRUE;
} else if (strcmp(ThisExtn, "GL_ARB_texture_env_dot3") == 0) {
FIXME(" FOUND: EXT Dot3 support\n");
This->gl_info.supported[ARB_TEXTURE_ENV_DOT3] = TRUE;
} else if (strstr(ThisExtn, "GL_ARB_vertex_program")) {
This->gl_info.vs_arb_version = VS_VERSION_11;
FIXME(" FOUND: ARB Vertex Shader support - version=%02x\n", This->gl_info.vs_arb_version);
This->gl_info.supported[ARB_VERTEX_PROGRAM] = TRUE;
/**
* EXT
*/
} else if (strcmp(ThisExtn, "GL_EXT_fog_coord") == 0) {
FIXME(" FOUND: EXT Fog coord support\n");
This->gl_info.supported[EXT_FOG_COORD] = TRUE;
} else if (strcmp(ThisExtn, "GL_EXT_paletted_texture") == 0) {
/* handle paletted texture extensions */
FIXME(" FOUND: EXT Paletted texture support\n");
This->gl_info.supported[EXT_PALETTED_TEXTURE] = TRUE;
} else if (strcmp(ThisExtn, "GL_EXT_secondary_color") == 0) {
FIXME(" FOUND: EXT Secondary coord support\n");
This->gl_info.supported[EXT_SECONDARY_COLOR] = TRUE;
} else if (strcmp(ThisExtn, "GL_EXT_texture_compression_s3tc") == 0) {
FIXME(" FOUND: EXT Texture S3TC compression support\n");
This->gl_info.supported[EXT_TEXTURE_COMPRESSION_S3TC] = TRUE;
} else if (strcmp(ThisExtn, "GL_EXT_texture_lod") == 0) {
FIXME(" FOUND: EXT Texture LOD support\n");
This->gl_info.supported[EXT_TEXTURE_LOD] = TRUE;
} else if (strcmp(ThisExtn, "GL_EXT_texture_lod_bias") == 0) {
FIXME(" FOUND: EXT Texture LOD bias support\n");
This->gl_info.supported[EXT_TEXTURE_LOD_BIAS] = TRUE;
} else if (strcmp(ThisExtn, "GL_EXT_vertex_weighting") == 0) {
FIXME(" FOUND: EXT Vertex weighting support\n");
This->gl_info.supported[EXT_VERTEX_WEIGHTING] = TRUE;
/**
* NVIDIA
*/
} else if (strstr(ThisExtn, "GL_NV_vertex_program")) {
This->gl_info.vs_nv_version = max(This->gl_info.vs_nv_version, (0 == strcmp(ThisExtn, "GL_NV_vertex_program1_1")) ? VS_VERSION_11 : VS_VERSION_10);
This->gl_info.vs_nv_version = max(This->gl_info.vs_nv_version, (0 == strcmp(ThisExtn, "GL_NV_vertex_program2")) ? VS_VERSION_20 : VS_VERSION_10);
FIXME(" FOUND: NVIDIA (NV) Vertex Shader support - version=%02x\n", This->gl_info.vs_nv_version);
This->gl_info.supported[NV_VERTEX_PROGRAM] = TRUE;
/**
* ATI
*/
/** TODO */
} else if (strcmp(ThisExtn, "GL_EXT_vertex_shader") == 0) {
This->gl_info.vs_ati_version = VS_VERSION_11;
FIXME(" FOUND: ATI (EXT) Vertex Shader support - version=%02x\n", This->gl_info.vs_ati_version);
This->gl_info.supported[EXT_VERTEX_SHADER] = TRUE;
}
if (strcmp(ThisExtn, "GL_ARB_multitexture") == 0) {
glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, &gl_max);
object->isMultiTexture = TRUE;
object->TextureUnits = min(8, gl_max);
TRACE("FOUND: Multitexture support - GL_MAX_TEXTURE_UNITS_ARB=%d\n", gl_max);
} else if (strcmp(ThisExtn, "GL_EXT_texture_env_dot3") == 0) {
object->isDot3 = TRUE;
TRACE("FOUND: Dot3 support\n");
}
if (*GL_Extensions == ' ') GL_Extensions++;
}
@ -831,7 +1002,7 @@ HRESULT WINAPI IDirect3D8Impl_CreateDevice (LPDIRECT3D8 iface,
GLX_Extensions++;
}
memcpy(ThisExtn, Start, (GLX_Extensions - Start));
TRACE (" %s\n", ThisExtn);
TRACE ("- %s\n", ThisExtn);
if (*GLX_Extensions == ' ') GLX_Extensions++;
}
}

View File

@ -101,6 +101,30 @@ D3DRESOURCETYPE WINAPI IDirect3DResource8Impl_GetType(LPDIRECT3DRESOURCE8 iface)
return This->ResourceType;
}
D3DPOOL WINAPI IDirect3DResource8Impl_GetPool(LPDIRECT3DRESOURCE8 iface) {
ICOM_THIS(IDirect3DResource8Impl,iface);
switch (This->ResourceType) {
case D3DRTYPE_SURFACE:
return ((IDirect3DSurface8Impl*) This)->myDesc.Pool;
case D3DRTYPE_TEXTURE:
return ((IDirect3DTexture8Impl*) This)->surfaces[0]->myDesc.Pool;
case D3DRTYPE_VOLUME:
return ((IDirect3DVolume8Impl*) This)->myDesc.Pool;
case D3DRTYPE_VOLUMETEXTURE:
return ((IDirect3DVolumeTexture8Impl*) This)->volumes[0]->myDesc.Pool;
case D3DRTYPE_CUBETEXTURE:
return ((IDirect3DCubeTexture8Impl*) This)->surfaces[0][0]->myDesc.Pool;
case D3DRTYPE_VERTEXBUFFER:
return ((IDirect3DVertexBuffer8Impl*) This)->currentDesc.Pool;
case D3DRTYPE_INDEXBUFFER:
return ((IDirect3DIndexBuffer8Impl*) This)->currentDesc.Pool;
default:
FIXME("(%p) Unrecognized type(%d,%s)\n", This, This->ResourceType, debug_d3dressourcetype(This->ResourceType));
return D3DPOOL_DEFAULT;
}
}
ICOM_VTABLE(IDirect3DResource8) Direct3DResource8_Vtbl =
{
ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE

View File

@ -593,6 +593,7 @@ HRESULT WINAPI IDirect3DVertexShaderImpl_ExecuteSW(IDirect3DVertexShaderImpl* vs
TRACE_VECTOR(vshader->data->C[6]);
TRACE_VECTOR(vshader->data->C[7]);
TRACE_VECTOR(vshader->data->C[8]);
TRACE_VECTOR(vshader->data->C[64]);
TRACE_VECTOR(input->V[D3DVSDE_POSITION]);
TRACE_VECTOR(input->V[D3DVSDE_BLENDWEIGHT]);
TRACE_VECTOR(input->V[D3DVSDE_BLENDINDICES]);

View File

@ -154,7 +154,7 @@ HRESULT WINAPI IDirect3DDeviceImpl_InitStartupStateBlock(IDirect3DDevice8Impl* T
IDirect3DDevice8Impl_SetRenderState(iface, D3DRS_NORMALORDER, D3DORDER_LINEAR);
/* Texture Stage States - Put directly into state block, we will call function below */
for (i = 0; i < This->TextureUnits; i++) {
for (i = 0; i < GL_LIMITS(textures); i++) {
memcpy(&This->StateBlock->transforms[D3DTS_TEXTURE0 + i], &idmatrix, sizeof(idmatrix));
This->StateBlock->texture_state[i][D3DTSS_COLOROP ] = (i==0)? D3DTOP_MODULATE : D3DTOP_DISABLE;
This->StateBlock->texture_state[i][D3DTSS_COLORARG1 ] = D3DTA_TEXTURE;
@ -191,7 +191,7 @@ HRESULT WINAPI IDirect3DDeviceImpl_InitStartupStateBlock(IDirect3DDevice8Impl* T
texture stage, but disable all stages by default. Hence if a stage is enabled
then the default texture will kick in until replaced by a SetTexture call */
for (i = 0; i < This->TextureUnits; i++) {
for (i = 0; i < GL_LIMITS(textures); i++) {
GLubyte white = 255;
/* Note this avoids calling settexture, so pretend it has been called */
@ -200,7 +200,7 @@ HRESULT WINAPI IDirect3DDeviceImpl_InitStartupStateBlock(IDirect3DDevice8Impl* T
This->StateBlock->textures[i] = NULL;
/* Make appropriate texture active */
if (This->isMultiTexture) {
if (GL_SUPPORT(ARB_MULTITEXTURE)) {
#if defined(GL_VERSION_1_3)
glActiveTexture(GL_TEXTURE0 + i);
#else
@ -289,7 +289,7 @@ HRESULT WINAPI IDirect3DDeviceImpl_CreateStateBlock(IDirect3DDevice8Impl* This,
for (i = 0; i < NUM_SAVEDPIXELSTATES_R; i++) {
object->Changed.renderstate[SavedPixelStates_R[i]] = TRUE;
}
for (j = 0; j < This->TextureUnits; i++) {
for (j = 0; j < GL_LIMITS(textures); i++) {
for (i = 0; i < NUM_SAVEDPIXELSTATES_T; i++) {
object->Changed.texture_state[j][SavedPixelStates_T[i]] = TRUE;
}
@ -304,12 +304,12 @@ HRESULT WINAPI IDirect3DDeviceImpl_CreateStateBlock(IDirect3DDevice8Impl* This,
for (i = 0; i < NUM_SAVEDVERTEXSTATES_R; i++) {
object->Changed.renderstate[SavedVertexStates_R[i]] = TRUE;
}
for (j = 0; j < This->TextureUnits; i++) {
for (j = 0; j < GL_LIMITS(textures); i++) {
for (i = 0; i < NUM_SAVEDVERTEXSTATES_T; i++) {
object->Changed.texture_state[j][SavedVertexStates_T[i]] = TRUE;
}
}
for (i = 0; i < This->maxLights; i++) {
for (i = 0; i < GL_LIMITS(lights); i++) {
object->Changed.lightEnable[i] = TRUE;
object->Changed.lights[i] = TRUE;
}
@ -385,7 +385,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 < GL_LIMITS(lights); i++) {
if (pSB->Set.lightEnable[i] && pSB->Changed.lightEnable[i])
IDirect3DDevice8Impl_LightEnable(iface, i, pSB->lightEnable[i]);
@ -428,7 +428,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 < GL_LIMITS(clipplanes); i++) {
if (pSB->Set.clipplane[i] && pSB->Changed.clipplane[i]) {
float clip[4];
@ -447,7 +447,7 @@ HRESULT WINAPI IDirect3DDeviceImpl_ApplyStateBlock(IDirect3DDevice8Impl* This,
}
/* Texture */
for (j = 0; j < This->TextureUnits; j++) {
for (j = 0; j < GL_LIMITS(textures); j++) {
for (i = 0; i < HIGHEST_TEXTURE_STATE; i++) {
if (pSB->Set.texture_state[j][i] && pSB->Changed.texture_state[j][i]) {
IDirect3DDevice8Impl_SetTextureStageState(iface, j, i, pSB->texture_state[j][i]);
@ -467,7 +467,7 @@ HRESULT WINAPI IDirect3DDeviceImpl_ApplyStateBlock(IDirect3DDevice8Impl* This,
}
for (j = 0; j < This->TextureUnits; i++) {
for (j = 0; j < GL_LIMITS(textures); 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]])
@ -482,7 +482,7 @@ HRESULT WINAPI IDirect3DDeviceImpl_ApplyStateBlock(IDirect3DDevice8Impl* This,
IDirect3DDevice8Impl_SetRenderState(iface, SavedVertexStates_R[i], pSB->renderstate[SavedVertexStates_R[i]]);
}
for (j = 0; j < This->TextureUnits; i++) {
for (j = 0; j < GL_LIMITS(textures); 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]])
@ -526,7 +526,7 @@ HRESULT WINAPI IDirect3DDeviceImpl_CaptureStateBlock(IDirect3DDevice8Impl* This,
/* TODO: Vertex Shader Constants */
for (i = 0; i < This->maxLights; i++) {
for (i = 0; i < GL_LIMITS(lights); 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];
@ -591,7 +591,7 @@ HRESULT WINAPI IDirect3DDeviceImpl_CaptureStateBlock(IDirect3DDevice8Impl* This,
}
}
for (i = 0; i < This->clipPlanes; i++) {
for (i = 0; i < GL_LIMITS(clipplanes); i++) {
if (updateBlock->Set.clipplane[i] && memcmp(&This->StateBlock->clipplane[i],
&updateBlock->clipplane[i],
sizeof(updateBlock->clipplane)) != 0) {
@ -613,7 +613,7 @@ HRESULT WINAPI IDirect3DDeviceImpl_CaptureStateBlock(IDirect3DDevice8Impl* This,
}
/* Texture */
for (j = 0; j < This->TextureUnits; j++) {
for (j = 0; j < GL_LIMITS(textures); j++) {
for (i = 0; i < HIGHEST_TEXTURE_STATE; i++) {
if (updateBlock->Set.texture_state[j][i] && (updateBlock->texture_state[j][i] !=

View File

@ -131,11 +131,13 @@ HRESULT WINAPI IDirect3DSurface8Impl_LockRect(LPDIRECT3DSURFACE8 iface, D3DLOCKE
return D3DERR_INVALIDCALL;
}
if (This == This->Device->backBuffer || This == This->Device->frontBuffer || This->Device->depthStencilBuffer) {
if (This == This->Device->backBuffer || This == This->Device->renderTarget || This == This->Device->frontBuffer || This->Device->depthStencilBuffer) {
if (This == This->Device->backBuffer) {
TRACE("(%p, backBuffer) : rect@%p flags(%08lx), output lockedRect@%p, memory@%p\n", This, pRect, Flags, pLockedRect, This->allocatedMemory);
} else if (This == This->Device->frontBuffer) {
TRACE("(%p, frontBuffer) : rect@%p flags(%08lx), output lockedRect@%p, memory@%p\n", This, pRect, Flags, pLockedRect, This->allocatedMemory);
} else if (This == This->Device->renderTarget) {
TRACE("(%p, renderTarget) : rect@%p flags(%08lx), output lockedRect@%p, memory@%p\n", This, pRect, Flags, pLockedRect, This->allocatedMemory);
} else if (This == This->Device->depthStencilBuffer) {
TRACE("(%p, stencilBuffer) : rect@%p flags(%08lx), output lockedRect@%p, memory@%p\n", This, pRect, Flags, pLockedRect, This->allocatedMemory);
}
@ -167,7 +169,7 @@ HRESULT WINAPI IDirect3DSurface8Impl_LockRect(LPDIRECT3DSURFACE8 iface, D3DLOCKE
} else if (D3DUSAGE_RENDERTARGET & This->myDesc.Usage) { /* render surfaces */
if (This == This->Device->backBuffer || This == This->Device->frontBuffer) {
if (This == This->Device->backBuffer || This == This->Device->renderTarget || This == This->Device->frontBuffer) {
GLint prev_store;
GLenum prev_read;
@ -188,84 +190,13 @@ HRESULT WINAPI IDirect3DSurface8Impl_LockRect(LPDIRECT3DSURFACE8 iface, D3DLOCKE
if (This == This->Device->backBuffer) {
glReadBuffer(GL_BACK);
} else if (This == This->Device->frontBuffer) {
} else if (This == This->Device->frontBuffer || This == This->Device->renderTarget) {
glReadBuffer(GL_FRONT);
} else if (This == This->Device->depthStencilBuffer) {
ERR("Stencil Buffer lock unsupported for now\n");
}
vcheckGLcall("glReadBuffer");
/** TODO: use an enhanced version of fmt2glintFmt here instad this switch */
#if 0
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");
*/
long j;
for (j = This->lockedRect.top; j < This->lockedRect.bottom - This->lockedRect.top; ++j) {
glReadPixels(This->lockedRect.left,
This->lockedRect.bottom - j - 1,
This->lockedRect.right - This->lockedRect.left,
1,
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");
*/
long j;
for (j = This->lockedRect.top; j < This->lockedRect.bottom - This->lockedRect.top; ++j) {
glReadPixels(This->lockedRect.left,
This->lockedRect.bottom - j - 1,
This->lockedRect.right - This->lockedRect.left,
1,
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");
*/
long j;
glPixelStorei(GL_PACK_SWAP_BYTES, TRUE);
vcheckGLcall("glPixelStorei");
for (j = This->lockedRect.top; j < This->lockedRect.bottom - This->lockedRect.top; ++j) {
glReadPixels(This->lockedRect.left,
This->lockedRect.bottom - j - 1,
This->lockedRect.right - This->lockedRect.left,
1,
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);
}
#endif
{
long j;
for (j = This->lockedRect.top; j < This->lockedRect.bottom - This->lockedRect.top; ++j) {
@ -273,7 +204,9 @@ HRESULT WINAPI IDirect3DSurface8Impl_LockRect(LPDIRECT3DSURFACE8 iface, D3DLOCKE
This->lockedRect.bottom - j - 1,
This->lockedRect.right - This->lockedRect.left,
1,
fmt2glFmt(This->myDesc.Format), fmt2glType(This->myDesc.Format), pLockedRect->pBits);
D3DFmt2GLFmt(This->myDesc.Format),
D3DFmt2GLType(This->myDesc.Format),
pLockedRect->pBits);
vcheckGLcall("glReadPixels");
}
}
@ -307,6 +240,8 @@ HRESULT WINAPI IDirect3DSurface8Impl_LockRect(LPDIRECT3DSURFACE8 iface, D3DLOCKE
hr = IUnknown_QueryInterface(This->Container, &IID_IDirect3DBaseTexture8, (void**) &cont);
if (SUCCEEDED(hr) && NULL != cont) {
IDirect3DBaseTexture8Impl_SetDirty(cont, TRUE);
#if 0
/* Now setup the texture appropraitly */
D3DRESOURCETYPE containerType = IDirect3DBaseTexture8Impl_GetType(cont);
if (containerType == D3DRTYPE_TEXTURE) {
@ -318,6 +253,7 @@ HRESULT WINAPI IDirect3DSurface8Impl_LockRect(LPDIRECT3DSURFACE8 iface, D3DLOCKE
} else {
FIXME("Set dirty on container type %d\n", containerType);
}
#endif
IDirect3DBaseTexture8_Release(cont);
cont = NULL;
}
@ -356,29 +292,10 @@ HRESULT WINAPI IDirect3DSurface8Impl_UnlockRect(LPDIRECT3DSURFACE8 iface) {
}
if (0 == This->myDesc.Usage) { /* classic surface */
#if 0
if (This->Container) {
HRESULT hr;
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) {
IDirect3DCubeTexture8Impl *pTexture = (IDirect3DCubeTexture8Impl *)cont;
pTexture->Dirty = TRUE;
} else {
FIXME("Set dirty on container type %d\n", containerType);
}
IDirect3DBaseTexture8_Release(cont);
cont = NULL;
}
}
#endif
/**
* nothing to do
* waiting to reload the surface via IDirect3DDevice8::UpdateTexture
*/
} else if (D3DUSAGE_RENDERTARGET & This->myDesc.Usage) { /* render surfaces */
if (This == This->Device->backBuffer || This == This->Device->frontBuffer) {
@ -441,6 +358,9 @@ HRESULT WINAPI IDirect3DSurface8Impl_UnlockRect(LPDIRECT3DSURFACE8 iface) {
glRasterPos3iv(&prev_rasterpos[0]);
vcheckGLcall("glRasterPos3iv");
LEAVE_GL();
This->Dirty = FALSE;
} else {
FIXME("unsupported unlocking to Rendering surface surf@%p usage(%lu)\n", This, This->myDesc.Usage);
}
@ -462,7 +382,6 @@ unlock_end:
return D3D_OK;
}
ICOM_VTABLE(IDirect3DSurface8) Direct3DSurface8_Vtbl =
{
ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
@ -478,3 +397,80 @@ ICOM_VTABLE(IDirect3DSurface8) Direct3DSurface8_Vtbl =
IDirect3DSurface8Impl_LockRect,
IDirect3DSurface8Impl_UnlockRect,
};
HRESULT WINAPI IDirect3DSurface8Impl_CreateGLTexture(LPDIRECT3DSURFACE8 iface, GLenum gl_target, GLenum gl_level) {
ICOM_THIS(IDirect3DSurface8Impl,iface);
if ((This->myDesc.Format == D3DFMT_P8 || This->myDesc.Format == D3DFMT_A8P8) &&
!GL_SUPPORT_DEV(EXT_PALETTED_TEXTURE, This->Device)) {
/**
* wanted a paletted texture and not really support it in HW
* so software emulation code begin
*/
UINT i;
PALETTEENTRY* pal = This->Device->palettes[This->Device->currentPalette];
VOID* surface = (VOID*) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, This->myDesc.Width * This->myDesc.Height * sizeof(DWORD));
BYTE* dst = (BYTE*) surface;
BYTE* src = (BYTE*) This->allocatedMemory;
for (i = 0; i < This->myDesc.Width * This->myDesc.Height; i++) {
BYTE color = *src++;
*dst++ = pal[color].peRed;
*dst++ = pal[color].peGreen;
*dst++ = pal[color].peBlue;
if (This->myDesc.Format == D3DFMT_A8P8)
*dst++ = pal[color].peFlags;
else
*dst++ = 0xFF;
}
TRACE("Calling glTexImage2D %x i=%d, intfmt=%x, w=%d, h=%d,0=%d, glFmt=%x, glType=%x, Mem=%p\n",
gl_target,
gl_level,
GL_RGBA,
This->myDesc.Width,
This->myDesc.Height,
0,
GL_RGBA,
GL_UNSIGNED_BYTE,
surface);
glTexImage2D(gl_target,
gl_level,
GL_RGBA,
This->myDesc.Width,
This->myDesc.Height,
0,
GL_RGBA,
GL_UNSIGNED_BYTE,
surface);
checkGLcall("glTexImage2D");
HeapFree(GetProcessHeap(), 0, surface);
return D3D_OK;
}
TRACE("Calling glTexImage2D %x i=%d, intfmt=%x, w=%d, h=%d,0=%d, glFmt=%x, glType=%x, Mem=%p\n",
gl_target,
gl_level,
D3DFmt2GLIntFmt(This->myDesc.Format),
This->myDesc.Width,
This->myDesc.Height,
0,
D3DFmt2GLFmt(This->myDesc.Format),
D3DFmt2GLType(This->myDesc.Format),
This->allocatedMemory);
glTexImage2D(gl_target,
gl_level,
D3DFmt2GLIntFmt(This->myDesc.Format),
This->myDesc.Width,
This->myDesc.Height,
0,
D3DFmt2GLFmt(This->myDesc.Format),
D3DFmt2GLType(This->myDesc.Format),
This->allocatedMemory);
checkGLcall("glTexImage2D");
return D3D_OK;
}

View File

@ -74,7 +74,6 @@ HRESULT WINAPI IDirect3DSwapChain8Impl_GetBackBuffer(LPDIRECT3DSWAPCHAIN8 iface,
return D3D_OK;
}
ICOM_VTABLE(IDirect3DSwapChain8) Direct3DSwapChain8_Vtbl =
{
ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE

View File

@ -133,22 +133,30 @@ void WINAPI IDirect3DTexture8Impl_PreLoad(LPDIRECT3DTEXTURE8 iface) {
checkGLcall("glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, This->levels)");
}
TRACE("Calling glTexImage2D %x i=%d, intfmt=%x, w=%d, h=%d,0=%d, glFmt=%x, glType=%lx, Mem=%p\n",
GL_TEXTURE_2D, i, fmt2glintFmt(This->format),
This->surfaces[i]->myDesc.Width, This->surfaces[i]->myDesc.Height,
0, fmt2glFmt(This->format), fmt2glType(This->format),
IDirect3DSurface8Impl_CreateGLTexture((LPDIRECT3DSURFACE8) This->surfaces[i], GL_TEXTURE_2D, i);
#if 0
TRACE("Calling glTexImage2D %x i=%d, intfmt=%x, w=%d, h=%d,0=%d, glFmt=%x, glType=%x, Mem=%p\n",
GL_TEXTURE_2D,
i,
D3DFmt2GLIntFmt(This->format),
This->surfaces[i]->myDesc.Width,
This->surfaces[i]->myDesc.Height,
0,
D3DFmt2GLFmt(This->format),
D3DFmt2GLType(This->format),
This->surfaces[i]->allocatedMemory);
glTexImage2D(GL_TEXTURE_2D,
i,
fmt2glintFmt(This->format),
D3DFmt2GLIntFmt(This->format),
This->surfaces[i]->myDesc.Width,
This->surfaces[i]->myDesc.Height,
0,
fmt2glFmt(This->format),
fmt2glType(This->format),
D3DFmt2GLFmt(This->format),
D3DFmt2GLType(This->format),
This->surfaces[i]->allocatedMemory);
checkGLcall("glTexImage2D");
#endif
/* Removed glTexParameterf now TextureStageStates are initialized at startup */
This->Dirty = FALSE;
}
@ -202,20 +210,27 @@ HRESULT WINAPI IDirect3DTexture8Impl_LockRect(LPDIRECT3DTEXTURE8 iface,
ICOM_THIS(IDirect3DTexture8Impl,iface);
TRACE("(%p) Level (%d)\n", This, Level);
if (Level < This->levels) {
/**
* Not dirtified while Surfaces don't notify dirtification
* This->Dirty = TRUE;
*/
hr = IDirect3DSurface8Impl_LockRect((LPDIRECT3DSURFACE8) This->surfaces[Level], pLockedRect, pRect, Flags);
TRACE("(%p) Level (%d) success(%lu)\n", This, Level, hr);
/**
* Not dirtified while Surfaces don't notify dirtification
* This->Dirty = TRUE;
*/
hr = IDirect3DSurface8Impl_LockRect((LPDIRECT3DSURFACE8) This->surfaces[Level], pLockedRect, pRect, Flags);
TRACE("(%p) Level (%d) success(%lu)\n", This, Level, hr);
} else {
FIXME("Levels seems too high?!!\n");
}
return hr;
}
HRESULT WINAPI IDirect3DTexture8Impl_UnlockRect(LPDIRECT3DTEXTURE8 iface, UINT Level) {
HRESULT hr;
ICOM_THIS(IDirect3DTexture8Impl,iface);
TRACE("(%p) : stub\n", This);
TRACE("(%p) Level (%d)\n", This, Level);
if (Level < This->levels) {
hr = IDirect3DSurface8Impl_UnlockRect((LPDIRECT3DSURFACE8) This->surfaces[Level]);
TRACE("(%p) Level (%d) success(%lu)\n", This, Level, hr);
} else {
FIXME("Levels seems too high?!!\n");
}
return D3D_OK;
}
HRESULT WINAPI IDirect3DTexture8Impl_AddDirtyRect(LPDIRECT3DTEXTURE8 iface, CONST RECT* pDirtyRect) {

419
dlls/d3d8/utils.c Normal file
View File

@ -0,0 +1,419 @@
/*
* D3D8 utils
*
* Copyright 2002-2003 Jason Edmeades
* Raphael Junqueira
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "config.h"
#include <math.h>
#define NONAMELESSUNION
#define NONAMELESSSTRUCT
#include "windef.h"
#include "winbase.h"
#include "winuser.h"
#include "wingdi.h"
#include "wine/debug.h"
#include "d3d8_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(d3d);
#if 0
# define VTRACE(A) TRACE A
#else
# define VTRACE(A)
#endif
const char* debug_d3ddevicetype(D3DDEVTYPE devtype) {
switch (devtype) {
#define DEVTYPE_TO_STR(dev) case dev: return #dev
DEVTYPE_TO_STR(D3DDEVTYPE_HAL);
DEVTYPE_TO_STR(D3DDEVTYPE_REF);
DEVTYPE_TO_STR(D3DDEVTYPE_SW);
#undef DEVTYPE_TO_STR
default:
FIXME("Unrecognized %u D3DDEVTYPE!\n", devtype);
return "unrecognized";
}
}
const char* debug_d3dusage(DWORD usage) {
switch (usage) {
#define D3DUSAGE_TO_STR(u) case u: return #u
D3DUSAGE_TO_STR(D3DUSAGE_RENDERTARGET);
D3DUSAGE_TO_STR(D3DUSAGE_DEPTHSTENCIL);
D3DUSAGE_TO_STR(D3DUSAGE_WRITEONLY);
D3DUSAGE_TO_STR(D3DUSAGE_SOFTWAREPROCESSING);
D3DUSAGE_TO_STR(D3DUSAGE_DONOTCLIP);
D3DUSAGE_TO_STR(D3DUSAGE_POINTS);
D3DUSAGE_TO_STR(D3DUSAGE_RTPATCHES);
D3DUSAGE_TO_STR(D3DUSAGE_NPATCHES);
D3DUSAGE_TO_STR(D3DUSAGE_DYNAMIC);
#undef D3DUSAGE_TO_STR
case 0: return "none";
default:
FIXME("Unrecognized %lu Usage!\n", usage);
return "unrecognized";
}
}
const char* debug_d3dformat(D3DFORMAT fmt) {
switch (fmt) {
#define FMT_TO_STR(fmt) case fmt: return #fmt
FMT_TO_STR(D3DFMT_UNKNOWN);
FMT_TO_STR(D3DFMT_R8G8B8);
FMT_TO_STR(D3DFMT_A8R8G8B8);
FMT_TO_STR(D3DFMT_X8R8G8B8);
FMT_TO_STR(D3DFMT_R5G6B5);
FMT_TO_STR(D3DFMT_X1R5G5B5);
FMT_TO_STR(D3DFMT_A1R5G5B5);
FMT_TO_STR(D3DFMT_A4R4G4B4);
FMT_TO_STR(D3DFMT_R3G3B2);
FMT_TO_STR(D3DFMT_A8);
FMT_TO_STR(D3DFMT_A8R3G3B2);
FMT_TO_STR(D3DFMT_X4R4G4B4);
FMT_TO_STR(D3DFMT_A8P8);
FMT_TO_STR(D3DFMT_P8);
FMT_TO_STR(D3DFMT_L8);
FMT_TO_STR(D3DFMT_A8L8);
FMT_TO_STR(D3DFMT_A4L4);
FMT_TO_STR(D3DFMT_V8U8);
FMT_TO_STR(D3DFMT_L6V5U5);
FMT_TO_STR(D3DFMT_X8L8V8U8);
FMT_TO_STR(D3DFMT_Q8W8V8U8);
FMT_TO_STR(D3DFMT_V16U16);
FMT_TO_STR(D3DFMT_W11V11U10);
FMT_TO_STR(D3DFMT_UYVY);
FMT_TO_STR(D3DFMT_YUY2);
FMT_TO_STR(D3DFMT_DXT1);
FMT_TO_STR(D3DFMT_DXT2);
FMT_TO_STR(D3DFMT_DXT3);
FMT_TO_STR(D3DFMT_DXT4);
FMT_TO_STR(D3DFMT_DXT5);
FMT_TO_STR(D3DFMT_D16_LOCKABLE);
FMT_TO_STR(D3DFMT_D32);
FMT_TO_STR(D3DFMT_D15S1);
FMT_TO_STR(D3DFMT_D24S8);
FMT_TO_STR(D3DFMT_D16);
FMT_TO_STR(D3DFMT_D24X8);
FMT_TO_STR(D3DFMT_D24X4S4);
FMT_TO_STR(D3DFMT_VERTEXDATA);
FMT_TO_STR(D3DFMT_INDEX16);
FMT_TO_STR(D3DFMT_INDEX32);
#undef FMT_TO_STR
default:
FIXME("Unrecognized %u D3DFORMAT!\n", fmt);
return "unrecognized";
}
}
const char* debug_d3dressourcetype(D3DRESOURCETYPE res) {
switch (res) {
#define RES_TO_STR(res) case res: return #res;
RES_TO_STR(D3DRTYPE_SURFACE);
RES_TO_STR(D3DRTYPE_VOLUME);
RES_TO_STR(D3DRTYPE_TEXTURE);
RES_TO_STR(D3DRTYPE_VOLUMETEXTURE);
RES_TO_STR(D3DRTYPE_CUBETEXTURE);
RES_TO_STR(D3DRTYPE_VERTEXBUFFER);
RES_TO_STR(D3DRTYPE_INDEXBUFFER);
#undef RES_TO_STR
default:
FIXME("Unrecognized %u D3DRESOURCETYPE!\n", res);
return "unrecognized";
}
}
const char* debug_d3dprimitivetype(D3DPRIMITIVETYPE PrimitiveType) {
switch (PrimitiveType) {
#define PRIM_TO_STR(prim) case prim: return #prim;
PRIM_TO_STR(D3DPT_POINTLIST);
PRIM_TO_STR(D3DPT_LINELIST);
PRIM_TO_STR(D3DPT_LINESTRIP);
PRIM_TO_STR(D3DPT_TRIANGLELIST);
PRIM_TO_STR(D3DPT_TRIANGLESTRIP);
PRIM_TO_STR(D3DPT_TRIANGLEFAN);
#undef PRIM_TO_STR
default:
FIXME("Unrecognized %u D3DPRIMITIVETYPE!\n", PrimitiveType);
return "unrecognized";
}
}
/*
* Simple utility routines used for dx -> gl mapping of byte formats
*/
SHORT bytesPerPixel(D3DFORMAT fmt) {
SHORT retVal;
switch (fmt) {
/* color buffer */
case D3DFMT_P8: retVal = 1; break;
case D3DFMT_R3G3B2: retVal = 1; break;
case D3DFMT_R5G6B5: retVal = 2; break;
case D3DFMT_X1R5G5B5: retVal = 2; break;
case D3DFMT_A4R4G4B4: retVal = 2; break;
case D3DFMT_X4R4G4B4: retVal = 2; break;
case D3DFMT_A1R5G5B5: retVal = 2; break;
case D3DFMT_R8G8B8: retVal = 3; break;
case D3DFMT_X8R8G8B8: retVal = 4; break;
case D3DFMT_A8R8G8B8: retVal = 4; break;
/* depth/stencil buffer */
case D3DFMT_D16_LOCKABLE: retVal = 2; break;
case D3DFMT_D16: retVal = 2; break;
case D3DFMT_D15S1: retVal = 2; break;
case D3DFMT_D24X4S4: retVal = 4; break;
case D3DFMT_D24S8: retVal = 4; break;
case D3DFMT_D24X8: retVal = 4; break;
case D3DFMT_D32: retVal = 4; break;
/* unknown */
case D3DFMT_UNKNOWN:
/* Guess at the highest value of the above */
TRACE("D3DFMT_UNKNOWN - Guessing at 4 bytes/pixel %u\n", fmt);
retVal = 4;
break;
default:
FIXME("Unhandled fmt(%u,%s)\n", fmt, debug_d3dformat(fmt));
retVal = 4;
}
TRACE("bytes/Pxl for fmt(%u,%s) = %d\n", fmt, debug_d3dformat(fmt), retVal);
return retVal;
}
GLint fmt2glintFmt(D3DFORMAT fmt) {
GLint retVal;
switch (fmt) {
case D3DFMT_A4R4G4B4: retVal = GL_RGBA4; break;
case D3DFMT_A8R8G8B8: retVal = GL_RGBA8; break;
case D3DFMT_X8R8G8B8: retVal = GL_RGB8; break;
case D3DFMT_R8G8B8: retVal = GL_RGB8; break;
case D3DFMT_R5G6B5: retVal = GL_RGB5; break; /* fixme: internal format 6 for g? */
case D3DFMT_A1R5G5B5: retVal = GL_RGB5_A1; break;
default:
FIXME("Unhandled fmt(%u,%s)\n", fmt, debug_d3dformat(fmt));
retVal = GL_RGB8;
}
TRACE("fmt2glintFmt for fmt(%u,%s) = %x\n", fmt, debug_d3dformat(fmt), retVal);
return retVal;
}
GLenum fmt2glFmt(D3DFORMAT fmt) {
GLenum retVal;
switch (fmt) {
case D3DFMT_A4R4G4B4: retVal = GL_BGRA; break;
case D3DFMT_A8R8G8B8: retVal = GL_BGRA; break;
case D3DFMT_X8R8G8B8: retVal = GL_BGRA; break;
case D3DFMT_R8G8B8: retVal = GL_BGR; break;
case D3DFMT_R5G6B5: retVal = GL_RGB; break;
case D3DFMT_A1R5G5B5: retVal = GL_BGRA; break;
default:
FIXME("Unhandled fmt(%u,%s)\n", fmt, debug_d3dformat(fmt));
retVal = GL_BGR;
}
TRACE("fmt2glFmt for fmt(%u,%s) = %x\n", fmt, debug_d3dformat(fmt), retVal);
return retVal;
}
GLenum fmt2glType(D3DFORMAT fmt) {
GLenum retVal;
switch (fmt) {
case D3DFMT_A4R4G4B4: retVal = GL_UNSIGNED_SHORT_4_4_4_4_REV; break;
case D3DFMT_A8R8G8B8: retVal = GL_UNSIGNED_BYTE; break;
case D3DFMT_X8R8G8B8: retVal = GL_UNSIGNED_BYTE; break;
case D3DFMT_R5G6B5: retVal = GL_UNSIGNED_SHORT_5_6_5; break;
case D3DFMT_R8G8B8: retVal = GL_UNSIGNED_BYTE; break;
case D3DFMT_A1R5G5B5: retVal = GL_UNSIGNED_SHORT_1_5_5_5_REV; break;
default:
FIXME("Unhandled fmt(%u,%s)\n", fmt, debug_d3dformat(fmt));
retVal = GL_UNSIGNED_BYTE;
}
TRACE("fmt2glType for fmt(%u,%s) = %x\n", fmt, debug_d3dformat(fmt), retVal);
return retVal;
}
int D3DPrimitiveListGetVertexSize(D3DPRIMITIVETYPE PrimitiveType, int iNumPrim) {
switch (PrimitiveType) {
case D3DPT_POINTLIST: return iNumPrim;
case D3DPT_LINELIST: return iNumPrim * 2;
case D3DPT_LINESTRIP: return iNumPrim + 1;
case D3DPT_TRIANGLELIST: return iNumPrim * 3;
case D3DPT_TRIANGLESTRIP: return iNumPrim + 2;
case D3DPT_TRIANGLEFAN: return iNumPrim + 2;
default:
FIXME("Unrecognized %u D3DPRIMITIVETYPE!\n", PrimitiveType);
return 0;
}
}
int D3DPrimitive2GLenum(D3DPRIMITIVETYPE PrimitiveType) {
switch (PrimitiveType) {
case D3DPT_POINTLIST: return GL_POINTS;
case D3DPT_LINELIST: return GL_LINES;
case D3DPT_LINESTRIP: return GL_LINE_STRIP;
case D3DPT_TRIANGLELIST: return GL_TRIANGLES;
case D3DPT_TRIANGLESTRIP: return GL_TRIANGLE_STRIP;
case D3DPT_TRIANGLEFAN: return GL_TRIANGLE_FAN;
default:
FIXME("Unrecognized %u D3DPRIMITIVETYPE!\n", PrimitiveType);
return GL_POLYGON;
}
}
int D3DFVFGetSize(D3DFORMAT fvf) {
int ret = 0;
if (fvf & D3DFVF_XYZ) ret += 3 * sizeof(float);
else if (fvf & D3DFVF_XYZRHW) ret += 4 * sizeof(float);
if (fvf & D3DFVF_NORMAL) ret += 3 * sizeof(float);
if (fvf & D3DFVF_PSIZE) ret += sizeof(float);
if (fvf & D3DFVF_DIFFUSE) ret += sizeof(DWORD);
if (fvf & D3DFVF_SPECULAR) ret += sizeof(DWORD);
/*if (fvf & D3DFVF_TEX1) ret += 1;*/
return ret;
}
GLenum D3DFmt2GLDepthFmt(D3DFORMAT fmt) {
switch (fmt) {
/* depth/stencil buffer */
case D3DFMT_D16_LOCKABLE:
case D3DFMT_D16:
case D3DFMT_D15S1:
case D3DFMT_D24X4S4:
case D3DFMT_D24S8:
case D3DFMT_D24X8:
case D3DFMT_D32:
return GL_DEPTH_COMPONENT;
default:
FIXME("Unhandled fmt(%u,%s)\n", fmt, debug_d3dformat(fmt));
}
return 0;
}
GLenum D3DFmt2GLDepthType(D3DFORMAT fmt) {
switch (fmt) {
/* depth/stencil buffer */
case D3DFMT_D15S1:
case D3DFMT_D16_LOCKABLE:
case D3DFMT_D16:
return GL_UNSIGNED_SHORT;
case D3DFMT_D24X4S4:
case D3DFMT_D24S8:
case D3DFMT_D24X8:
case D3DFMT_D32:
return GL_UNSIGNED_INT;
default:
FIXME("Unhandled fmt(%u,%s)\n", fmt, debug_d3dformat(fmt));
}
return 0;
}
SHORT D3DFmtGetBpp(D3DFORMAT fmt) {
return bytesPerPixel(fmt);
}
GLint D3DFmt2GLIntFmt(D3DFORMAT fmt) {
return fmt2glintFmt(fmt);
}
GLenum D3DFmt2GLFmt(D3DFORMAT fmt) {
return fmt2glFmt(fmt);
}
GLenum D3DFmt2GLType(D3DFORMAT fmt) {
return fmt2glType(fmt);
}
int SOURCEx_RGB_EXT(DWORD arg) {
switch(arg) {
case D3DTSS_COLORARG0: return GL_SOURCE2_RGB_EXT;
case D3DTSS_COLORARG1: return GL_SOURCE0_RGB_EXT;
case D3DTSS_COLORARG2: return GL_SOURCE1_RGB_EXT;
case D3DTSS_ALPHAARG0:
case D3DTSS_ALPHAARG1:
case D3DTSS_ALPHAARG2:
default:
FIXME("Invalid arg %ld\n", arg);
return GL_SOURCE0_RGB_EXT;
}
}
int OPERANDx_RGB_EXT(DWORD arg) {
switch(arg) {
case D3DTSS_COLORARG0: return GL_OPERAND2_RGB_EXT;
case D3DTSS_COLORARG1: return GL_OPERAND0_RGB_EXT;
case D3DTSS_COLORARG2: return GL_OPERAND1_RGB_EXT;
case D3DTSS_ALPHAARG0:
case D3DTSS_ALPHAARG1:
case D3DTSS_ALPHAARG2:
default:
FIXME("Invalid arg %ld\n", arg);
return GL_OPERAND0_RGB_EXT;
}
}
int SOURCEx_ALPHA_EXT(DWORD arg) {
switch(arg) {
case D3DTSS_ALPHAARG0: return GL_SOURCE2_ALPHA_EXT;
case D3DTSS_ALPHAARG1: return GL_SOURCE0_ALPHA_EXT;
case D3DTSS_ALPHAARG2: return GL_SOURCE1_ALPHA_EXT;
case D3DTSS_COLORARG0:
case D3DTSS_COLORARG1:
case D3DTSS_COLORARG2:
default:
FIXME("Invalid arg %ld\n", arg);
return GL_SOURCE0_ALPHA_EXT;
}
}
int OPERANDx_ALPHA_EXT(DWORD arg) {
switch(arg) {
case D3DTSS_ALPHAARG0: return GL_OPERAND2_ALPHA_EXT;
case D3DTSS_ALPHAARG1: return GL_OPERAND0_ALPHA_EXT;
case D3DTSS_ALPHAARG2: return GL_OPERAND1_ALPHA_EXT;
case D3DTSS_COLORARG0:
case D3DTSS_COLORARG1:
case D3DTSS_COLORARG2:
default:
FIXME("Invalid arg %ld\n", arg);
return GL_OPERAND0_ALPHA_EXT;
}
}
GLenum StencilOp(DWORD op) {
switch(op) {
case D3DSTENCILOP_KEEP : return GL_KEEP;
case D3DSTENCILOP_ZERO : return GL_ZERO;
case D3DSTENCILOP_REPLACE : return GL_REPLACE;
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 D3DSTENCILOP_INCR\n");
return GL_INCR; /* Fixme - needs to support wrap */
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);
return GL_ALWAYS;
}
}

View File

@ -136,12 +136,17 @@ void WINAPI IDirect3DVolumeTexture8Impl_PreLoad(LPDIRECT3DVOLUMETEXTU
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAX_LEVEL, This->levels - 1);
checkGLcall("glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAX_LEVEL, This->levels - 1)");
}
TRACE("Calling glTexImage3D %x i=%d, intfmt=%x, w=%d, h=%d,d=%d, 0=%d, glFmt=%x, glType=%lx, Mem=%p\n",
GL_TEXTURE_3D, i, fmt2glintFmt(This->format),
This->volumes[i]->myDesc.Width, This->volumes[i]->myDesc.Height,
TRACE("Calling glTexImage3D %x i=%d, intfmt=%x, w=%d, h=%d,d=%d, 0=%d, glFmt=%x, glType=%x, Mem=%p\n",
GL_TEXTURE_3D,
i,
fmt2glintFmt(This->format),
This->volumes[i]->myDesc.Width,
This->volumes[i]->myDesc.Height,
This->volumes[i]->myDesc.Depth,
0, fmt2glFmt(This->format), fmt2glType(This->format),
0,
fmt2glFmt(This->format),
fmt2glType(This->format),
This->volumes[i]->allocatedMemory);
glTexImage3D(GL_TEXTURE_3D,
i,
@ -154,7 +159,7 @@ void WINAPI IDirect3DVolumeTexture8Impl_PreLoad(LPDIRECT3DVOLUMETEXTU
fmt2glType(This->format),
This->volumes[i]->allocatedMemory);
checkGLcall("glTexImage3D");
/* Removed glTexParameterf now TextureStageStates are initialized at startup */
This->Dirty = FALSE;
}