new theme graphics and new texture loading algorithm

This commit is contained in:
Chris Danford
2002-01-29 08:19:03 +00:00
parent c6e2f17db4
commit fbb9e9494f
7 changed files with 85 additions and 32 deletions
+35 -10
View File
@@ -91,9 +91,25 @@ void RageBitmapTexture::Create()
}
// load texture and get image info
/////////////////////
// Figure out whether the texture can fit into texture memory unscaled
/////////////////////
bool bScaleImageToTextureSize;
D3DXIMAGE_INFO ddii;
if( FAILED( hr = D3DXGetImageInfoFromFile(
m_sFilePath,
&ddii ) ) )
{
RageErrorHr( ssprintf("D3DXGetImageInfoFromFile() failed for file '%s'.", m_sFilePath), hr );
}
D3DCAPS8 caps;
m_pd3dDevice->GetDeviceCaps( &caps );
bScaleImageToTextureSize = ddii.Width > caps.MaxTextureWidth
|| ddii.Height > caps.MaxTextureHeight;
if( FAILED( hr = D3DXCreateTextureFromFileEx(
m_pd3dDevice, // device
@@ -103,8 +119,8 @@ void RageBitmapTexture::Create()
0, // usage (is a render target?)
fmtTexture, // our preferred texture format
D3DPOOL_MANAGED, // which memory pool
D3DX_FILTER_BOX, // filter
D3DX_FILTER_BOX, // mip filter
bScaleImageToTextureSize ? D3DX_FILTER_BOX : D3DX_FILTER_NONE, // filter
D3DX_DEFAULT, // mip filter
0, // no color key
&ddii, // struct to fill with source image info
NULL, // no palette
@@ -113,15 +129,13 @@ void RageBitmapTexture::Create()
RageErrorHr( ssprintf("D3DXCreateTextureFromFileEx() failed for file '%s'.", m_sFilePath), hr );
}
// save the source image's width and height
/////////////////////
// Save information about the texture
/////////////////////
m_uSourceWidth = ddii.Width;
m_uSourceHeight= ddii.Height;
//RageLog( "info.Width = %d, info.Height = %d, devCaps.MaxTextureWidth = %d, devCaps.MaxTextureHeight = %d",
// info.Width, info.Height, devCaps.MaxTextureWidth, devCaps.MaxTextureHeight );
D3DSURFACE_DESC ddsd;
if ( FAILED( hr = m_pd3dTexture->GetLevelDesc( 0, &ddsd ) ) )
RageErrorHr( "Could not get level Description of D3DX texture!", hr );
@@ -130,5 +144,16 @@ void RageBitmapTexture::Create()
m_uTextureWidth = ddsd.Width;
m_uTextureHeight = ddsd.Height;
m_TextureFormat = ddsd.Format;
if( bScaleImageToTextureSize )
{
m_uImageWidth = m_uTextureWidth;
m_uImageHeight = m_uTextureHeight;
}
else
{
m_uImageWidth = m_uSourceWidth;
m_uImageHeight = m_uSourceHeight;
}
}
+9 -14
View File
@@ -20,15 +20,7 @@
//-----------------------------------------------------------------------------
// RageTexture constructor
//-----------------------------------------------------------------------------
RageTexture::RageTexture( LPRageScreen pScreen, CString sFilePath ) :
m_uSourceWidth( 0 ),
m_uSourceHeight( 0 ),
m_uTextureWidth( 0 ),
m_uTextureHeight( 0 ),
m_uFramesWide( 1 ),
m_uFramesHigh( 1 ),
m_uSourceFrameWidth( 0 ),
m_uSourceFrameHeight( 0 )
RageTexture::RageTexture( LPRageScreen pScreen, CString sFilePath )
{
// RageLog( "RageTexture::RageTexture()" );
@@ -41,7 +33,10 @@ RageTexture::RageTexture( LPRageScreen pScreen, CString sFilePath ) :
// m_pd3dTexture = NULL;
m_iRefCount = 1;
m_uSourceWidth = m_uSourceHeight = 0;
m_uTextureWidth = m_uTextureHeight = 0;
m_uImageWidth = m_uImageHeight = 0;
m_uFramesWide = m_uFramesHigh = 1;
}
RageTexture::~RageTexture()
@@ -61,10 +56,10 @@ void RageTexture::CreateFrameRects()
{
for( UINT i=0; i<m_uFramesWide; i++ ) // traverse along X (important that this is the inner loop)
{
FRECT frect( (i+0)/(float)m_uFramesWide, // these will all be between 0.0 and 1.0
(j+0)/(float)m_uFramesHigh,
(i+1)/(float)m_uFramesWide,
(j+1)/(float)m_uFramesHigh );
FRECT frect( (i+0)/(float)m_uFramesWide*m_uImageWidth /m_uTextureWidth, // these will all be between 0.0 and 1.0
(j+0)/(float)m_uFramesHigh*m_uImageHeight/m_uTextureHeight,
(i+1)/(float)m_uFramesWide*m_uImageWidth /m_uTextureWidth,
(j+1)/(float)m_uFramesHigh*m_uImageHeight/m_uTextureHeight );
m_TextureCoordRects.Add( frect ); // the index of this array element will be (i + j*m_uFramesWide)
//RageLog( "Adding frect%d %f %f %f %f", (i + j*m_uFramesWide), frect.left, frect.top, frect.right, frect.bottom );
+13 -7
View File
@@ -51,13 +51,19 @@ public:
UINT GetSourceHeight() {return m_uSourceHeight;};
UINT GetTextureWidth() {return m_uTextureWidth;};
UINT GetTextureHeight() {return m_uTextureHeight;};
UINT GetTextureFrameWidth() {return GetTextureWidth()/GetFramesWide();};
UINT GetTextureFrameHeight(){return GetTextureHeight()/GetFramesHigh();};
UINT GetImageWidth() {return m_uImageWidth;};
UINT GetImageHeight() {return m_uImageHeight;};
UINT GetFramesWide() {return m_uFramesWide;};
UINT GetFramesHigh() {return m_uFramesHigh;};
UINT GetSourceFrameWidth() {return GetSourceWidth()/GetFramesWide();};
UINT GetSourceFrameHeight() {return GetSourceHeight()/GetFramesHigh();};
UINT GetSourceFrameWidth() {return GetSourceWidth() / GetFramesWide();};
UINT GetSourceFrameHeight() {return GetSourceHeight() / GetFramesHigh();};
UINT GetTextureFrameWidth() {return GetTextureWidth() / GetFramesWide();};
UINT GetTextureFrameHeight(){return GetTextureHeight() / GetFramesHigh();};
UINT GetImageFrameWidth() {return GetImageWidth() / GetFramesWide();};
UINT GetImageFrameHeight() {return GetImageHeight() / GetFramesHigh();};
FRECT* GetTextureCoordRect( UINT uFrameNo ) {return &m_TextureCoordRects[uFrameNo];};
UINT GetNumFrames() {return m_TextureCoordRects.GetSize();};
CString GetFilePath() {return m_sFilePath;};
@@ -72,13 +78,13 @@ protected:
LPDIRECT3DDEVICE8 m_pd3dDevice;
// LPDIRECT3DTEXTURE8 m_pd3dTexture;
UINT m_uSourceWidth, m_uSourceHeight; // dimensions of the original image
UINT m_uTextureWidth, m_uTextureHeight; // dimensions of the texture holding the image
UINT m_uSourceWidth, m_uSourceHeight; // dimensions of the original image loaded from disk
UINT m_uTextureWidth, m_uTextureHeight; // dimensions of the texture in memory
UINT m_uImageWidth, m_uImageHeight; // dimensions of the image in the texture
D3DFORMAT m_TextureFormat;
// The number of frames of animation in each row and column of this texture.
UINT m_uFramesWide, m_uFramesHigh;
UINT m_uSourceFrameWidth, m_uSourceFrameHeight;
// RECTs that hold the bounds of each frame in the bitmap.
+1 -1
View File
@@ -2,7 +2,7 @@
[General Info]
Version=1
LastClass=CSMPackageInstallDlg
LastClass=CSmpackageDlg
LastTemplate=CDialog
NewFileInclude1=#include "stdafx.h"
NewFileInclude2=#include "smpackage.h"
Binary file not shown.
+26
View File
@@ -40,6 +40,7 @@ BEGIN_MESSAGE_MAP(CSmpackageDlg, CDialog)
ON_WM_QUERYDRAGICON()
ON_LBN_SELCHANGE(IDC_LIST_SONGS, OnSelchangeListSongs)
ON_BN_CLICKED(IDC_BUTTON_EXPORT, OnButtonExport)
ON_BN_CLICKED(IDC_BUTTON_PLAY, OnButtonPlay)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
@@ -234,3 +235,28 @@ void CSmpackageDlg::OnButtonExport()
void CSmpackageDlg::OnButtonPlay()
{
// TODO: Add your control notification handler code here
PROCESS_INFORMATION pi;
STARTUPINFO si;
ZeroMemory( &si, sizeof(si) );
CreateProcess(
NULL, // pointer to name of executable module
"stepmania.exe", // pointer to command line string
NULL, // process security attributes
NULL, // thread security attributes
false, // handle inheritance flag
0, // creation flags
NULL, // pointer to new environment block
NULL, // pointer to current directory name
&si, // pointer to STARTUPINFO
&pi // pointer to PROCESS_INFORMATION
);
}
+1
View File
@@ -47,6 +47,7 @@ protected:
afx_msg HCURSOR OnQueryDragIcon();
afx_msg void OnSelchangeListSongs();
afx_msg void OnButtonExport();
afx_msg void OnButtonPlay();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};