#include "stdafx.h" /* ----------------------------------------------------------------------------- File: RageTexture.h Desc: Abstract class for a texture with metadata. Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved. ----------------------------------------------------------------------------- */ //----------------------------------------------------------------------------- // Includes //----------------------------------------------------------------------------- #include "RageTexture.h" #include "RageUtil.h" #include #include //----------------------------------------------------------------------------- // RageTexture constructor //----------------------------------------------------------------------------- RageTexture::RageTexture( RageDisplay* pScreen, const CString &sFilePath, DWORD dwMaxSize, DWORD dwTextureColorDepth, int iMipMaps, int iAlphaBits, bool bDither, bool bStretch ) { // LOG->Trace( "RageTexture::RageTexture()" ); // save a pointer to the D3D device m_pd3dDevice = pScreen->m_pd3dDevice; assert( m_pd3dDevice != NULL ); // save the file path m_sFilePath = sFilePath; // m_pd3dTexture = NULL; m_iRefCount = 1; m_iSourceWidth = m_iSourceHeight = 0; m_iTextureWidth = m_iTextureHeight = 0; m_iImageWidth = m_iImageHeight = 0; m_iFramesWide = m_iFramesHigh = 1; } RageTexture::~RageTexture() { } void RageTexture::CreateFrameRects() { GetFrameDimensionsFromFileName( m_sFilePath, &m_iFramesWide, &m_iFramesHigh ); /////////////////////////////////// // Fill in the m_FrameRects with the bounds of each frame in the animation. /////////////////////////////////// m_TextureCoordRects.SetSize( 1, 10 ); // most textures will have only one frame m_TextureCoordRects.RemoveAll(); for( int j=0; jTrace( "Adding frect%d %f %f %f %f", (i + j*m_iFramesWide), frect.left, frect.top, frect.right, frect.bottom ); } } } void RageTexture::GetFrameDimensionsFromFileName( CString sPath, int* piFramesWide, int* piFramesHigh ) const { *piFramesWide = *piFramesHigh = 1; // set default values in case we don't find the dimension in the file name sPath.MakeLower(); CString sDir, sFName, sExt; splitrelpath( sPath, sDir, sFName, sExt); CStringArray arrayBits; split( sFName, " ", arrayBits, false ); for( int i=0; i