mirror of
https://github.com/gwdevhub/gMod.git
synced 2026-07-18 08:29:31 +00:00
uMod2 Alpha Version: known bugs: I disabled the remove device function inside the gui, because something in the event handling goes terrible wrong.
Implemented a some new features.
This commit is contained in:
@@ -33,16 +33,6 @@ uMod_TextureClient_DX9::uMod_TextureClient_DX9( IDirect3DDevice9* device, const
|
||||
uMod_TextureClient_DX9::~uMod_TextureClient_DX9(void)
|
||||
{
|
||||
Message("uMod_TextureClient_DX9::~uMod_TextureClient(void): %lu\n", this);
|
||||
if (Server!=NULL) Server->RemoveClient( this, Version);
|
||||
|
||||
if (Mutex!=NULL) CloseHandle(Mutex);
|
||||
|
||||
if (Update!=NULL) delete [] Update;
|
||||
if (FileToMod!=NULL)
|
||||
{
|
||||
for (int i=0; i<NumberToMod; i++) if (FileToMod[i].Textures!=NULL) delete [] FileToMod[i].Textures;
|
||||
delete [] FileToMod;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -57,17 +47,14 @@ int uMod_TextureClient_DX9::AddTexture( uMod_IDirect3DTexture9* pTexture)
|
||||
|
||||
Message("uMod_TextureClient_DX9::AddTexture( %lu): %lu (thread: %lu)\n", pTexture, this, GetCurrentThreadId());
|
||||
|
||||
MyTypeHash hash;
|
||||
if (int ret = pTexture->GetHash( hash))
|
||||
if (int ret = pTexture->ComputetHash( BoolComputeCRC))
|
||||
{
|
||||
Bool_CheckAgainNonAdded = true;
|
||||
NonAdded_OriginalTextures.Add( pTexture);
|
||||
return (ret);
|
||||
}
|
||||
|
||||
pTexture->Hash = hash;
|
||||
|
||||
if (BoolSaveAllTextures) SaveTexture(pTexture);
|
||||
if (BoolSaveAllTextures) SaveTexture(pTexture, true);
|
||||
|
||||
if (gl_ErrorState & uMod_ERROR_FATAL) return (RETURN_FATAL_ERROR);
|
||||
|
||||
@@ -87,17 +74,14 @@ int uMod_TextureClient_DX9::AddTexture( uMod_IDirect3DVolumeTexture9* pTexture)
|
||||
|
||||
Message("uMod_TextureClient_DX9::AddTexture( Volume: %lu): %lu (thread: %lu)\n", pTexture, this, GetCurrentThreadId());
|
||||
|
||||
MyTypeHash hash;
|
||||
if (int ret = pTexture->GetHash( hash))
|
||||
if (int ret = pTexture->ComputetHash( BoolComputeCRC))
|
||||
{
|
||||
Bool_CheckAgainNonAdded = true;
|
||||
NonAdded_OriginalVolumeTextures.Add( pTexture);
|
||||
return (ret);
|
||||
}
|
||||
|
||||
pTexture->Hash = hash;
|
||||
|
||||
if (BoolSaveAllTextures) SaveTexture(pTexture);
|
||||
if (BoolSaveAllTextures) SaveTexture(pTexture, true);
|
||||
|
||||
if (gl_ErrorState & uMod_ERROR_FATAL) return (RETURN_FATAL_ERROR);
|
||||
|
||||
@@ -117,17 +101,14 @@ int uMod_TextureClient_DX9::AddTexture( uMod_IDirect3DCubeTexture9* pTexture)
|
||||
|
||||
Message("uMod_TextureClient_DX9::AddTexture( Cube: %lu): %lu (thread: %lu)\n", pTexture, this, GetCurrentThreadId());
|
||||
|
||||
MyTypeHash hash;
|
||||
if (int ret = pTexture->GetHash( hash))
|
||||
if (int ret = pTexture->ComputetHash( BoolComputeCRC))
|
||||
{
|
||||
Bool_CheckAgainNonAdded = true;
|
||||
NonAdded_OriginalCubeTextures.Add( pTexture);
|
||||
return (ret);
|
||||
}
|
||||
|
||||
pTexture->Hash = hash;
|
||||
|
||||
if (BoolSaveAllTextures) SaveTexture(pTexture);
|
||||
if (BoolSaveAllTextures) SaveTexture(pTexture, true);
|
||||
|
||||
if (gl_ErrorState & uMod_ERROR_FATAL) return (RETURN_FATAL_ERROR);
|
||||
|
||||
@@ -149,8 +130,7 @@ int uMod_TextureClient_DX9::CheckAgainNonAdded(void)
|
||||
{
|
||||
uMod_IDirect3DTexture9* pTexture = NonAdded_OriginalTextures[i];
|
||||
|
||||
MyTypeHash hash;
|
||||
if (pTexture->GetHash( hash) == 0)
|
||||
if (pTexture->ComputetHash( BoolComputeCRC) == RETURN_OK)
|
||||
{
|
||||
NonAdded_OriginalTextures.Remove(pTexture);
|
||||
OriginalTextures.Add( pTexture); // add the texture to the list of original texture
|
||||
@@ -163,8 +143,7 @@ int uMod_TextureClient_DX9::CheckAgainNonAdded(void)
|
||||
{
|
||||
uMod_IDirect3DVolumeTexture9* pTexture = NonAdded_OriginalVolumeTextures[i];
|
||||
|
||||
MyTypeHash hash;
|
||||
if (pTexture->GetHash( hash) == 0)
|
||||
if (pTexture->ComputetHash( BoolComputeCRC) == RETURN_OK)
|
||||
{
|
||||
NonAdded_OriginalVolumeTextures.Remove(pTexture);
|
||||
OriginalVolumeTextures.Add( pTexture); // add the texture to the list of original texture
|
||||
@@ -177,8 +156,7 @@ int uMod_TextureClient_DX9::CheckAgainNonAdded(void)
|
||||
{
|
||||
uMod_IDirect3DCubeTexture9* pTexture = NonAdded_OriginalCubeTextures[i];
|
||||
|
||||
MyTypeHash hash;
|
||||
if (pTexture->GetHash( hash) == 0)
|
||||
if (pTexture->ComputetHash( BoolComputeCRC) == RETURN_OK)
|
||||
{
|
||||
NonAdded_OriginalCubeTextures.Remove(pTexture);
|
||||
OriginalCubeTextures.Add( pTexture); // add the texture to the list of original texture
|
||||
@@ -299,49 +277,248 @@ int uMod_TextureClient_DX9::SaveSingleTexture(bool val)
|
||||
}
|
||||
|
||||
|
||||
int uMod_TextureClient_DX9::SaveTexture(uMod_IDirect3DTexture9* pTexture)
|
||||
int uMod_TextureClient_DX9::SaveTexture(uMod_IDirect3DTexture9* pTexture, bool save_all)
|
||||
{
|
||||
if (pTexture==NULL) return (RETURN_BAD_ARGUMENT);
|
||||
if (SavePath[0]==0)
|
||||
{
|
||||
Message("uMod_TextureClient_DX9::SaveTexture( %#lX, %lu): %lu, SavePath not set\n", pTexture->Hash, pTexture->m_D3Dtex, this);
|
||||
return (RETURN_TEXTURE_NOT_SAVED);
|
||||
}
|
||||
D3DSURFACE_DESC desc;
|
||||
if (pTexture->m_D3Dtex->GetLevelDesc(0, &desc)!=D3D_OK) //get the format and the size of the texture
|
||||
{
|
||||
Message("uMod_TextureClient_DX9::SaveTexture() Failed: GetLevelDesc \n");
|
||||
return (RETURN_GetLevelDesc_FAILED);
|
||||
}
|
||||
|
||||
if (save_all)
|
||||
{
|
||||
if (WidthFilter)
|
||||
{
|
||||
unsigned int min = WidthFilter >> 32;
|
||||
unsigned int max = (WidthFilter<<32) >> 32;
|
||||
if (desc.Width<min || desc.Width> max) return (RETURN_OK);
|
||||
}
|
||||
if (HeightFilter)
|
||||
{
|
||||
unsigned int min = HeightFilter >> 32;
|
||||
unsigned int max = (HeightFilter<<32) >> 32;
|
||||
if (desc.Height<min || desc.Height> max) return (RETURN_OK);
|
||||
}
|
||||
if (!SaveTextureFilterFormat(desc.Format)) return (RETURN_OK);
|
||||
}
|
||||
|
||||
|
||||
wchar_t file[MAX_PATH];
|
||||
if (GameName[0]) swprintf_s( file, MAX_PATH, L"%ls\\%ls_W%u_H%u_F%u_T_%#llX", SavePath, GameName, desc.Width, desc.Height,desc.Format, pTexture->Hash);
|
||||
else swprintf_s( file, MAX_PATH, L"%ls\\W%u_H%u_F%u_T_%#llX", SavePath, desc.Width, desc.Height, desc.Format, pTexture->Hash);
|
||||
Message("uMod_TextureClient_DX9::SaveTexture( %ls): %lu\n", file, this);
|
||||
|
||||
return (SaveTexture( pTexture->m_D3Dtex, file));
|
||||
}
|
||||
|
||||
int uMod_TextureClient_DX9::SaveTexture(uMod_IDirect3DVolumeTexture9* pTexture, bool save_all)
|
||||
{
|
||||
if (pTexture==NULL) return (RETURN_BAD_ARGUMENT);
|
||||
if (SavePath[0]==0) {Message("uMod_TextureClient_DX9::SaveTexture( %#lX, %lu): %lu, SavePath not set\n", pTexture->Hash, pTexture->m_D3Dtex, this); return (RETURN_TEXTURE_NOT_SAVED);}
|
||||
|
||||
D3DVOLUME_DESC desc;
|
||||
if (pTexture->m_D3Dtex->GetLevelDesc(0, &desc)!=D3D_OK) //get the format and the size of the texture
|
||||
{
|
||||
Message("uMod_TextureClient_DX9::SaveTexture() Failed: GetLevelDesc \n");
|
||||
return (RETURN_GetLevelDesc_FAILED);
|
||||
}
|
||||
|
||||
if (save_all)
|
||||
{
|
||||
if (WidthFilter)
|
||||
{
|
||||
unsigned int min = WidthFilter >> 32;
|
||||
unsigned int max = (WidthFilter<<32) >> 32;
|
||||
if (desc.Width<min || desc.Width> max) return (RETURN_OK);
|
||||
}
|
||||
if (HeightFilter)
|
||||
{
|
||||
unsigned int min = HeightFilter >> 32;
|
||||
unsigned int max = (HeightFilter<<32) >> 32;
|
||||
if (desc.Height<min || desc.Height> max) return (RETURN_OK);
|
||||
}
|
||||
if (DepthFilter)
|
||||
{
|
||||
unsigned int min = DepthFilter >> 32;
|
||||
unsigned int max = (DepthFilter<<32) >> 32;
|
||||
if (desc.Depth<min || desc.Depth> max) return (RETURN_OK);
|
||||
}
|
||||
if (!SaveTextureFilterFormat(desc.Format)) return (RETURN_OK);
|
||||
}
|
||||
|
||||
wchar_t file[MAX_PATH];
|
||||
if (GameName[0]) swprintf_s( file, MAX_PATH, L"%ls\\%ls_T_%#lX.dds", SavePath, GameName, pTexture->Hash);
|
||||
else swprintf_s( file, MAX_PATH, L"%ls\\T_%#lX.dds", SavePath, pTexture->Hash);
|
||||
if (GameName[0]) swprintf_s( file, MAX_PATH, L"%ls\\%ls_W%u_H%u_D%u_F%u_V_%#llX", SavePath, GameName, desc.Width, desc.Height, desc.Depth, desc.Format, pTexture->Hash);
|
||||
else swprintf_s( file, MAX_PATH, L"%ls\\W%u_H%u_D%u_F%u_V_%#llX", SavePath, desc.Width, desc.Height, desc.Depth, desc.Format, pTexture->Hash);
|
||||
Message("uMod_TextureClient_DX9::SaveTexture( %ls): %lu\n", file, this);
|
||||
|
||||
if (D3D_OK!=D3DXSaveTextureToFileW( file, D3DXIFF_DDS, pTexture->m_D3Dtex, NULL)) return (RETURN_TEXTURE_NOT_SAVED);
|
||||
return (RETURN_OK);
|
||||
return (SaveTexture( pTexture->m_D3Dtex, file));
|
||||
}
|
||||
|
||||
int uMod_TextureClient_DX9::SaveTexture(uMod_IDirect3DVolumeTexture9* pTexture)
|
||||
int uMod_TextureClient_DX9::SaveTexture(uMod_IDirect3DCubeTexture9* pTexture, bool save_all)
|
||||
{
|
||||
if (pTexture==NULL) return (RETURN_BAD_ARGUMENT);
|
||||
if (SavePath[0]==0) {Message("uMod_TextureClient_DX9::SaveTexture( %#lX, %lu): %lu, SavePath not set\n", pTexture->Hash, pTexture->m_D3Dtex, this); return (RETURN_TEXTURE_NOT_SAVED);}
|
||||
|
||||
D3DSURFACE_DESC desc;
|
||||
if (pTexture->m_D3Dtex->GetLevelDesc(0, &desc)!=D3D_OK) //get the format and the size of the texture
|
||||
{
|
||||
Message("uMod_TextureClient_DX9::SaveTexture() Failed: GetLevelDesc \n");
|
||||
return (RETURN_GetLevelDesc_FAILED);
|
||||
}
|
||||
|
||||
if (save_all)
|
||||
{
|
||||
if (WidthFilter)
|
||||
{
|
||||
unsigned int min = WidthFilter >> 32;
|
||||
unsigned int max = (WidthFilter<<32) >> 32;
|
||||
if (desc.Width<min || desc.Width> max) return (RETURN_OK);
|
||||
}
|
||||
if (!SaveTextureFilterFormat(desc.Format)) return (RETURN_OK);
|
||||
}
|
||||
|
||||
wchar_t file[MAX_PATH];
|
||||
if (GameName[0]) swprintf_s( file, MAX_PATH, L"%ls\\%ls_V_%#lX.dds", SavePath, GameName, pTexture->Hash);
|
||||
else swprintf_s( file, MAX_PATH, L"%ls\\V_%#lX.dds", SavePath, pTexture->Hash);
|
||||
if (GameName[0]) swprintf_s( file, MAX_PATH, L"%ls\\%ls_W%u_F%u_C_%#llX.dds", SavePath, GameName, desc.Width, desc.Format, pTexture->Hash);
|
||||
else swprintf_s( file, MAX_PATH, L"%ls\\W%u_F%u_C_%#llX.dds", SavePath, desc.Width, desc.Format, pTexture->Hash);
|
||||
Message("uMod_TextureClient_DX9::SaveTexture( %ls): %lu\n", file, this);
|
||||
|
||||
if (D3D_OK!=D3DXSaveTextureToFileW( file, D3DXIFF_DDS, pTexture->m_D3Dtex, NULL)) return (RETURN_TEXTURE_NOT_SAVED);
|
||||
return (RETURN_OK);
|
||||
|
||||
return (SaveTexture( pTexture->m_D3Dtex, file));
|
||||
}
|
||||
|
||||
int uMod_TextureClient_DX9::SaveTexture(uMod_IDirect3DCubeTexture9* pTexture)
|
||||
|
||||
int uMod_TextureClient_DX9::SaveTexture(IDirect3DBaseTexture9* pTexture, wchar_t *file)
|
||||
{
|
||||
if (pTexture==NULL) return (RETURN_BAD_ARGUMENT);
|
||||
if (SavePath[0]==0) {Message("uMod_TextureClient_DX9::SaveTexture( %#lX, %lu): %lu, SavePath not set\n", pTexture->Hash, pTexture->m_D3Dtex, this); return (RETURN_TEXTURE_NOT_SAVED);}
|
||||
|
||||
wchar_t file[MAX_PATH];
|
||||
if (GameName[0]) swprintf_s( file, MAX_PATH, L"%ls\\%ls_C_%#lX.dds", SavePath, GameName, pTexture->Hash);
|
||||
else swprintf_s( file, MAX_PATH, L"%ls\\C_%#lX.dds", SavePath, pTexture->Hash);
|
||||
Message("uMod_TextureClient_DX9::SaveTexture( %ls): %lu\n", file, this);
|
||||
|
||||
if (D3D_OK!=D3DXSaveTextureToFileW( file, D3DXIFF_DDS, pTexture->m_D3Dtex, NULL)) return (RETURN_TEXTURE_NOT_SAVED);
|
||||
unsigned int len=0;
|
||||
while (file[len]) len++;
|
||||
if (FileFormat & uMod_D3DXIFF_BMP)
|
||||
{
|
||||
file[len] = '.';file[len+1] = 'b';file[len+2] = 'm';file[len+3] = 'p';file[len+4] = '\0';
|
||||
if (D3D_OK!=D3DXSaveTextureToFileW( file, D3DXIFF_BMP, pTexture, NULL)) return (RETURN_TEXTURE_NOT_SAVED);
|
||||
}
|
||||
if (FileFormat & uMod_D3DXIFF_JPG)
|
||||
{
|
||||
file[len] = '.';file[len+1] = 'j';file[len+2] = 'p';file[len+3] = 'g';file[len+4] = '\0';
|
||||
if (D3D_OK!=D3DXSaveTextureToFileW( file, D3DXIFF_JPG, pTexture, NULL)) return (RETURN_TEXTURE_NOT_SAVED);
|
||||
}
|
||||
if (FileFormat & uMod_D3DXIFF_TGA)
|
||||
{
|
||||
file[len] = '.';file[len+1] = 't';file[len+2] = 'g';file[len+3] = 'a';file[len+4] = '\0';
|
||||
if (D3D_OK!=D3DXSaveTextureToFileW( file, D3DXIFF_TGA, pTexture, NULL)) return (RETURN_TEXTURE_NOT_SAVED);
|
||||
}
|
||||
if (FileFormat & uMod_D3DXIFF_PNG)
|
||||
{
|
||||
file[len] = '.';file[len+1] = 'p';file[len+2] = 'n';file[len+3] = 'g';file[len+4] = '\0';
|
||||
if (D3D_OK!=D3DXSaveTextureToFileW( file, D3DXIFF_PNG, pTexture, NULL)) return (RETURN_TEXTURE_NOT_SAVED);
|
||||
}
|
||||
if (FileFormat & uMod_D3DXIFF_DDS)
|
||||
{
|
||||
file[len] = '.';file[len+1] = 'd';file[len+2] = 'd';file[len+3] = 's';file[len+4] = '\0';
|
||||
if (D3D_OK!=D3DXSaveTextureToFileW( file, D3DXIFF_DDS, pTexture, NULL)) return (RETURN_TEXTURE_NOT_SAVED);
|
||||
}
|
||||
if (FileFormat & uMod_D3DXIFF_PPM)
|
||||
{
|
||||
file[len] = '.';file[len+1] = 'p';file[len+2] = 'p';file[len+3] = 'm';file[len+4] = '\0';
|
||||
if (D3D_OK!=D3DXSaveTextureToFileW( file, D3DXIFF_PPM, pTexture, NULL)) return (RETURN_TEXTURE_NOT_SAVED);
|
||||
}
|
||||
return (RETURN_OK);
|
||||
}
|
||||
|
||||
#define DEF_FormatCheck( format ) \
|
||||
case format: \
|
||||
{ \
|
||||
if (FormatFilter & uMod_ ## format) return (true); \
|
||||
else return (false); \
|
||||
}
|
||||
|
||||
|
||||
bool uMod_TextureClient_DX9::SaveTextureFilterFormat(D3DFORMAT format)
|
||||
{
|
||||
if (FormatFilter == 0u) return (true);
|
||||
switch(format) //switch trough the formats to calculate the size of the raw data
|
||||
{
|
||||
DEF_FormatCheck( D3DFMT_A1) // 1-bit monochrome.
|
||||
DEF_FormatCheck( D3DFMT_R3G3B2) // 8-bit RGB texture format using 3 bits for red, 3 bits for green, and 2 bits for blue.
|
||||
DEF_FormatCheck( D3DFMT_A8) // 8-bit alpha only.
|
||||
|
||||
DEF_FormatCheck( D3DFMT_A8P8) // 8-bit color indexed with 8 bits of alpha.
|
||||
DEF_FormatCheck( D3DFMT_P8) // 8-bit color indexed.
|
||||
DEF_FormatCheck( D3DFMT_L8) // 8-bit luminance only.
|
||||
DEF_FormatCheck( D3DFMT_A4L4) // 8-bit using 4 bits each for alpha and luminance.
|
||||
|
||||
//DEF_FormatCheck( D3DFMT_FORCE_DWORD)
|
||||
DEF_FormatCheck( D3DFMT_S8_LOCKABLE) // A lockable 8-bit stencil buffer.
|
||||
|
||||
DEF_FormatCheck( D3DFMT_D16_LOCKABLE) //16-bit z-buffer bit depth.
|
||||
DEF_FormatCheck( D3DFMT_D15S1) // 16-bit z-buffer bit depth where 15 bits are reserved for the depth channel and 1 bit is reserved for the stencil channel.
|
||||
DEF_FormatCheck( D3DFMT_L6V5U5) // 16-bit bump-map format with luminance using 6 bits for luminance, and 5 bits each for v and u.
|
||||
DEF_FormatCheck( D3DFMT_V8U8) // 16-bit bump-map format using 8 bits each for u and v data.
|
||||
DEF_FormatCheck( D3DFMT_CxV8U8) // 16-bit normal compression format. The texture sampler computes the C channel from) C = sqrt(1 - U2 - V2).
|
||||
DEF_FormatCheck( D3DFMT_R5G6B5) // 16-bit RGB pixel format with 5 bits for red, 6 bits for green, and 5 bits for blue.
|
||||
DEF_FormatCheck( D3DFMT_X1R5G5B5) // 16-bit pixel format where 5 bits are reserved for each color.
|
||||
DEF_FormatCheck( D3DFMT_A1R5G5B5) // 16-bit pixel format where 5 bits are reserved for each color and 1 bit is reserved for alpha.
|
||||
DEF_FormatCheck( D3DFMT_A4R4G4B4) // 16-bit ARGB pixel format with 4 bits for each channel.
|
||||
DEF_FormatCheck( D3DFMT_A8R3G3B2) // 16-bit ARGB texture format using 8 bits for alpha, 3 bits each for red and green, and 2 bits for blue.
|
||||
DEF_FormatCheck( D3DFMT_X4R4G4B4) // 16-bit RGB pixel format using 4 bits for each color.
|
||||
DEF_FormatCheck( D3DFMT_L16) // 16-bit luminance only.
|
||||
DEF_FormatCheck( D3DFMT_R16F) // 16-bit float format using 16 bits for the red channel.
|
||||
DEF_FormatCheck( D3DFMT_A8L8) // 16-bit using 8 bits each for alpha and luminance.
|
||||
DEF_FormatCheck( D3DFMT_D16) // 16-bit z-buffer bit depth.
|
||||
DEF_FormatCheck( D3DFMT_INDEX16) // 16-bit index buffer bit depth.
|
||||
DEF_FormatCheck( D3DFMT_G8R8_G8B8) // ??
|
||||
DEF_FormatCheck( D3DFMT_R8G8_B8G8) // ??
|
||||
DEF_FormatCheck( D3DFMT_UYVY) // ??
|
||||
DEF_FormatCheck( D3DFMT_YUY2) // ??
|
||||
|
||||
DEF_FormatCheck( D3DFMT_R8G8B8) //24-bit RGB pixel format with 8 bits per channel.
|
||||
|
||||
DEF_FormatCheck( D3DFMT_R32F) // 32-bit float format using 32 bits for the red channel.
|
||||
DEF_FormatCheck( D3DFMT_X8L8V8U8) // 32-bit bump-map format with luminance using 8 bits for each channel.
|
||||
DEF_FormatCheck( D3DFMT_A2W10V10U10) // 32-bit bump-map format using 2 bits for alpha and 10 bits each for w, v, and u.
|
||||
DEF_FormatCheck( D3DFMT_Q8W8V8U8) // 32-bit bump-map format using 8 bits for each channel.
|
||||
DEF_FormatCheck( D3DFMT_V16U16) // 32-bit bump-map format using 16 bits for each channel.
|
||||
DEF_FormatCheck( D3DFMT_A8R8G8B8) // 32-bit ARGB pixel format with alpha, using 8 bits per channel.
|
||||
DEF_FormatCheck( D3DFMT_X8R8G8B8) // 32-bit RGB pixel format, where 8 bits are reserved for each color.
|
||||
DEF_FormatCheck( D3DFMT_A2B10G10R10) // 32-bit pixel format using 10 bits for each color and 2 bits for alpha.
|
||||
DEF_FormatCheck( D3DFMT_A8B8G8R8) // 32-bit ARGB pixel format with alpha, using 8 bits per channel.
|
||||
DEF_FormatCheck( D3DFMT_X8B8G8R8) // 32-bit RGB pixel format, where 8 bits are reserved for each color.
|
||||
DEF_FormatCheck( D3DFMT_G16R16) // 32-bit pixel format using 16 bits each for green and red.
|
||||
DEF_FormatCheck( D3DFMT_G16R16F) // 32-bit float format using 16 bits for the red channel and 16 bits for the green channel.
|
||||
DEF_FormatCheck( D3DFMT_A2R10G10B10) // 32-bit pixel format using 10 bits each for red, green, and blue, and 2 bits for alpha.
|
||||
DEF_FormatCheck( D3DFMT_D32) // 32-bit z-buffer bit depth.
|
||||
DEF_FormatCheck( D3DFMT_D24S8) // 32-bit z-buffer bit depth using 24 bits for the depth channel and 8 bits for the stencil channel.
|
||||
DEF_FormatCheck( D3DFMT_D24X8) //32-bit z-buffer bit depth using 24 bits for the depth channel.
|
||||
DEF_FormatCheck( D3DFMT_D24X4S4) // 32-bit z-buffer bit depth using 24 bits for the depth channel and 4 bits for the stencil channel.
|
||||
DEF_FormatCheck( D3DFMT_D32F_LOCKABLE) // A lockable format where the depth value is represented as a standard IEEE floating-point number.
|
||||
DEF_FormatCheck( D3DFMT_D24FS8) // A non-lockable format that contains 24 bits of depth (in a 24-bit floating point format - 20e4) and 8 bits of stencil.
|
||||
DEF_FormatCheck( D3DFMT_D32_LOCKABLE) // A lockable 32-bit depth buffer.
|
||||
DEF_FormatCheck( D3DFMT_INDEX32) // 32-bit index buffer bit depth.
|
||||
|
||||
DEF_FormatCheck( D3DFMT_G32R32F) // 64-bit float format using 32 bits for the red channel and 32 bits for the green channel.
|
||||
DEF_FormatCheck( D3DFMT_Q16W16V16U16) // 64-bit bump-map format using 16 bits for each component.
|
||||
DEF_FormatCheck( D3DFMT_A16B16G16R16) // 64-bit pixel format using 16 bits for each component.
|
||||
DEF_FormatCheck( D3DFMT_A16B16G16R16F) // 64-bit float format using 16 bits for the each channel (alpha, blue, green, red).
|
||||
|
||||
DEF_FormatCheck( D3DFMT_A32B32G32R32F) // 128-bit float format using 32 bits for the each channel (alpha, blue, green, red).
|
||||
DEF_FormatCheck( D3DFMT_DXT2)
|
||||
DEF_FormatCheck( D3DFMT_DXT3)
|
||||
DEF_FormatCheck( D3DFMT_DXT4)
|
||||
DEF_FormatCheck( D3DFMT_DXT5)
|
||||
DEF_FormatCheck( D3DFMT_DXT1)
|
||||
default: //compressed formats
|
||||
{
|
||||
return (false);
|
||||
}
|
||||
}
|
||||
return (false);
|
||||
}
|
||||
int uMod_TextureClient_DX9::MergeUpdate(void)
|
||||
{
|
||||
if (NumberOfUpdate<0) {return (RETURN_OK);}
|
||||
@@ -548,7 +725,7 @@ int uMod_TextureClient_DX9::MergeUpdate(void)
|
||||
|
||||
if (to_lookup != NULL) delete [] to_lookup;
|
||||
|
||||
Message("uMod_TextureClient_DX9::MergeUpdate() END: %lu\n", this);
|
||||
Message("uMod_TextureClient_DX9::MergeUpdate() END: %p\n", this);
|
||||
|
||||
CheckAgainNonAdded();
|
||||
return (UnlockMutex());
|
||||
@@ -558,7 +735,7 @@ int uMod_TextureClient_DX9::MergeUpdate(void)
|
||||
|
||||
int uMod_TextureClient_DX9::LookUpToMod( uMod_IDirect3DTexture9* pTexture, int num_index_list, int *index_list) // should only be called for original textures
|
||||
{
|
||||
Message("uMod_TextureClient_DX9::LookUpToMod( %lu): hash: %#lX, %lu\n", pTexture, pTexture->Hash, this);
|
||||
Message("uMod_TextureClient_DX9::LookUpToMod( %p): hash: %#llX, %p\n", pTexture, pTexture->Hash, this);
|
||||
if (pTexture->CrossRef_D3Dtex!=NULL) return (RETURN_OK); // bug, this texture is already switched
|
||||
int index = GetIndex( pTexture->Hash, num_index_list, index_list);
|
||||
if (index>=0)
|
||||
@@ -582,12 +759,37 @@ int uMod_TextureClient_DX9::LookUpToMod( uMod_IDirect3DTexture9* pTexture, int n
|
||||
fake_Texture->Reference = index;
|
||||
}
|
||||
}
|
||||
else if (BoolComputeCRC && pTexture->CRC>0)
|
||||
{
|
||||
index = GetIndex( pTexture->CRC, num_index_list, index_list);
|
||||
if (index>=0)
|
||||
{
|
||||
uMod_IDirect3DTexture9 *fake_Texture;
|
||||
if (int ret = LoadTexture( & (FileToMod[index]), &fake_Texture)) return (ret);
|
||||
if (SwitchTextures( fake_Texture, pTexture))
|
||||
{
|
||||
Message("uMod_TextureClient_DX9::LookUpToMod(): textures not switched %#lX\n", FileToMod[index].Hash);
|
||||
fake_Texture->Release();
|
||||
}
|
||||
else
|
||||
{
|
||||
IDirect3DBaseTexture9 **temp = new IDirect3DBaseTexture9*[FileToMod[index].NumberOfTextures+1];
|
||||
for (int j=0; j<FileToMod[index].NumberOfTextures; j++) temp[j] = (IDirect3DBaseTexture9*) FileToMod[index].Textures[j];
|
||||
|
||||
if (FileToMod[index].Textures!=NULL) delete [] FileToMod[index].Textures;
|
||||
FileToMod[index].Textures = (void**) temp;
|
||||
|
||||
FileToMod[index].Textures[FileToMod[index].NumberOfTextures++] = fake_Texture;
|
||||
fake_Texture->Reference = index;
|
||||
}
|
||||
}
|
||||
}
|
||||
return (RETURN_OK);
|
||||
}
|
||||
|
||||
int uMod_TextureClient_DX9::LookUpToMod( uMod_IDirect3DVolumeTexture9* pTexture, int num_index_list, int *index_list) // should only be called for original textures
|
||||
{
|
||||
Message("uMod_TextureClient_DX9::LookUpToMod( Volume %lu): hash: %#lX, %lu\n", pTexture, pTexture->Hash, this);
|
||||
Message("uMod_TextureClient_DX9::LookUpToMod( Volume %p): hash: %#llX, %p\n", pTexture, pTexture->Hash, this);
|
||||
if (pTexture->CrossRef_D3Dtex!=NULL) return (RETURN_OK); // bug, this texture is already switched
|
||||
int index = GetIndex( pTexture->Hash, num_index_list, index_list);
|
||||
if (index>=0)
|
||||
@@ -611,12 +813,37 @@ int uMod_TextureClient_DX9::LookUpToMod( uMod_IDirect3DVolumeTexture9* pTexture,
|
||||
fake_Texture->Reference = index;
|
||||
}
|
||||
}
|
||||
else if (BoolComputeCRC && pTexture->CRC>0)
|
||||
{
|
||||
index = GetIndex( pTexture->CRC, num_index_list, index_list);
|
||||
if (index>=0)
|
||||
{
|
||||
uMod_IDirect3DVolumeTexture9 *fake_Texture;
|
||||
if (int ret = LoadTexture( & (FileToMod[index]), &fake_Texture)) return (ret);
|
||||
if (SwitchTextures( fake_Texture, pTexture))
|
||||
{
|
||||
Message("uMod_TextureClient_DX9::LookUpToMod(): textures not switched %#lX\n", FileToMod[index].Hash);
|
||||
fake_Texture->Release();
|
||||
}
|
||||
else
|
||||
{
|
||||
IDirect3DBaseTexture9 **temp = new IDirect3DBaseTexture9*[FileToMod[index].NumberOfTextures+1];
|
||||
for (int j=0; j<FileToMod[index].NumberOfTextures; j++) temp[j] = (IDirect3DBaseTexture9*) FileToMod[index].Textures[j];
|
||||
|
||||
if (FileToMod[index].Textures!=NULL) delete [] FileToMod[index].Textures;
|
||||
FileToMod[index].Textures = (void**) temp;
|
||||
|
||||
FileToMod[index].Textures[FileToMod[index].NumberOfTextures++] = fake_Texture;
|
||||
fake_Texture->Reference = index;
|
||||
}
|
||||
}
|
||||
}
|
||||
return (RETURN_OK);
|
||||
}
|
||||
|
||||
int uMod_TextureClient_DX9::LookUpToMod( uMod_IDirect3DCubeTexture9* pTexture, int num_index_list, int *index_list) // should only be called for original textures
|
||||
{
|
||||
Message("uMod_TextureClient_DX9::LookUpToMod( Cube %lu): hash: %#lX, %lu\n", pTexture, pTexture->Hash, this);
|
||||
Message("uMod_TextureClient_DX9::LookUpToMod( Cube %p): hash: %#llX, %p\n", pTexture, pTexture->Hash, this);
|
||||
if (pTexture->CrossRef_D3Dtex!=NULL) return (RETURN_OK); // bug, this texture is already switched
|
||||
int index = GetIndex( pTexture->Hash, num_index_list, index_list);
|
||||
if (index>=0)
|
||||
@@ -640,6 +867,31 @@ int uMod_TextureClient_DX9::LookUpToMod( uMod_IDirect3DCubeTexture9* pTexture, i
|
||||
fake_Texture->Reference = index;
|
||||
}
|
||||
}
|
||||
else if (BoolComputeCRC && pTexture->CRC>0)
|
||||
{
|
||||
index = GetIndex( pTexture->CRC, num_index_list, index_list);
|
||||
if (index>=0)
|
||||
{
|
||||
uMod_IDirect3DCubeTexture9 *fake_Texture;
|
||||
if (int ret = LoadTexture( & (FileToMod[index]), &fake_Texture)) return (ret);
|
||||
if (SwitchTextures( fake_Texture, pTexture))
|
||||
{
|
||||
Message("uMod_TextureClient_DX9::LookUpToMod(): textures not switched %#lX\n", FileToMod[index].Hash);
|
||||
fake_Texture->Release();
|
||||
}
|
||||
else
|
||||
{
|
||||
IDirect3DBaseTexture9 **temp = new IDirect3DBaseTexture9*[FileToMod[index].NumberOfTextures+1];
|
||||
for (int j=0; j<FileToMod[index].NumberOfTextures; j++) temp[j] = (IDirect3DBaseTexture9*) FileToMod[index].Textures[j];
|
||||
|
||||
if (FileToMod[index].Textures!=NULL) delete [] FileToMod[index].Textures;
|
||||
FileToMod[index].Textures = (void**) temp;
|
||||
|
||||
FileToMod[index].Textures[FileToMod[index].NumberOfTextures++] = fake_Texture;
|
||||
fake_Texture->Reference = index;
|
||||
}
|
||||
}
|
||||
}
|
||||
return (RETURN_OK);
|
||||
}
|
||||
|
||||
@@ -648,7 +900,7 @@ int uMod_TextureClient_DX9::LookUpToMod( uMod_IDirect3DCubeTexture9* pTexture, i
|
||||
|
||||
int uMod_TextureClient_DX9::LoadTexture( TextureFileStruct* file_in_memory, uMod_IDirect3DTexture9 **ppTexture) // to load fake texture from a file in memory
|
||||
{
|
||||
Message("LoadTexture( %lu, %lu, %#lX): %lu\n", file_in_memory, ppTexture, file_in_memory->Hash, this);
|
||||
Message("LoadTexture( %p, %p, %#llX): %p\n", file_in_memory, ppTexture, file_in_memory->Hash, this);
|
||||
if (D3D_OK != D3DXCreateTextureFromFileInMemoryEx( D3D9Device, file_in_memory->pData, file_in_memory->Size, D3DX_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, 0, D3DFMT_UNKNOWN, D3DPOOL_MANAGED, D3DX_DEFAULT, D3DX_DEFAULT, 0, NULL, NULL, (IDirect3DTexture9 **) ppTexture))
|
||||
//if (D3D_OK != D3DXCreateTextureFromFileInMemory( D3D9Device, file_in_memory->pData, file_in_memory->Size, (IDirect3DTexture9 **) ppTexture))
|
||||
{
|
||||
@@ -662,13 +914,13 @@ int uMod_TextureClient_DX9::LoadTexture( TextureFileStruct* file_in_memory, uMod
|
||||
if (ret == 0x01000000L) ((uMod_IDirect3DDevice9*)D3D9Device)->SetLastCreatedTexture(NULL); //this texture must no be added twice
|
||||
else ((uMod_IDirect3DDevice9Ex*) D3D9Device)->SetLastCreatedTexture(NULL); //this texture must no be added twice
|
||||
|
||||
Message("LoadTexture( %lu, %#lX): DONE\n", *ppTexture, file_in_memory->Hash);
|
||||
Message("LoadTexture( %p, %#llX): DONE\n", *ppTexture, file_in_memory->Hash);
|
||||
return (RETURN_OK);
|
||||
}
|
||||
|
||||
int uMod_TextureClient_DX9::LoadTexture( TextureFileStruct* file_in_memory, uMod_IDirect3DVolumeTexture9 **ppTexture) // to load fake texture from a file in memory
|
||||
{
|
||||
Message("LoadTexture( Volume %lu, %lu, %#lX): %lu\n", file_in_memory, ppTexture, file_in_memory->Hash, this);
|
||||
Message("LoadTexture( Volume %p, %p, %#llX): %p\n", file_in_memory, ppTexture, file_in_memory->Hash, this);
|
||||
if (D3D_OK != D3DXCreateVolumeTextureFromFileInMemoryEx( D3D9Device, file_in_memory->pData, file_in_memory->Size, D3DX_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, 0, D3DFMT_UNKNOWN, D3DPOOL_MANAGED, D3DX_DEFAULT, D3DX_DEFAULT, 0, NULL, NULL, (IDirect3DVolumeTexture9 **) ppTexture))
|
||||
//if (D3D_OK != D3DXCreateVolumeTextureFromFileInMemory( D3D9Device, file_in_memory->pData, file_in_memory->Size, (IDirect3DVolumeTexture9 **) ppTexture))
|
||||
{
|
||||
@@ -682,13 +934,13 @@ int uMod_TextureClient_DX9::LoadTexture( TextureFileStruct* file_in_memory, uMod
|
||||
if (ret == 0x01000000L) ((uMod_IDirect3DDevice9*)D3D9Device)->SetLastCreatedVolumeTexture(NULL); //this texture must no be added twice
|
||||
else ((uMod_IDirect3DDevice9Ex*) D3D9Device)->SetLastCreatedVolumeTexture(NULL); //this texture must no be added twice
|
||||
|
||||
Message("LoadTexture( Volume %lu, %#lX): DONE\n", *ppTexture, file_in_memory->Hash);
|
||||
Message("LoadTexture( Volume %p, %#llX): DONE\n", *ppTexture, file_in_memory->Hash);
|
||||
return (RETURN_OK);
|
||||
}
|
||||
|
||||
int uMod_TextureClient_DX9::LoadTexture( TextureFileStruct* file_in_memory, uMod_IDirect3DCubeTexture9 **ppTexture) // to load fake texture from a file in memory
|
||||
{
|
||||
Message("LoadTexture( Cube %lu, %lu, %#lX): %lu\n", file_in_memory, ppTexture, file_in_memory->Hash, this);
|
||||
Message("LoadTexture( Cube %p, %p, %#llX): %p\n", file_in_memory, ppTexture, file_in_memory->Hash, this);
|
||||
if (D3D_OK != D3DXCreateCubeTextureFromFileInMemoryEx( D3D9Device, file_in_memory->pData, file_in_memory->Size, D3DX_DEFAULT, D3DX_DEFAULT, 0, D3DFMT_UNKNOWN, D3DPOOL_MANAGED, D3DX_DEFAULT, D3DX_DEFAULT, 0, NULL, NULL, (IDirect3DCubeTexture9 **) ppTexture))
|
||||
//if (D3D_OK != D3DXCreateCubeTextureFromFileInMemory( D3D9Device, file_in_memory->pData, file_in_memory->Size, (IDirect3DCubeTexture9 **) ppTexture))
|
||||
{
|
||||
@@ -702,7 +954,7 @@ int uMod_TextureClient_DX9::LoadTexture( TextureFileStruct* file_in_memory, uMod
|
||||
if (ret == 0x01000000L) ((uMod_IDirect3DDevice9*)D3D9Device)->SetLastCreatedCubeTexture(NULL); //this texture must no be added twice
|
||||
else ((uMod_IDirect3DDevice9Ex*) D3D9Device)->SetLastCreatedCubeTexture(NULL); //this texture must no be added twice
|
||||
|
||||
Message("LoadTexture( Cube %lu, %#lX): DONE\n", *ppTexture, file_in_memory->Hash);
|
||||
Message("LoadTexture( Cube %p, %#llX): DONE\n", *ppTexture, file_in_memory->Hash);
|
||||
return (RETURN_OK);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user