in the middle of working on 1.70. Now compiles in Visual Studio.net

This commit is contained in:
Chris Danford
2002-03-30 20:00:13 +00:00
parent 1c6533c283
commit d2eeed810c
72 changed files with 2726 additions and 1321 deletions
+69 -79
View File
@@ -23,22 +23,25 @@
#include "dxerr8.h"
#include "DXUtil.h"
#include "RageUtil.h"
#include "PrefsManager.h"
#include "RageHelper.h"
//#include <stdio.h>
#include <assert.h>
//-----------------------------------------------------------------------------
// RageBitmapTexture constructor
//-----------------------------------------------------------------------------
RageBitmapTexture::RageBitmapTexture( LPRageScreen pScreen, CString sFilePath, DWORD dwHints ) :
RageBitmapTexture::RageBitmapTexture(
RageScreen* pScreen,
const CString &sFilePath,
const DWORD dwMaxSize,
const DWORD dwTextureColorDepth,
const DWORD dwHints ) :
RageTexture( pScreen, sFilePath )
{
// RageLog( "RageBitmapTexture::RageBitmapTexture()" );
// HELPER.Log( "RageBitmapTexture::RageBitmapTexture()" );
m_pd3dTexture = NULL;
Create( dwHints );
Create( dwMaxSize, dwTextureColorDepth, dwHints );
CreateFrameRects();
}
@@ -58,7 +61,7 @@ LPDIRECT3DTEXTURE8 RageBitmapTexture::GetD3DTexture()
}
void RageBitmapTexture::Create( DWORD dwHints )
void RageBitmapTexture::Create( DWORD dwMaxSize, DWORD dwTextureColorDepth, DWORD dwHints )
{
HRESULT hr;
@@ -69,37 +72,33 @@ void RageBitmapTexture::Create( DWORD dwHints )
// look in the file name for a format hint
m_sFilePath.MakeLower();
if( -1 != m_sFilePath.Find("no alpha") )
switch( dwTextureColorDepth )
{
fmtTexture = D3DFMT_R5G6B5;
}
else if( -1 != m_sFilePath.Find("1 alpha") )
{
fmtTexture = D3DFMT_A1R5G5B5;
}
else // no hint, assume full alpha
{
fmtTexture = D3DFMT_A4R4G4B4;
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;
case 32:
fmtTexture = D3DFMT_A8R8G8B8;
break;
default:
ASSERT( false ); // invalid color depth value
}
// look in the file name for a dither hint
bool bDither = (dwHints & HINT_DITHER)
bool bDither = (dwHints & TEXTURE_HINT_DITHER)
|| -1 != m_sFilePath.Find("dither");
bool bCreateMipMaps = !(dwHints & HINT_NOMIPMAPS);
bool bCreateMipMaps = !(dwHints & TEXTURE_HINT_NOMIPMAPS);
// if the user has requested high color textures, use the higher color
if( PREFS != NULL
&& PREFS->m_GameOptions.m_iDisplayColor == 32
&& PREFS->m_GameOptions.m_iTextureColor == 32 )
{
fmtTexture = D3DFMT_A8R8G8B8;
}
/////////////////////
// Figure out whether the texture can fit into texture memory unscaled
/////////////////////
@@ -110,78 +109,69 @@ void RageBitmapTexture::Create( DWORD dwHints )
m_sFilePath,
&ddii ) ) )
{
RageErrorHr( ssprintf("D3DXGetImageInfoFromFile() failed for file '%s'.", m_sFilePath), hr );
HELPER.FatalErrorHr( hr, "D3DXGetImageInfoFromFile() failed for file '%s'.", m_sFilePath );
}
D3DCAPS8 caps;
m_pd3dDevice->GetDeviceCaps( &caps );
bScaleImageToTextureSize = ddii.Width > caps.MaxTextureWidth
|| ddii.Height > caps.MaxTextureHeight;
// find out what the min texture size is
dwMaxSize = min( dwMaxSize, caps.MaxTextureWidth );
// HACK: The stupid Savage card will report that it can hold the entire texture,
bScaleImageToTextureSize = ddii.Width > dwMaxSize || ddii.Height > dwMaxSize;
/*
// HACK: The stupid Savage driver will report that it can hold the entire texture,
// then allocate something smaller than the dimensions we need!
// after allocating the texture, make sure it's the size we expect. If not,
// load it again with scaling turned on.
for( int i=0; i<2; i++ ) // only try twice
*/
// I'm taking out the Savage hack because it's causing problems. Tough luck for them. I think
// the problem can be worked around by setting MaxTextureSize to 512.
if( FAILED( hr = D3DXCreateTextureFromFileEx(
m_pd3dDevice, // device
m_sFilePath, // soure file
D3DX_DEFAULT, // width
D3DX_DEFAULT, // height
bCreateMipMaps ? 4 : 0, // 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
D3DX_DEFAULT | (bDither ? D3DX_FILTER_DITHER : 0), // mip filter
0, // no color key
&ddii, // struct to fill with source image info
NULL, // no palette
&m_pd3dTexture ) ) )
{
DWORD dwExpectedWidth = bScaleImageToTextureSize ? caps.MaxTextureWidth : ddii.Width;
DWORD dwExpectedHeight = bScaleImageToTextureSize ? caps.MaxTextureHeight : ddii.Height;
if( FAILED( hr = D3DXCreateTextureFromFileEx(
m_pd3dDevice, // device
m_sFilePath, // soure file
D3DX_DEFAULT, D3DX_DEFAULT, // width, height
bCreateMipMaps ? 4 : 0, // 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
D3DX_DEFAULT | (bDither ? D3DX_FILTER_DITHER : 0), // mip filter
0, // no color key
&ddii, // struct to fill with source image info
NULL, // no palette
&m_pd3dTexture ) ) )
{
RageErrorHr( ssprintf("D3DXCreateTextureFromFileEx() failed for file '%s'.", m_sFilePath), hr );
}
/////////////////////
// Save information about the texture
/////////////////////
m_uSourceWidth = ddii.Width;
m_uSourceHeight= ddii.Height;
D3DSURFACE_DESC ddsd;
if ( FAILED( hr = m_pd3dTexture->GetLevelDesc( 0, &ddsd ) ) )
RageErrorHr( "Could not get level Description of D3DX texture!", hr );
// save information about the texture
m_uTextureWidth = ddsd.Width;
m_uTextureHeight = ddsd.Height;
m_TextureFormat = ddsd.Format;
if( dwExpectedWidth == ddsd.Width &&
dwExpectedHeight == ddsd.Height )
break; // done trying to load
else
bScaleImageToTextureSize = true;
HELPER.FatalErrorHr( hr, "D3DXCreateTextureFromFileEx() failed for file '%s'.", m_sFilePath );
}
/////////////////////
// Save information about the texture
/////////////////////
m_iSourceWidth = ddii.Width;
m_iSourceHeight= ddii.Height;
D3DSURFACE_DESC ddsd;
if ( FAILED( hr = m_pd3dTexture->GetLevelDesc( 0, &ddsd ) ) )
HELPER.FatalErrorHr( hr, "Could not get level Description of D3DX texture!" );
// save information about the texture
m_iTextureWidth = ddsd.Width;
m_iTextureHeight = ddsd.Height;
m_TextureFormat = ddsd.Format;
if( bScaleImageToTextureSize )
{
m_uImageWidth = m_uTextureWidth;
m_uImageHeight = m_uTextureHeight;
m_iImageWidth = m_iTextureWidth;
m_iImageHeight = m_iTextureHeight;
}
else
{
m_uImageWidth = m_uSourceWidth;
m_uImageHeight = m_uSourceHeight;
m_iImageWidth = m_iSourceWidth;
m_iImageHeight = m_iSourceHeight;
}
}