* Fixed compilation error
* Implemented IDirect3DBaseTexture9's and IDirect3DTexture9's GetAutoGenFilterType(), GetLOD() and GetLevelCount()

svn path=/trunk/; revision=39341
This commit is contained in:
Gregor Brunmar 2009-02-03 18:55:20 +00:00
parent 98346f3252
commit fe9de35fff
6 changed files with 162 additions and 17 deletions

View file

@ -6,7 +6,6 @@
* PROGRAMERS: Gregor Brunmar <gregor (dot) brunmar (at) home (dot) se>
*/
#define _WIN32_WINNT 0x0502
#include "d3d9_common.h"
#include <d3d9.h>
#include <ddraw.h>

View file

@ -8,6 +8,8 @@
#ifndef _D3D9_BASETEXTURE_H_
#define _D3D9_BASETEXTURE_H_
#include "d3d9_resource.h"
// Work-around for:
// "warning: 'FilterType' is narrower than values of its type"
#if __GNUC__ >=3
@ -31,9 +33,10 @@ typedef struct _Direct3DBaseTexture9_INT
/* 0x005a */ D3DTEXTUREFILTERTYPE FilterType : 8;
struct
{
/* 0x005a */ DWORD dwFilterType : 8;
/* 0x005b */ BOOL bIsAutoGenMipMap : 8;
/* 0x005c */ DWORD MipMapLevels2 : 16;
/* 0x005a */ DWORD dwFilterType : 8;
/* 0x005b */ BOOL bIsAutoGenMipMap : 8;
/* 0x005c */ DWORD MipMapLevels2 : 8;
/* 0x005d */ DWORD MaxLOD : 8;
};
};
/* 0x005e */ WORD wPaletteIndex;

View file

@ -7,6 +7,7 @@
*/
#include "d3d9_mipmap.h"
#include "debug.h"
#include "d3d9_texture.h"
#include "d3d9_device.h"
#include "d3d9_helpers.h"
#include <d3d9.h>
@ -54,7 +55,7 @@ ULONG WINAPI D3D9MipMap_Release(LPDIRECT3DTEXTURE9 iface)
return D3D9BaseObject_Release(&This->BaseTexture.BaseResource.BaseObject);
}
/* IDirect3DBaseTexture9 */
/* IDirect3DResource9 */
/*++
* @name IDirect3DTexture9::GetDevice
@ -74,7 +75,8 @@ ULONG WINAPI D3D9MipMap_Release(LPDIRECT3DTEXTURE9 iface)
* If ppDevice is a bad pointer the return value will be D3DERR_INVALIDCALL.
* If the texture didn't contain any device, the return value will be D3DERR_INVALIDDEVICE.
*
*/HRESULT WINAPI D3D9MipMap_GetDevice(LPDIRECT3DTEXTURE9 iface, IDirect3DDevice9** ppDevice)
*/
HRESULT WINAPI D3D9MipMap_GetDevice(LPDIRECT3DTEXTURE9 iface, IDirect3DDevice9** ppDevice)
{
LPD3D9MIPMAP This = IDirect3DTexture9ToImpl(iface);
LOCK_D3DDEVICE9();
@ -132,6 +134,7 @@ void WINAPI D3D9MipMap_PreLoad(LPDIRECT3DTEXTURE9 iface)
UNIMPLEMENTED
}
/* IDirect3DBaseTexture9 */
D3DRESOURCETYPE WINAPI D3D9MipMap_GetType(LPDIRECT3DTEXTURE9 iface)
{
UNIMPLEMENTED
@ -144,16 +147,44 @@ DWORD WINAPI D3D9MipMap_SetLOD(LPDIRECT3DTEXTURE9 iface, DWORD LODNew)
return 0;
}
/*++
* @name IDirect3DTexture9::GetLOD
* @implemented
*
* The function D3D9MipMap_GetLOD returns the number
* max LODs for the specified texture, if it's managed.
*
* @param LPDIRECT3DTEXTURE9 iface
* Pointer to a IDirect3DTexture9 object returned from IDirect3D9Device::CreateTexture().
*
* @return DWORD
* Returns the number of LODs in the specified texture if it's managed.
*
*/
DWORD WINAPI D3D9MipMap_GetLOD(LPDIRECT3DTEXTURE9 iface)
{
UNIMPLEMENTED
return 0;
LPD3D9MIPMAP This = IDirect3DTexture9ToImpl(iface);
return D3D9Texture_GetLOD( (IDirect3DBaseTexture9*)&This->BaseTexture.lpVtbl );
}
/*++
* @name IDirect3DTexture9::GetLevelCount
* @implemented
*
* The function D3D9MipMap_GetLevelCount returns the number of mip map levels
* in the specified texture.
*
* @param LPDIRECT3DTEXTURE9 iface
* Pointer to a IDirect3DTexture9 object returned from IDirect3D9Device::CreateTexture().
*
* @return DWORD
* Returns the number of levels in the specified texture.
*
*/
DWORD WINAPI D3D9MipMap_GetLevelCount(LPDIRECT3DTEXTURE9 iface)
{
UNIMPLEMENTED
return 0;
LPD3D9MIPMAP This = IDirect3DTexture9ToImpl(iface);
return D3D9Texture_GetLevelCount( (IDirect3DBaseTexture9*)&This->BaseTexture.lpVtbl );
}
HRESULT WINAPI D3D9MipMap_SetAutoGenFilterType(LPDIRECT3DTEXTURE9 iface, D3DTEXTUREFILTERTYPE FilterType)
@ -162,10 +193,24 @@ HRESULT WINAPI D3D9MipMap_SetAutoGenFilterType(LPDIRECT3DTEXTURE9 iface, D3DTEXT
return D3D_OK;
}
/*++
* @name IDirect3DTexture9::GetAutoGenFilterType
* @implemented
*
* The function D3D9MipMap_GetAutoGenFilterType returns filter type
* that is used when automated mipmaping is set.
*
* @param LPDIRECT3DTEXTURE9 iface
* Pointer to a IDirect3DTexture9 object returned from IDirect3D9Device::CreateTexture().
*
* @return D3DTEXTUREFILTERTYPE
* Filter type used when automated mipmaping is set for the specified texture.
*
*/
D3DTEXTUREFILTERTYPE WINAPI D3D9MipMap_GetAutoGenFilterType(LPDIRECT3DTEXTURE9 iface)
{
UNIMPLEMENTED
return D3DRTYPE_TEXTURE;
LPD3D9MIPMAP This = IDirect3DTexture9ToImpl(iface);
return D3D9Texture_GetAutoGenFilterType( (IDirect3DBaseTexture9*)&This->BaseTexture.lpVtbl );
}
void WINAPI D3D9MipMap_GenerateMipSubLevels(LPDIRECT3DTEXTURE9 iface)
@ -220,6 +265,8 @@ static IDirect3DTexture9Vtbl D3D9MipMap_Vtbl =
D3D9MipMap_SetPriority,
D3D9MipMap_GetPriority,
D3D9MipMap_PreLoad,
/* IDirect3DBaseTexture9 methods */
D3D9MipMap_GetType,
D3D9MipMap_SetLOD,
D3D9MipMap_GetLOD,

View file

@ -13,12 +13,12 @@
typedef struct _Direct3DResource9_INT
{
/* 0x0000 */ D3D9BaseObject BaseObject;
/* 0x0020 */ DWORD dwUnknown20;
/* 0x0020 */ BOOL bIsManaged;
/* 0x0024 */ DWORD dwUnknown24;
/* 0x0028 */ DWORD dwUnknown28;
/* 0x002c */ DWORD dwUnknown2c;
/* 0x0030 */ DWORD dwUnknown30;
/* 0x0034 */ DWORD dwUnknown34;
/* 0x0030 */ DWORD dwPriority;
/* 0x0034 */ BOOL bIsDirty;
/* 0x0038 */ D3DPOOL Pool;
/* 0x003c */ LPDWORD dwUnknown3c;
/* 0x0040 */ LPDWORD dwUnknown40;

View file

@ -7,6 +7,18 @@
*/
#include "d3d9_texture.h"
#define LOCK_D3DDEVICE9() D3D9BaseObject_LockDevice(&This->BaseResource.BaseObject)
#define UNLOCK_D3DDEVICE9() D3D9BaseObject_UnlockDevice(&This->BaseResource.BaseObject)
/* Convert a IDirect3DBaseTexture9 pointer safely to the internal implementation struct */
Direct3DBaseTexture9_INT* IDirect3DBaseTexture9ToImpl(LPDIRECT3DBASETEXTURE9 iface)
{
if (NULL == iface)
return NULL;
return (Direct3DBaseTexture9_INT*)((ULONG_PTR)iface - FIELD_OFFSET(Direct3DBaseTexture9_INT, lpVtbl));
}
void InitDirect3DBaseTexture9(Direct3DBaseTexture9_INT* pBaseTexture,
IDirect3DBaseTexture9Vtbl* pVtbl,
DWORD Usage,
@ -22,9 +34,88 @@ void InitDirect3DBaseTexture9(Direct3DBaseTexture9_INT* pBaseTexture,
pBaseTexture->Format = Format;
pBaseTexture->wPaletteIndex = 0xFFFF;
pBaseTexture->Usage = Usage;
pBaseTexture->MipMapLevels =
pBaseTexture->MipMapLevels2 = (WORD)Levels;
pBaseTexture->MipMapLevels = Levels;
pBaseTexture->MipMapLevels2 = Levels;
pBaseTexture->FilterType = D3DTEXF_LINEAR;
pBaseTexture->bIsAutoGenMipMap = (Usage & D3DUSAGE_AUTOGENMIPMAP) != 0;
}
/*++
* @name IDirect3DBaseTexture9::GetAutoGenFilterType
* @implemented
*
* The function D3D9Texture_GetAutoGenFilterType returns filter type
* that is used when automated mipmaping is set.
*
* @param LPDIRECT3DBASETEXTURE9 iface
* Pointer to a IDirect3DBaseTexture9 interface
*
* @return D3DTEXTUREFILTERTYPE
* Filter type used when automated mipmaping is set for the specified texture.
*
*/
D3DTEXTUREFILTERTYPE WINAPI D3D9Texture_GetAutoGenFilterType(LPDIRECT3DBASETEXTURE9 iface)
{
D3DTEXTUREFILTERTYPE FilterType;
Direct3DBaseTexture9_INT* This = IDirect3DBaseTexture9ToImpl(iface);
LOCK_D3DDEVICE9();
FilterType = This->dwFilterType;
UNLOCK_D3DDEVICE9();
return FilterType;
}
/*++
* @name IDirect3DBaseTexture9::GetLOD
* @implemented
*
* The function D3D9Texture_GetLOD returns the number
* max LODs for the specified texture, if it's managed.
*
* @param LPDIRECT3DBASETEXTURE9 iface
* Pointer to a IDirect3DBaseTexture9 interface
*
* @return DWORD
* Returns the number of LODs in the specified texture if it's managed.
*
*/
DWORD WINAPI D3D9Texture_GetLOD(LPDIRECT3DBASETEXTURE9 iface)
{
DWORD MaxLOD = 0;
Direct3DBaseTexture9_INT* This = IDirect3DBaseTexture9ToImpl(iface);
LOCK_D3DDEVICE9();
if (This->BaseResource.bIsManaged)
MaxLOD = This->MaxLOD;
UNLOCK_D3DDEVICE9();
return MaxLOD;
}
/*++
* @name IDirect3DBaseTexture9::GetLevelCount
* @implemented
*
* The function D3D9Texture_GetLevelCount returns the number of mip map levels
* in the specified texture.
*
* @param LPDIRECT3DBASETEXTURE9 iface
* Pointer to a IDirect3DBaseTexture9 interface
*
* @return DWORD
* Returns the number of levels in the specified texture.
*
*/
DWORD WINAPI D3D9Texture_GetLevelCount(LPDIRECT3DBASETEXTURE9 iface)
{
DWORD MipMapLevels;
Direct3DBaseTexture9_INT* This = IDirect3DBaseTexture9ToImpl(iface);
LOCK_D3DDEVICE9();
MipMapLevels = This->MipMapLevels;
UNLOCK_D3DDEVICE9();
return MipMapLevels;
}

View file

@ -22,4 +22,9 @@ void InitDirect3DBaseTexture9(Direct3DBaseTexture9_INT* pBaseTexture,
struct _Direct3DDevice9_INT* pDevice,
enum REF_TYPE RefType);
D3DTEXTUREFILTERTYPE WINAPI D3D9Texture_GetAutoGenFilterType(struct IDirect3DBaseTexture9* iface);
DWORD WINAPI D3D9Texture_GetLOD(struct IDirect3DBaseTexture9* iface);
DWORD WINAPI D3D9Texture_GetLevelCount(struct IDirect3DBaseTexture9* iface);
#endif // _D3D9_TEXTURE_H_