new theme graphics and new texture loading algorithm
This commit is contained in:
@@ -91,9 +91,25 @@ void RageBitmapTexture::Create()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////
|
||||||
|
// Figure out whether the texture can fit into texture memory unscaled
|
||||||
|
/////////////////////
|
||||||
|
bool bScaleImageToTextureSize;
|
||||||
|
|
||||||
// load texture and get image info
|
|
||||||
D3DXIMAGE_INFO ddii;
|
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(
|
if( FAILED( hr = D3DXCreateTextureFromFileEx(
|
||||||
m_pd3dDevice, // device
|
m_pd3dDevice, // device
|
||||||
@@ -103,8 +119,8 @@ void RageBitmapTexture::Create()
|
|||||||
0, // usage (is a render target?)
|
0, // usage (is a render target?)
|
||||||
fmtTexture, // our preferred texture format
|
fmtTexture, // our preferred texture format
|
||||||
D3DPOOL_MANAGED, // which memory pool
|
D3DPOOL_MANAGED, // which memory pool
|
||||||
D3DX_FILTER_BOX, // filter
|
bScaleImageToTextureSize ? D3DX_FILTER_BOX : D3DX_FILTER_NONE, // filter
|
||||||
D3DX_FILTER_BOX, // mip filter
|
D3DX_DEFAULT, // mip filter
|
||||||
0, // no color key
|
0, // no color key
|
||||||
&ddii, // struct to fill with source image info
|
&ddii, // struct to fill with source image info
|
||||||
NULL, // no palette
|
NULL, // no palette
|
||||||
@@ -113,15 +129,13 @@ void RageBitmapTexture::Create()
|
|||||||
RageErrorHr( ssprintf("D3DXCreateTextureFromFileEx() failed for file '%s'.", m_sFilePath), hr );
|
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_uSourceWidth = ddii.Width;
|
||||||
m_uSourceHeight= ddii.Height;
|
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;
|
D3DSURFACE_DESC ddsd;
|
||||||
if ( FAILED( hr = m_pd3dTexture->GetLevelDesc( 0, &ddsd ) ) )
|
if ( FAILED( hr = m_pd3dTexture->GetLevelDesc( 0, &ddsd ) ) )
|
||||||
RageErrorHr( "Could not get level Description of D3DX texture!", hr );
|
RageErrorHr( "Could not get level Description of D3DX texture!", hr );
|
||||||
@@ -130,5 +144,16 @@ void RageBitmapTexture::Create()
|
|||||||
m_uTextureWidth = ddsd.Width;
|
m_uTextureWidth = ddsd.Width;
|
||||||
m_uTextureHeight = ddsd.Height;
|
m_uTextureHeight = ddsd.Height;
|
||||||
m_TextureFormat = ddsd.Format;
|
m_TextureFormat = ddsd.Format;
|
||||||
|
|
||||||
|
if( bScaleImageToTextureSize )
|
||||||
|
{
|
||||||
|
m_uImageWidth = m_uTextureWidth;
|
||||||
|
m_uImageHeight = m_uTextureHeight;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_uImageWidth = m_uSourceWidth;
|
||||||
|
m_uImageHeight = m_uSourceHeight;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,15 +20,7 @@
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// RageTexture constructor
|
// RageTexture constructor
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
RageTexture::RageTexture( LPRageScreen pScreen, CString sFilePath ) :
|
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 )
|
|
||||||
{
|
{
|
||||||
// RageLog( "RageTexture::RageTexture()" );
|
// RageLog( "RageTexture::RageTexture()" );
|
||||||
|
|
||||||
@@ -41,7 +33,10 @@ RageTexture::RageTexture( LPRageScreen pScreen, CString sFilePath ) :
|
|||||||
// m_pd3dTexture = NULL;
|
// m_pd3dTexture = NULL;
|
||||||
m_iRefCount = 1;
|
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()
|
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)
|
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
|
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,
|
(j+0)/(float)m_uFramesHigh*m_uImageHeight/m_uTextureHeight,
|
||||||
(i+1)/(float)m_uFramesWide,
|
(i+1)/(float)m_uFramesWide*m_uImageWidth /m_uTextureWidth,
|
||||||
(j+1)/(float)m_uFramesHigh );
|
(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)
|
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 );
|
//RageLog( "Adding frect%d %f %f %f %f", (i + j*m_uFramesWide), frect.left, frect.top, frect.right, frect.bottom );
|
||||||
|
|||||||
@@ -51,13 +51,19 @@ public:
|
|||||||
UINT GetSourceHeight() {return m_uSourceHeight;};
|
UINT GetSourceHeight() {return m_uSourceHeight;};
|
||||||
UINT GetTextureWidth() {return m_uTextureWidth;};
|
UINT GetTextureWidth() {return m_uTextureWidth;};
|
||||||
UINT GetTextureHeight() {return m_uTextureHeight;};
|
UINT GetTextureHeight() {return m_uTextureHeight;};
|
||||||
UINT GetTextureFrameWidth() {return GetTextureWidth()/GetFramesWide();};
|
UINT GetImageWidth() {return m_uImageWidth;};
|
||||||
UINT GetTextureFrameHeight(){return GetTextureHeight()/GetFramesHigh();};
|
UINT GetImageHeight() {return m_uImageHeight;};
|
||||||
|
|
||||||
UINT GetFramesWide() {return m_uFramesWide;};
|
UINT GetFramesWide() {return m_uFramesWide;};
|
||||||
UINT GetFramesHigh() {return m_uFramesHigh;};
|
UINT GetFramesHigh() {return m_uFramesHigh;};
|
||||||
|
|
||||||
UINT GetSourceFrameWidth() {return GetSourceWidth() / GetFramesWide();};
|
UINT GetSourceFrameWidth() {return GetSourceWidth() / GetFramesWide();};
|
||||||
UINT GetSourceFrameHeight() {return GetSourceHeight() / GetFramesHigh();};
|
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];};
|
FRECT* GetTextureCoordRect( UINT uFrameNo ) {return &m_TextureCoordRects[uFrameNo];};
|
||||||
UINT GetNumFrames() {return m_TextureCoordRects.GetSize();};
|
UINT GetNumFrames() {return m_TextureCoordRects.GetSize();};
|
||||||
CString GetFilePath() {return m_sFilePath;};
|
CString GetFilePath() {return m_sFilePath;};
|
||||||
@@ -72,13 +78,13 @@ protected:
|
|||||||
LPDIRECT3DDEVICE8 m_pd3dDevice;
|
LPDIRECT3DDEVICE8 m_pd3dDevice;
|
||||||
// LPDIRECT3DTEXTURE8 m_pd3dTexture;
|
// LPDIRECT3DTEXTURE8 m_pd3dTexture;
|
||||||
|
|
||||||
UINT m_uSourceWidth, m_uSourceHeight; // dimensions of the original image
|
UINT m_uSourceWidth, m_uSourceHeight; // dimensions of the original image loaded from disk
|
||||||
UINT m_uTextureWidth, m_uTextureHeight; // dimensions of the texture holding the image
|
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;
|
D3DFORMAT m_TextureFormat;
|
||||||
|
|
||||||
// The number of frames of animation in each row and column of this texture.
|
// The number of frames of animation in each row and column of this texture.
|
||||||
UINT m_uFramesWide, m_uFramesHigh;
|
UINT m_uFramesWide, m_uFramesHigh;
|
||||||
UINT m_uSourceFrameWidth, m_uSourceFrameHeight;
|
|
||||||
|
|
||||||
|
|
||||||
// RECTs that hold the bounds of each frame in the bitmap.
|
// RECTs that hold the bounds of each frame in the bitmap.
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
[General Info]
|
[General Info]
|
||||||
Version=1
|
Version=1
|
||||||
LastClass=CSMPackageInstallDlg
|
LastClass=CSmpackageDlg
|
||||||
LastTemplate=CDialog
|
LastTemplate=CDialog
|
||||||
NewFileInclude1=#include "stdafx.h"
|
NewFileInclude1=#include "stdafx.h"
|
||||||
NewFileInclude2=#include "smpackage.h"
|
NewFileInclude2=#include "smpackage.h"
|
||||||
|
|||||||
Binary file not shown.
@@ -40,6 +40,7 @@ BEGIN_MESSAGE_MAP(CSmpackageDlg, CDialog)
|
|||||||
ON_WM_QUERYDRAGICON()
|
ON_WM_QUERYDRAGICON()
|
||||||
ON_LBN_SELCHANGE(IDC_LIST_SONGS, OnSelchangeListSongs)
|
ON_LBN_SELCHANGE(IDC_LIST_SONGS, OnSelchangeListSongs)
|
||||||
ON_BN_CLICKED(IDC_BUTTON_EXPORT, OnButtonExport)
|
ON_BN_CLICKED(IDC_BUTTON_EXPORT, OnButtonExport)
|
||||||
|
ON_BN_CLICKED(IDC_BUTTON_PLAY, OnButtonPlay)
|
||||||
//}}AFX_MSG_MAP
|
//}}AFX_MSG_MAP
|
||||||
END_MESSAGE_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
|
||||||
|
);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ protected:
|
|||||||
afx_msg HCURSOR OnQueryDragIcon();
|
afx_msg HCURSOR OnQueryDragIcon();
|
||||||
afx_msg void OnSelchangeListSongs();
|
afx_msg void OnSelchangeListSongs();
|
||||||
afx_msg void OnButtonExport();
|
afx_msg void OnButtonExport();
|
||||||
|
afx_msg void OnButtonPlay();
|
||||||
//}}AFX_MSG
|
//}}AFX_MSG
|
||||||
DECLARE_MESSAGE_MAP()
|
DECLARE_MESSAGE_MAP()
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user