no message

This commit is contained in:
Chris Danford
2002-05-19 01:59:48 +00:00
parent 62f3f01a05
commit 2f80235590
141 changed files with 2540 additions and 2058 deletions
+53 -43
View File
@@ -5,7 +5,7 @@
Desc: Holder for a static texture with metadata. Can load just about any image format.
Copyright (c) 2001-2002 by the persons listed below. All rights reserved.
Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved.
-----------------------------------------------------------------------------
*/
@@ -31,18 +31,22 @@
// RageBitmapTexture constructor
//-----------------------------------------------------------------------------
RageBitmapTexture::RageBitmapTexture(
RageScreen* pScreen,
RageDisplay* pScreen,
const CString &sFilePath,
const DWORD dwMaxSize,
const DWORD dwTextureColorDepth,
const DWORD dwHints ) :
RageTexture( pScreen, sFilePath, dwMaxSize, dwTextureColorDepth, dwHints )
DWORD dwMaxSize,
DWORD dwTextureColorDepth,
int iMipMaps,
int iAlphaBits,
bool bDither,
bool bStretch
) :
RageTexture( pScreen, sFilePath, dwMaxSize, dwTextureColorDepth, iMipMaps, iAlphaBits, bDither, bStretch )
{
// LOG->WriteLine( "RageBitmapTexture::RageBitmapTexture()" );
m_pd3dTexture = NULL;
Create( dwMaxSize, dwTextureColorDepth, dwHints );
Create( dwMaxSize, dwTextureColorDepth, iMipMaps, iAlphaBits, bDither, bStretch );
CreateFrameRects();
}
@@ -53,12 +57,16 @@ RageBitmapTexture::~RageBitmapTexture()
}
void RageBitmapTexture::Reload(
const DWORD dwMaxSize,
const DWORD dwTextureColorDepth,
const DWORD dwHints )
DWORD dwMaxSize,
DWORD dwTextureColorDepth,
int iMipMaps,
int iAlphaBits,
bool bDither,
bool bStretch
)
{
SAFE_RELEASE(m_pd3dTexture);
Create( dwMaxSize, dwTextureColorDepth, dwHints );
Create( dwMaxSize, dwTextureColorDepth, iMipMaps, iAlphaBits, bDither, bStretch );
// leave m_iRefCount alone!
CreateFrameRects();
}
@@ -72,49 +80,51 @@ LPDIRECT3DTEXTURE8 RageBitmapTexture::GetD3DTexture()
}
void RageBitmapTexture::Create( DWORD dwMaxSize, DWORD dwTextureColorDepth, DWORD dwHints )
void RageBitmapTexture::Create(
DWORD dwMaxSize,
DWORD dwTextureColorDepth,
int iMipMaps,
int iAlphaBits,
bool bDither,
bool bStretch
)
{
HRESULT hr;
// look in the file name for a format hints
m_sFilePath.MakeLower();
if( -1 != m_sFilePath.Find("no alpha") )
iAlphaBits = 0;
else if( -1 != m_sFilePath.Find("1 alpha") )
iAlphaBits = 1;
if( -1 != m_sFilePath.Find("dither") )
bDither = true;
///////////////////////
// Figure out which texture format to use
///////////////////////
D3DFORMAT fmtTexture;
// look in the file name for a format hint
m_sFilePath.MakeLower();
switch( dwTextureColorDepth )
{
case 16:
if( -1 != m_sFilePath.Find("no alpha") )
fmtTexture = D3DFMT_R5G6B5;
else if( -1 != m_sFilePath.Find("1 alpha") )
fmtTexture = D3DFMT_A1R5G5B5;
else
fmtTexture = D3DFMT_A4R4G4B4;
break;
switch( iAlphaBits )
{
case 0: fmtTexture = D3DFMT_R5G6B5; break;
case 1: fmtTexture = D3DFMT_A1R5G5B5; break;
default: fmtTexture = D3DFMT_A4R4G4B4; break;
}
case 32:
fmtTexture = D3DFMT_A8R8G8B8;
break;
default:
ASSERT( false ); // invalid color depth value
FatalError( "Invalid color depth: %d bits", dwTextureColorDepth );
}
// look in the file name for a dither hint
bool bDither = (dwHints & TEXTURE_HINT_DITHER)
|| -1 != m_sFilePath.Find("dither");
bool bCreateMipMaps = !(dwHints & TEXTURE_HINT_NOMIPMAPS);
/////////////////////
// Figure out whether the texture can fit into texture memory unscaled
/////////////////////
bool bScaleImageToTextureSize;
D3DXIMAGE_INFO ddii;
if( FAILED( hr = D3DXGetImageInfoFromFile(
m_sFilePath,
@@ -124,9 +134,9 @@ void RageBitmapTexture::Create( DWORD dwMaxSize, DWORD dwTextureColorDepth, DWOR
}
// find out what the min texture size is
dwMaxSize = min( dwMaxSize, SCREEN->GetDeviceCaps().MaxTextureWidth );
dwMaxSize = min( dwMaxSize, DISPLAY->GetDeviceCaps().MaxTextureWidth );
bScaleImageToTextureSize = ddii.Width > dwMaxSize || ddii.Height > dwMaxSize;
bStretch |= ddii.Width > dwMaxSize || ddii.Height > dwMaxSize;
/*
// HACK: The stupid Savage driver will report that it can hold the entire texture,
@@ -139,13 +149,13 @@ void RageBitmapTexture::Create( DWORD dwMaxSize, DWORD dwTextureColorDepth, DWOR
if( FAILED( hr = D3DXCreateTextureFromFileEx(
m_pd3dDevice, // device
m_sFilePath, // soure file
bScaleImageToTextureSize ? dwMaxSize : D3DX_DEFAULT, // width
bScaleImageToTextureSize ? dwMaxSize : D3DX_DEFAULT, // height
bCreateMipMaps ? 4 : 0, // mip map levels
bStretch ? dwMaxSize : D3DX_DEFAULT, // width
bStretch ? dwMaxSize : D3DX_DEFAULT, // height
iMipMaps, // mip map levels
0, // usage (is a render target?)
fmtTexture, // our preferred texture format
D3DPOOL_MANAGED, // which memory pool
(bScaleImageToTextureSize ? D3DX_FILTER_BOX : D3DX_FILTER_NONE) | (bDither ? D3DX_FILTER_DITHER : 0), // filter
(bStretch ? D3DX_FILTER_BOX : D3DX_FILTER_NONE) | (bDither ? D3DX_FILTER_DITHER : 0), // filter
D3DX_FILTER_BOX | (bDither ? D3DX_FILTER_DITHER : 0), // mip filter
0, // no color key
&ddii, // struct to fill with source image info
@@ -171,7 +181,7 @@ void RageBitmapTexture::Create( DWORD dwMaxSize, DWORD dwTextureColorDepth, DWOR
m_TextureFormat = ddsd.Format;
if( bScaleImageToTextureSize )
if( bStretch )
{
m_iImageWidth = m_iTextureWidth;
m_iImageHeight = m_iTextureHeight;
@@ -182,11 +192,11 @@ void RageBitmapTexture::Create( DWORD dwMaxSize, DWORD dwTextureColorDepth, DWOR
m_iImageHeight = m_iSourceHeight;
}
LOG->WriteLine( "RageBitmapTexture: Loaded '%s' (%ux%u) from disk. bScaleImageToTextureSize = %d, source %d,%d; image %d,%d.",
LOG->WriteLine( "RageBitmapTexture: Loaded '%s' (%ux%u) from disk. bStretch = %d, source %d,%d; image %d,%d.",
m_sFilePath,
GetTextureWidth(),
GetTextureHeight(),
bScaleImageToTextureSize,
bStretch,
m_iSourceWidth,
m_iSourceHeight,
m_iImageWidth,