Bug fixes and deferred rendering architecture

This commit is contained in:
Chris Danford
2002-08-18 16:19:26 +00:00
parent 9b45ff8afe
commit 0447dc2aad
30 changed files with 671 additions and 695 deletions
+10 -10
View File
@@ -25,7 +25,7 @@ Actor::Actor()
m_rotation = m_start_rotation = D3DXVECTOR3( 0, 0, 0 );
m_scale = m_start_scale = D3DXVECTOR2( 1, 1 );
for(int i=0; i<4; i++) m_colorDiffuse[i] = m_start_colorDiffuse[i] = D3DXCOLOR( 1, 1, 1, 1 );
m_colorAdd = m_start_colorAdd = D3DXCOLOR( 0, 0, 0, 0 );
m_colorGlow = m_start_colorGlow = D3DXCOLOR( 0, 0, 0, 0 );
m_HorizAlign = align_center;
m_VertAlign = align_middle;
@@ -61,7 +61,7 @@ void Actor::Draw() // set the world matrix and calculate actor properties, the
m_temp_colorDiffuse[4];
for(i=0; i<4; i++)
m_temp_colorDiffuse[i] = m_colorDiffuse[i];
m_temp_colorAdd = m_colorAdd;
m_temp_colorGlow = m_colorGlow;
//
@@ -82,7 +82,7 @@ void Actor::Draw() // set the world matrix and calculate actor properties, the
case glowing:
float fCurvedPercent;
fCurvedPercent = sinf( m_fPercentBetweenColors * D3DX_PI );
m_temp_colorAdd = m_effect_colorAdd1*fCurvedPercent + m_effect_colorAdd2*(1.0f-fCurvedPercent);
m_temp_colorGlow = m_effect_colorGlow1*fCurvedPercent + m_effect_colorGlow2*(1.0f-fCurvedPercent);
break;
case wagging:
m_temp_rotation.z = m_fWagRadians * sinf(
@@ -220,7 +220,7 @@ void Actor::Update( float fDeltaTime )
m_start_rotation = m_rotation;
m_start_scale = m_scale;
for( int i=0; i<4; i++) m_start_colorDiffuse[i] = m_colorDiffuse[i];
m_start_colorAdd = m_colorAdd;
m_start_colorGlow = m_colorGlow;
}
TS.m_fTimeLeftInTween -= fDeltaTime;
@@ -233,7 +233,7 @@ void Actor::Update( float fDeltaTime )
m_scale = TS.m_end_scale;
m_rotation = TS.m_end_rotation;
for(i=0; i<4; i++) m_colorDiffuse[i] = TS.m_end_colorDiffuse[i];
m_colorAdd = TS.m_end_colorAdd;
m_colorGlow = TS.m_end_colorGlow;
// delete the head tween
for( i=0; i<m_iNumTweenStates-1; i++ )
@@ -278,7 +278,7 @@ void Actor::Update( float fDeltaTime )
m_scale = m_start_scale + (TS.m_end_scale - m_start_scale )*fPercentAlongPath;
m_rotation = m_start_rotation+ (TS.m_end_rotation - m_start_rotation)*fPercentAlongPath;
for(int i=0; i<4; i++) m_colorDiffuse[i] = m_start_colorDiffuse[i]*(1.0f-fPercentAlongPath) + TS.m_end_colorDiffuse[i]*(fPercentAlongPath);
m_colorAdd = m_start_colorAdd *(1.0f-fPercentAlongPath) + TS.m_end_colorAdd *(fPercentAlongPath);
m_colorGlow = m_start_colorGlow *(1.0f-fPercentAlongPath) + TS.m_end_colorGlow *(fPercentAlongPath);
}
@@ -314,7 +314,7 @@ void Actor::BeginTweeningQueued( float time, TweenType tt )
TS.m_end_scale = m_scale;
TS.m_end_rotation = m_rotation;
for(int i=0; i<4; i++) TS.m_end_colorDiffuse[i] = m_colorDiffuse[i];
TS.m_end_colorAdd = m_colorAdd;
TS.m_end_colorGlow = m_colorGlow;
}
TS.m_TweenType = tt;
@@ -347,7 +347,7 @@ void Actor::SetTweenDiffuseColorTopEdge( D3DXCOLOR colorDiffuse ) { GetLatestTw
void Actor::SetTweenDiffuseColorRightEdge( D3DXCOLOR colorDiffuse ) { GetLatestTween().m_end_colorDiffuse[1] = GetLatestTween().m_end_colorDiffuse[3] = colorDiffuse; };
void Actor::SetTweenDiffuseColorBottomEdge( D3DXCOLOR colorDiffuse ) { GetLatestTween().m_end_colorDiffuse[2] = GetLatestTween().m_end_colorDiffuse[3] = colorDiffuse; };
void Actor::SetTweenDiffuseColorLeftEdge( D3DXCOLOR colorDiffuse ) { GetLatestTween().m_end_colorDiffuse[0] = GetLatestTween().m_end_colorDiffuse[2] = colorDiffuse; };
void Actor::SetTweenAddColor( D3DXCOLOR c ) { GetLatestTween().m_end_colorAdd = c; };
void Actor::SetTweenAddColor( D3DXCOLOR c ) { GetLatestTween().m_end_colorGlow = c; };
void Actor::ScaleTo( LPRECT pRect, StretchType st )
@@ -434,8 +434,8 @@ void Actor::SetEffectCamelion( float fDeltaPercentPerSecond, D3DXCOLOR Color, D3
void Actor::SetEffectGlowing( float fDeltaPercentPerSecond, D3DXCOLOR Color, D3DXCOLOR Color2 )
{
m_Effect = glowing;
m_effect_colorAdd1 = Color;
m_effect_colorAdd2 = Color2;
m_effect_colorGlow1 = Color;
m_effect_colorGlow2 = Color2;
m_fDeltaPercentPerSecond = fDeltaPercentPerSecond;
}
+9 -9
View File
@@ -87,8 +87,8 @@ public:
virtual void SetDiffuseColorLeftEdge( D3DXCOLOR colorDiffuse ) { m_colorDiffuse[0] = m_colorDiffuse[2] = colorDiffuse; };
virtual D3DXCOLOR GetDiffuseColor() { return m_colorDiffuse[0]; };
virtual D3DXCOLOR GetDiffuseColors( int i ) { return m_colorDiffuse[i]; };
virtual void SetAddColor( D3DXCOLOR colorAdd ) { m_colorAdd = colorAdd; };
virtual D3DXCOLOR GetAddColor() { return m_colorAdd; };
virtual void SetGlowColor( D3DXCOLOR colorGlow ) { m_colorGlow = colorGlow; };
virtual D3DXCOLOR GetGlowColor() { return m_colorGlow; };
@@ -174,7 +174,7 @@ protected:
D3DXVECTOR3 m_rotation; // X, Y, and Z m_rotation
D3DXVECTOR2 m_scale; // X and Y zooming
D3DXCOLOR m_colorDiffuse[4]; // 4 corner colors - left to right, top to bottom
D3DXCOLOR m_colorAdd;
D3DXCOLOR m_colorGlow;
//
// Stuff for tweening
@@ -183,7 +183,7 @@ protected:
D3DXVECTOR3 m_start_rotation;
D3DXVECTOR2 m_start_scale;
D3DXCOLOR m_start_colorDiffuse[4];
D3DXCOLOR m_start_colorAdd;
D3DXCOLOR m_start_colorGlow;
struct TweenState
{
@@ -192,7 +192,7 @@ protected:
D3DXVECTOR3 m_end_rotation;
D3DXVECTOR2 m_end_scale;
D3DXCOLOR m_end_colorDiffuse[4];
D3DXCOLOR m_end_colorAdd;
D3DXCOLOR m_end_colorGlow;
// counters for tweening
TweenType m_TweenType;
@@ -205,7 +205,7 @@ protected:
m_end_rotation = D3DXVECTOR3( 0, 0, 0 );
m_end_scale = D3DXVECTOR2( 1, 1 );
for(int i=0; i<4; i++) m_end_colorDiffuse[i]= D3DXCOLOR( 1, 1, 1, 1 );
m_end_colorAdd = D3DXCOLOR( 0, 0, 0, 0 );
m_end_colorGlow = D3DXCOLOR( 0, 0, 0, 0 );
};
};
@@ -222,7 +222,7 @@ protected:
D3DXVECTOR3 m_temp_rotation;
D3DXVECTOR2 m_temp_scale;
D3DXCOLOR m_temp_colorDiffuse[4];
D3DXCOLOR m_temp_colorAdd;
D3DXCOLOR m_temp_colorGlow;
//
@@ -241,8 +241,8 @@ protected:
// Counting variables for camelion and glowing:
D3DXCOLOR m_effect_colorDiffuse1;
D3DXCOLOR m_effect_colorDiffuse2;
D3DXCOLOR m_effect_colorAdd1;
D3DXCOLOR m_effect_colorAdd2;
D3DXCOLOR m_effect_colorGlow1;
D3DXCOLOR m_effect_colorGlow2;
float m_fPercentBetweenColors;
bool m_bTweeningTowardEndColor; // TRUE is fading toward end_color, FALSE if fading toward start_color
float m_fDeltaPercentPerSecond; // percentage change in tweening per second
+162 -201
View File
@@ -13,17 +13,25 @@
#include "Background.h"
#include "RageUtil.h"
#include "GameConstantsAndTypes.h"
#include "PrefsManager.h"
#include "PrefsManager.h"
#include "RageBitmapTexture.h"
#include "RageException.h"
#include "RageTimer.h"
#include "GameState.h"
#include "ThemeManager.h"
#include "PrefsManager.h"
const CString BG_ANIMS_DIR = "BGAnimations\\";
const CString VISUALIZATIONS_DIR = "Visualizations\\";
const CString RANDOMMOVIES_DIR = "RandomMovies\\";
// TODO: Move these into theme metrics
const int BACKGROUND_LEFT = 0;
const int BACKGROUND_TOP = 0;
const int BACKGROUND_RIGHT = 640;
const int BACKGROUND_BOTTOM = 480;
#define RECT_BACKGROUND CRect(BACKGROUND_LEFT,BACKGROUND_TOP,BACKGROUND_RIGHT,BACKGROUND_BOTTOM)
int CompareAnimSegs(const void *arg1, const void *arg2)
{
@@ -50,9 +58,7 @@ void SortAnimSegArray( CArray<AnimSeg,AnimSeg&> &arrayAnimSegs )
Background::Background()
{
m_fSongBeat = 0;
m_bFreeze = false;
m_iCurAnimSegment = 0;
m_bInDanger = false;
m_BackgroundMode = MODE_STATIC_BG;
@@ -60,31 +66,39 @@ Background::Background()
m_sprDanger.SetZoom( 2 );
m_sprDanger.SetEffectWagging();
m_sprDanger.Load( THEME->GetPathTo("Graphics","gameplay danger text") );
m_sprDanger.SetXY( CENTER_X, CENTER_Y );
m_sprDanger.SetX( (float)RECTCENTERX(RECT_BACKGROUND) );
m_sprDanger.SetY( (float)RECTCENTERY(RECT_BACKGROUND) );
m_sprDangerBackground.Load( THEME->GetPathTo("Graphics","gameplay danger background") );
m_sprDangerBackground.StretchTo( CRect(SCREEN_LEFT,SCREEN_TOP,SCREEN_RIGHT,SCREEN_BOTTOM) );
m_sprDangerBackground.StretchTo( RECT_BACKGROUND );
m_quadBGBrightness.StretchTo( CRect(SCREEN_LEFT, SCREEN_TOP, SCREEN_RIGHT, SCREEN_BOTTOM) );
m_quadBGBrightness.StretchTo( RECT_BACKGROUND );
m_quadBGBrightness.SetDiffuseColor( D3DXCOLOR(0,0,0,1-0.5f) );
m_pCurBGA = NULL;
m_iCurAnimSegment = -1;
m_quadBorder[0].StretchTo( CRect(SCREEN_LEFT,SCREEN_TOP,BACKGROUND_LEFT,SCREEN_BOTTOM) );
m_quadBorder[0].SetDiffuseColor( D3DXCOLOR(0,0,0,0) );
m_quadBorder[1].StretchTo( CRect(BACKGROUND_LEFT,SCREEN_TOP,BACKGROUND_RIGHT,BACKGROUND_TOP) );
m_quadBorder[1].SetDiffuseColor( D3DXCOLOR(0,0,0,0) );
m_quadBorder[2].StretchTo( CRect(BACKGROUND_RIGHT,SCREEN_TOP,SCREEN_RIGHT,SCREEN_BOTTOM) );
m_quadBorder[2].SetDiffuseColor( D3DXCOLOR(0,0,0,0) );
m_quadBorder[3].StretchTo( CRect(BACKGROUND_LEFT,SCREEN_TOP,BACKGROUND_RIGHT,BACKGROUND_TOP) );
m_quadBorder[3].SetDiffuseColor( D3DXCOLOR(0,0,0,0) );
}
Background::~Background()
{
Unload();
}
void Background::Unload()
{
for( int i=0; i<m_BackgroundAnimations.GetSize(); i++ )
delete m_BackgroundAnimations[i];
}
bool Background::LoadFromSong( Song* pSong, bool bDisableVisualizations )
void Background::LoadFromSong( Song* pSong, bool bDisableVisualizations )
{
m_fMusicSeconds = 0;
m_bStartedBGMovie = false;
m_pSong = pSong;
ASSERT( m_BackgroundAnimations.GetSize() == 0 ); // forgot to call Unload() after song end
//
// figure out what BackgroundMode to use
@@ -100,70 +114,135 @@ bool Background::LoadFromSong( Song* pSong, bool bDisableVisualizations )
else
m_BackgroundMode = MODE_ANIMATIONS;
m_sprSongBackground.Load( pSong->HasBackground() ? pSong->GetBackgroundPath() : THEME->GetPathTo("Graphics","fallback background"), true, 4, 0, true );
m_sprSongBackground.StretchTo( CRect(SCREEN_LEFT,SCREEN_TOP,SCREEN_RIGHT,SCREEN_BOTTOM) );
//
// Load the static background that will before notes start and after notes end
//
BackgroundAnimation* pTempBGA;
pTempBGA = new BackgroundAnimation;
pTempBGA->LoadFromStaticGraphic( pSong->HasBackground() ? pSong->GetBackgroundPath() : THEME->GetPathTo("Graphics","fallback background") );
m_BackgroundAnimations.Add( pTempBGA );
//
// Load animations that will play while notes are active
//
switch( m_BackgroundMode )
{
case MODE_STATIC_BG:
// do nothing
break;
case MODE_MOVIE_BG:
m_sprMovieBackground.Load( pSong->GetMovieBackgroundPath() );
m_sprMovieBackground.StretchTo( CRect(SCREEN_LEFT+10,SCREEN_TOP+16,SCREEN_RIGHT-10,SCREEN_BOTTOM-16) );
m_sprMovieBackground.SetZoomY( m_sprMovieBackground.GetZoomY() );
m_sprMovieBackground.StopAnimating( );
{
pTempBGA = new BackgroundAnimation;
pTempBGA->LoadFromMovie( pSong->GetMovieBackgroundPath() );
m_BackgroundAnimations.Add( pTempBGA );
}
break;
case MODE_MOVIE_VIS:
{
CStringArray arrayPossibleMovies;
GetDirListing( VISUALIZATIONS_DIR + CString("*.avi"), arrayPossibleMovies );
GetDirListing( VISUALIZATIONS_DIR + CString("*.mpg"), arrayPossibleMovies );
GetDirListing( VISUALIZATIONS_DIR + CString("*.mpeg"), arrayPossibleMovies );
if( arrayPossibleMovies.GetSize() > 0 )
GetDirListing( VISUALIZATIONS_DIR + "*.avi", arrayPossibleMovies, false, true );
GetDirListing( VISUALIZATIONS_DIR + "*.mpg", arrayPossibleMovies, false, true );
GetDirListing( VISUALIZATIONS_DIR + "*.mpeg", arrayPossibleMovies, false, true );
while( arrayPossibleMovies.GetSize() > 0 && m_BackgroundAnimations.GetSize() < 2 )
{
int index = rand() % arrayPossibleMovies.GetSize();
m_sprMovieVis.Load( VISUALIZATIONS_DIR + arrayPossibleMovies[index] );
m_sprMovieVis.StretchTo( CRect(SCREEN_LEFT,SCREEN_TOP,SCREEN_RIGHT,SCREEN_BOTTOM) );
m_sprMovieVis.SetZoomY( m_sprMovieVis.GetZoomY()*-1 );
m_sprMovieVis.SetBlendModeAdd();
}
pTempBGA = new BackgroundAnimation;
pTempBGA->LoadFromVisualization( arrayPossibleMovies[index], pSong->HasBackground() ? pSong->GetBackgroundPath() : THEME->GetPathTo("Graphics","fallback background") );
m_BackgroundAnimations.Add( pTempBGA );
arrayPossibleMovies.RemoveAt( index );
}
}
break;
case MODE_ANIMATIONS:
{
//
// Load background animations
//
CStringArray asBGAnimNames;
// First look in the song folder for animations
GetDirListing( pSong->m_sSongDir+"BGAnimations\\*.*", asBGAnimNames, true );
if( asBGAnimNames.GetSize() > 0 )
CStringArray arrayPossibleAnims;
GetDirListing( BG_ANIMS_DIR+"*.*", arrayPossibleAnims, true, true );
while( arrayPossibleAnims.GetSize() > 0 && m_BackgroundAnimations.GetSize() < 5 )
{
for( int i=0; i<asBGAnimNames.GetSize(); i++ )
m_BackgroundAnimations.Add( new BackgroundAnimation(pSong->m_sSongDir+"BGAnimations\\"+asBGAnimNames[i], pSong) );
int index = rand() % arrayPossibleAnims.GetSize();
pTempBGA = new BackgroundAnimation;
pTempBGA->LoadFromAniDir( arrayPossibleAnims[index], pSong->HasBackground() ? pSong->GetBackgroundPath() : THEME->GetPathTo("Graphics","fallback background") );
m_BackgroundAnimations.Add( pTempBGA );
arrayPossibleAnims.RemoveAt( index );
}
else
}
break;
case MODE_RANDOMMOVIES:
{
CStringArray arrayPossibleMovies;
GetDirListing( RANDOMMOVIES_DIR + "*.avi", arrayPossibleMovies, false, true );
GetDirListing( RANDOMMOVIES_DIR + "*.mpg", arrayPossibleMovies, false, true );
GetDirListing( RANDOMMOVIES_DIR + "*.mpeg", arrayPossibleMovies, false, true );
while( arrayPossibleMovies.GetSize() > 0 && m_BackgroundAnimations.GetSize() < 5 )
{
// We're going to try to classify songs as trance, pop, or techno based on some data about the song
if( pSong->m_BPMSegments.GetSize() + pSong->m_StopSegments.GetSize() >= 3 )
GetDirListing( BG_ANIMS_DIR+"techno*.*", asBGAnimNames, true );
else if( pSong->m_BPMSegments[0].m_fBPM > 160 )
GetDirListing( BG_ANIMS_DIR+"trance*.*", asBGAnimNames, true );
else
GetDirListing( BG_ANIMS_DIR+"pop*.*", asBGAnimNames, true );
// load different animations
for( int i=0; i<asBGAnimNames.GetSize(); i++ )
m_BackgroundAnimations.Add( new BackgroundAnimation(BG_ANIMS_DIR + asBGAnimNames[i], pSong) );
}
int index = rand() % arrayPossibleMovies.GetSize();
pTempBGA = new BackgroundAnimation;
pTempBGA->LoadFromMovie( arrayPossibleMovies[index] );
m_BackgroundAnimations.Add( pTempBGA );
arrayPossibleMovies.RemoveAt( index );
}
}
break;
default:
ASSERT(0);
}
if( m_BackgroundAnimations.GetSize() == 0 )
break;
// At this point, m_BackgroundAnimations[0] is the song background, and everything else
// in m_BackgroundAnimations should be cycled through randomly while notes are playing.
//
// Generate an animation plan
//
if( m_BackgroundMode == MODE_MOVIE_VIS )
{
m_aAnimSegs.Add( AnimSeg(-10000,1) );
return;
}
// start off showing the static song background
m_aAnimSegs.Add( AnimSeg(-10000,0) );
// change BG every 4 bars
const float fFirstBeat = m_BackgroundMode==MODE_MOVIE_BG ? 0 : pSong->m_fFirstBeat;
const float fLastBeat = pSong->m_fLastBeat;
for( float f=fFirstBeat; f<fLastBeat; f+=16 )
{
int index;
if( m_BackgroundAnimations.GetSize()==1 )
index = 0;
else
index = 1 + rand()%(m_BackgroundAnimations.GetSize()-1);
m_aAnimSegs.Add( AnimSeg(f,index) );
}
// change BG every BPM change
for( int i=0; i<pSong->m_BPMSegments.GetSize(); i++ )
{
const BPMSegment& bpmseg = pSong->m_BPMSegments[i];
if( bpmseg.m_fStartBeat < fFirstBeat || bpmseg.m_fStartBeat > fLastBeat )
continue; // skip
int index;
if( m_BackgroundAnimations.GetSize()==1 )
index = 0;
else
int index = 1 + int(bpmseg.m_fBPM)%(m_BackgroundAnimations.GetSize()-1);
m_aAnimSegs.Add( AnimSeg(bpmseg.m_fStartBeat,index) );
}
// end showing the static song background
m_aAnimSegs.Add( AnimSeg(pSong->m_fLastBeat,0) );
// sort segments
SortAnimSegArray( m_aAnimSegs );
// for( int i=0; i<m_aAnimSegs.GetSize(); i++ )
// printf("AnimSeg %d: %f, %i\n", i, m_aAnimSegs[i].m_fStartBeat, m_aAnimSegs[i].m_iAnimationIndex);
/*
// Load the song's pre-defined animation plan.
// TODO: Fix this
// Load a background animation plan into m_aAnimSegs
if( pSong->m_AnimationSegments.GetSize() > 0 )
@@ -188,55 +267,7 @@ bool Background::LoadFromSong( Song* pSong, bool bDisableVisualizations )
m_aAnimSegs.Add( AnimSeg(aniseg.m_fStartBeat, iIndex) );
}
SortAnimSegArray( m_aAnimSegs ); // this should already be sorted
}
else
{
// Generate a plan.
for( int i=0; i<pSong->m_fLastBeat; i+=16 )
m_aAnimSegs.Add( AnimSeg((float)i,rand()%m_BackgroundAnimations.GetSize()) ); // change BG every 4 bars
for( i=0; i<pSong->m_BPMSegments.GetSize(); i++ )
{
const BPMSegment& bpmseg = pSong->m_BPMSegments[i];
m_aAnimSegs.Add( AnimSeg(bpmseg.m_fStartBeat,int(bpmseg.m_fBPM)%m_BackgroundAnimations.GetSize()) ); // change BG every BPM change
}
SortAnimSegArray( m_aAnimSegs );
}
}
break;
case MODE_RANDOMMOVIES:
{
CStringArray asMovieNames;
GetDirListing( RANDOMMOVIES_DIR + "*.avi", asMovieNames );
GetDirListing( RANDOMMOVIES_DIR + "*.mpg", asMovieNames );
GetDirListing( RANDOMMOVIES_DIR + "*.mpeg", asMovieNames );
for( int i=0; i<min(asMovieNames.GetSize(),5); i++ ) // only load up to 5 background because they are slow to load
{
CString sMovieName = asMovieNames[rand()%asMovieNames.GetSize()];
m_BackgroundAnimations.Add( new BackgroundAnimation(RANDOMMOVIES_DIR+sMovieName, NULL) );
}
if( m_BackgroundAnimations.GetSize() == 0 )
break;
// Generate a plan.
for( i=0; i<pSong->m_fLastBeat; i+=16 )
m_aAnimSegs.Add( AnimSeg((float)i,rand()%m_BackgroundAnimations.GetSize()) ); // change BG every 4 bars
for( i=0; i<pSong->m_BPMSegments.GetSize(); i++ )
{
const BPMSegment& bpmseg = pSong->m_BPMSegments[i];
m_aAnimSegs.Add( AnimSeg(bpmseg.m_fStartBeat,int(bpmseg.m_fBPM)%m_BackgroundAnimations.GetSize()) ); // change BG every BPM change
}
SortAnimSegArray( m_aAnimSegs );
}
break;
default:
ASSERT(0);
}
return true;
*/
}
@@ -251,77 +282,35 @@ void Background::Update( float fDeltaTime )
}
else
{
if( m_bFreeze )
if( GAMESTATE->m_bFreeze )
return;
m_sprSongBackground.Update( fDeltaTime );
// Find the AnimSeg we're in
for( int i=0; i<m_aAnimSegs.GetSize()-1; i++ )
if( GAMESTATE->m_fSongBeat < m_aAnimSegs[i+1].m_fStartBeat )
break;
ASSERT( i >= 0 && i<m_aAnimSegs.GetSize() );
switch( m_BackgroundMode )
if( i > m_iCurAnimSegment )
{
case MODE_STATIC_BG:
// do nothing
break;
case MODE_MOVIE_BG:
m_sprMovieBackground.Update( fDeltaTime );
break;
case MODE_MOVIE_VIS:
m_sprMovieVis.Update( fDeltaTime );
break;
case MODE_ANIMATIONS:
case MODE_RANDOMMOVIES:
{
// Find the AnimSeg we're in
for( int i=0; i<m_aAnimSegs.GetSize()-1; i++ )
if( m_aAnimSegs[i+1].m_fStartBeat > m_fSongBeat )
break;
if( i == m_aAnimSegs.GetSize() )
{
m_pCurBGA = NULL;
break; // no animations
}
int iNewAnimationSegment = i;
if( iNewAnimationSegment > m_iCurAnimSegment )
{
m_iCurAnimSegment = iNewAnimationSegment;
if( m_pCurBGA )
m_pCurBGA->LosingFocus();
if( i > m_aAnimSegs.GetSize() )
{
m_pCurBGA = NULL;
}
else
{
int iNewAnimIndex = m_aAnimSegs[i].m_iAnimationIndex;
m_pCurBGA = m_BackgroundAnimations[iNewAnimIndex];
m_pCurBGA->GainingFocus();
}
}
// printf( "%d, %d, %f, %f\n", m_iCurAnimSegment, i, m_aAnimSegs[i].m_fStartBeat, GAMESTATE->m_fSongBeat );
GetCurBGA()->LosingFocus();
m_iCurAnimSegment = i;
GetCurBGA()->GainingFocus();
if( m_pCurBGA )
m_pCurBGA->Update( fDeltaTime, m_fSongBeat );
}
break;
default:
ASSERT(0);
}
m_quadBGBrightness.Update( fDeltaTime );
}
}
GetCurBGA()->Update( fDeltaTime );
void Background::SetSongBeat( const float fSongBeat, const bool bFreeze, const float fMusicSeconds )
{
m_fSongBeat = fSongBeat;
m_bFreeze = bFreeze;
m_fMusicSeconds = fMusicSeconds;
if( m_BackgroundMode == MODE_MOVIE_BG && !m_bStartedBGMovie && m_fMusicSeconds > 0 )
m_sprMovieBackground.StartAnimating();
}
m_quadBGBrightness.Update( fDeltaTime );
}
void Background::DrawPrimitives()
{
ActorFrame::DrawPrimitives();
if( DangerVisible() )
{
m_sprDangerBackground.Draw();
@@ -329,45 +318,17 @@ void Background::DrawPrimitives()
}
else
{
switch( m_BackgroundMode )
{
case MODE_STATIC_BG:
m_sprSongBackground.Draw();
break;
case MODE_MOVIE_BG:
::Sleep(2); // let the movie decode a frame
m_sprMovieBackground.Draw();
break;
case MODE_MOVIE_VIS:
m_sprSongBackground.Draw();
::Sleep(2); // let the movie decode a frame
m_sprMovieVis.Draw();
break;
case MODE_ANIMATIONS:
case MODE_RANDOMMOVIES:
if( m_pCurBGA )
{
if( m_pCurBGA->IsAMovie() )
::Sleep(2); // let the movie decode a frame
m_pCurBGA->Draw();
}
else
{
m_sprSongBackground.Draw();
}
break;
default:
ASSERT(0);
}
m_quadBGBrightness.Draw();
GetCurBGA()->Draw();
}
m_quadBGBrightness.Draw();
for( int i=0; i<4; i++ )
m_quadBorder[i].Draw();
}
bool Background::DangerVisible()
{
return m_bInDanger && (TIMER->GetTimeSinceStart() - (int)TIMER->GetTimeSinceStart()) < 0.5f;
return m_bInDanger && PREFSMAN->m_bShowDanger && (TIMER->GetTimeSinceStart() - (int)TIMER->GetTimeSinceStart()) < 0.5f;
}
+6 -20
View File
@@ -35,13 +35,12 @@ public:
Background();
~Background();
virtual bool LoadFromSong( Song *pSong, bool bDisableVisualizations = false );
virtual void LoadFromSong( Song *pSong, bool bDisableVisualizations = false );
virtual void Unload(); // call this on before calling load
virtual void Update( float fDeltaTime );
virtual void DrawPrimitives();
void SetSongBeat( const float fSongBeat, const bool bFreeze, const float fMusicSeconds );
void FadeIn();
void FadeOut();
@@ -53,36 +52,23 @@ public:
protected:
bool DangerVisible();
Song* m_pSong;
enum BackgroundMode { MODE_STATIC_BG, MODE_MOVIE_BG, MODE_ANIMATIONS, MODE_MOVIE_VIS, MODE_RANDOMMOVIES };
BackgroundMode m_BackgroundMode;
Sprite m_sprSongBackground;
Sprite m_sprDanger;
Sprite m_sprDangerBackground;
// for movie BG
Sprite m_sprMovieBackground;
// for animations
// used in all BackgroundModes except OFF
CArray<BackgroundAnimation*,BackgroundAnimation*> m_BackgroundAnimations;
CArray<AnimSeg,AnimSeg&> m_aAnimSegs;
BackgroundAnimation* m_pCurBGA;
int m_iCurAnimSegment; // this increases as we move into new segments
BackgroundAnimation* GetCurBGA() { int index = m_aAnimSegs[m_iCurAnimSegment].m_iAnimationIndex; return m_BackgroundAnimations[index]; };
// for movie vis
Sprite m_sprMovieVis;
Quad m_quadBGBrightness;
Quad m_quadBorder[4]; // l, t, r, b - cover up the edge of animations that might hang outside of the background rectangle
bool m_bInDanger;
float m_fSongBeat;
bool m_bFreeze;
float m_fMusicSeconds;
bool m_bStartedBGMovie;
};
+68 -139
View File
@@ -148,9 +148,7 @@ void BitmapText::DrawPrimitives()
// make the object in logical units centered at the origin
LPDIRECT3DVERTEXBUFFER8 pVB = DISPLAY->GetVertexBuffer();
RAGEVERTEX* v;
pVB->Lock( 0, 0, (BYTE**)&v, 0 );
static RAGEVERTEX v[4000];
int iNumV = 0; // the current vertex number
@@ -201,22 +199,17 @@ void BitmapText::DrawPrimitives()
//
const float fExtraPixels = fPercentExtra * pTexture->GetSourceFrameWidth();
// first triangle
v[iNumV++].p = D3DXVECTOR3( (float)iX, iY-iHeight/2.0f, 0 ); // top left
v[iNumV++].p = D3DXVECTOR3( (float)iX, iY+iHeight/2.0f, 0 ); // bottom left
iX += iCharWidth;
v[iNumV++].p = D3DXVECTOR3( iX+fExtraPixels, iY-iHeight/2.0f, 0 ); // top right
// 2nd triangle
v[iNumV++].p = v[iNumV-1].p; // top right
v[iNumV++].p = v[iNumV-3].p; // bottom left
v[iNumV++].p = D3DXVECTOR3( iX+fExtraPixels, iY+iHeight/2.0f, 0 ); // bottom right
v[iNumV++].p = D3DXVECTOR3( (float)iX, iY-iHeight/2.0f, 0 ); // top left
v[iNumV++].p = D3DXVECTOR3( iX+iCharWidth+fExtraPixels, iY-iHeight/2.0f, 0 ); // top right
v[iNumV++].p = D3DXVECTOR3( (float)iX, iY+iHeight/2.0f, 0 ); // bottom left
v[iNumV++].p = D3DXVECTOR3( iX+iCharWidth+fExtraPixels, iY+iHeight/2.0f, 0 ); // bottom right
iX += iCharWidth;
//
// set texture coordinates
//
iNumV -= 6;
iNumV -= 4;
FRECT frectTexCoords = *pTexture->GetTextureCoordRect( iFrameNo );
@@ -230,153 +223,89 @@ void BitmapText::DrawPrimitives()
const float fExtraTexCoords = fPercentExtra * pTexture->GetTextureFrameWidth() / pTexture->GetTextureWidth();
v[iNumV++].t = D3DXVECTOR2( frectTexCoords.left, frectTexCoords.top ); // top left
v[iNumV++].t = D3DXVECTOR2( frectTexCoords.left, frectTexCoords.bottom ); // bottom left
v[iNumV++].t = D3DXVECTOR2( frectTexCoords.right + fExtraTexCoords, frectTexCoords.top ); // top right
v[iNumV++].t = v[iNumV-1].t; // top right
v[iNumV++].t = v[iNumV-3].t; // bottom left
v[iNumV++].t = D3DXVECTOR2( frectTexCoords.left, frectTexCoords.bottom ); // bottom left
v[iNumV++].t = D3DXVECTOR2( frectTexCoords.right + fExtraTexCoords, frectTexCoords.bottom ); // bottom right
}
iY += iHeight;
}
pVB->Unlock();
DISPLAY->SetTexture( pTexture );
DISPLAY->SetColorTextureMultDiffuse();
DISPLAY->SetAlphaTextureMultDiffuse();
// Set the stage...
LPDIRECT3DDEVICE8 pd3dDevice = DISPLAY->GetDevice();
pd3dDevice->SetTexture( 0, pTexture->GetD3DTexture() );
pd3dDevice->SetRenderState( D3DRS_SRCBLEND, m_bBlendAdd ? D3DBLEND_ONE : D3DBLEND_SRCALPHA );
pd3dDevice->SetRenderState( D3DRS_DESTBLEND, m_bBlendAdd ? D3DBLEND_ONE : D3DBLEND_INVSRCALPHA );
pd3dDevice->SetVertexShader( D3DFVF_RAGEVERTEX );
pd3dDevice->SetStreamSource( 0, pVB, sizeof(RAGEVERTEX) );
//////////////////////
// render the shadow
//////////////////////
if( m_bShadow && m_temp_colorDiffuse[0].a != 0 )
{
DISPLAY->PushMatrix();
DISPLAY->TranslateLocal( m_fShadowLength, m_fShadowLength, 0 ); // shift by 5 units
DWORD dwColor = D3DXCOLOR(0,0,0,0.5f*m_temp_colorDiffuse[0].a); // semi-transparent black
/*
// YUCK. It is very common in crapier drivers that the texture factor doesn't work.
// Too bad because using the texture factor instead of recoloring the verticies is very fast.
pd3dDevice->SetRenderState( D3DRS_TEXTUREFACTOR, dwColor );
pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TFACTOR );
pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1 );
pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE );
pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG2, D3DTA_TFACTOR );
pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_MODULATE );
*/
// recolor the verticies for a shadow
pVB->Lock( 0, 0, (BYTE**)&v, 0 );
for( int i=0; i<iNumV; i++ )
v[i].color = dwColor;
pVB->Unlock();
pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE );
pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_SELECTARG2 );
pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE );
pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE );
pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_MODULATE );
pd3dDevice->DrawPrimitive( D3DPT_TRIANGLELIST, 0, iNumV/3 );
DISPLAY->PopMatrix();
}
//////////////////////
// render the diffuse pass
//////////////////////
//
// set vertex colors for the diffuse pass
//
pVB->Lock( 0, 0, (BYTE**)&v, 0 );
if( m_bRainbow )
{
int color_index = int(TIMER->GetTimeSinceStart() / 0.200) % NUM_RAINBOW_COLORS;
for( int i=0; i<iNumV; i+=6 )
{
const D3DXCOLOR color = RAINBOW_COLORS[color_index];
for( int j=i; j<i+6; j++ )
v[j].color = color;
color_index = (color_index+1)%NUM_RAINBOW_COLORS;
}
}
if( m_bBlendAdd )
DISPLAY->SetBlendModeAdd();
else
DISPLAY->SetBlendModeNormal();
if( m_temp_colorDiffuse[0].a != 0 )
{
for( int i=0; i<iNumV; i+=6 )
//////////////////////
// render the shadow
//////////////////////
if( m_bShadow )
{
v[i ].color = m_temp_colorDiffuse[0]; // top left
v[i+1].color = m_temp_colorDiffuse[2]; // bottom left
v[i+2].color = m_temp_colorDiffuse[1]; // top right
v[i+3].color = m_temp_colorDiffuse[1]; // top right
v[i+4].color = m_temp_colorDiffuse[2]; // bottom left
v[i+5].color = m_temp_colorDiffuse[3]; // bottom right
DISPLAY->PushMatrix();
DISPLAY->TranslateLocal( m_fShadowLength, m_fShadowLength, 0 ); // shift by 5 units
DWORD dwColor = D3DXCOLOR(0,0,0,0.5f*m_temp_colorDiffuse[0].a); // semi-transparent black
for( int i=0; i<iNumV; i++ )
v[i].color = dwColor;
for( int i=0; i<iNumV; i+=4 )
DISPLAY->AddQuad( &v[i] );
DISPLAY->PopMatrix();
}
//////////////////////
// render the diffuse pass
//////////////////////
if( m_bRainbow )
{
int color_index = int(TIMER->GetTimeSinceStart() / 0.200) % NUM_RAINBOW_COLORS;
for( int i=0; i<iNumV; i+=6 )
{
const D3DXCOLOR color = RAINBOW_COLORS[color_index];
for( int j=i; j<i+6; j++ )
v[j].color = color;
color_index = (color_index+1)%NUM_RAINBOW_COLORS;
}
}
else
{
for( int i=0; i<iNumV; i+=4 )
{
v[i+0].color = m_temp_colorDiffuse[0]; // top left
v[i+1].color = m_temp_colorDiffuse[1]; // top right
v[i+2].color = m_temp_colorDiffuse[2]; // bottom left
v[i+3].color = m_temp_colorDiffuse[3]; // bottom right
}
}
for( int i=0; i<iNumV; i+=4 )
DISPLAY->AddQuad( &v[i] );
}
pVB->Unlock();
pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE );
pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_MODULATE );
pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE );
pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE );
pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_MODULATE );
pd3dDevice->DrawPrimitive( D3DPT_TRIANGLELIST, 0, iNumV/3 );
//////////////////////
// render the add pass
// render the glow pass
//////////////////////
if( m_temp_colorAdd.a != 0 )
if( m_temp_colorGlow.a != 0 )
{
DWORD dwColor = m_temp_colorAdd;
DISPLAY->SetColorDiffuse();
/*
// See above comment about some cards not correctly handling the
// texture factor render state.
pd3dDevice->SetRenderState( D3DRS_TEXTUREFACTOR, dwColor );
pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TFACTOR );
pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1 );
pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE );
pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG2, D3DTA_TFACTOR );
pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_MODULATE );
*/
// recolor the verticies for
pVB->Lock( 0, 0, (BYTE**)&v, 0 );
for( int i=0; i<iNumV; i++ )
v[i].color = dwColor;
pVB->Unlock();
v[i].color = m_temp_colorGlow;
pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE );
pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_SELECTARG2 );
pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE );
pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE );
pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_MODULATE );
pd3dDevice->DrawPrimitive( D3DPT_TRIANGLELIST, 0, iNumV/3 );
for( int i=0; i<iNumV; i+=4 )
DISPLAY->AddQuad( &v[i] );
}
}
+2 -7
View File
@@ -135,10 +135,7 @@ void CourseContentsFrame::Update( float fDeltaTime )
void CourseContentsFrame::DrawPrimitives()
{
// turn on Z buffer to clip items
LPDIRECT3DDEVICE8 pd3dDevice = DISPLAY->GetDevice();
pd3dDevice->SetRenderState( D3DRS_ZENABLE, TRUE );
pd3dDevice->SetRenderState( D3DRS_ZWRITEENABLE, TRUE );
DISPLAY->EnableZBuffer();
// write to z buffer so that top and bottom are clipped
m_quad.SetZ( -1 );
@@ -166,8 +163,6 @@ void CourseContentsFrame::DrawPrimitives()
fY += CONTENTS_BAR_HEIGHT;
}
// turn off Z buffer
pd3dDevice->SetRenderState( D3DRS_ZENABLE, FALSE );
pd3dDevice->SetRenderState( D3DRS_ZWRITEENABLE, FALSE );
DISPLAY->DisableZBuffer();
}
+9 -22
View File
@@ -146,14 +146,11 @@ void GrooveRadar::GrooveRadarValueMap::DrawPrimitives()
// draw radar filling
const float fRadius = m_sprRadarBase.GetZoomedHeight()/2.0f*1.1f;
LPDIRECT3DVERTEXBUFFER8 pVB = DISPLAY->GetVertexBuffer();
LPDIRECT3DDEVICE8 pd3dDevice = DISPLAY->GetDevice();
pd3dDevice->SetTexture( 0, NULL );
pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE );
pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_SELECTARG2 );
pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE );
pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG2 );
RAGEVERTEX* v;
DISPLAY->SetTexture( NULL );
DISPLAY->SetColorTextureMultDiffuse();
DISPLAY->SetAlphaTextureMultDiffuse();
RAGEVERTEX v[12]; // needed to draw 5 fan primitives and 10 strip primitives
for( int p=0; p<NUM_PLAYERS; p++ )
{
@@ -163,8 +160,6 @@ void GrooveRadar::GrooveRadarValueMap::DrawPrimitives()
//
// use a fan to draw the volume
//
pVB->Lock( 0, 0, (BYTE**)&v, 0 );
D3DXCOLOR color = PlayerToColor( (PlayerNumber)p );
color.a = 0.5f;
v[0].p = D3DXVECTOR3( 0, 0, 0 );
@@ -182,19 +177,15 @@ void GrooveRadar::GrooveRadarValueMap::DrawPrimitives()
const float fY = -sinf(fRotation) * fDistFromCenter;
v[1+i].p = D3DXVECTOR3( fX, fY, 0 );
v[1+i].color = color;
v[1+i].color = v[0].color;
}
pVB->Unlock();
pd3dDevice->DrawPrimitive( D3DPT_TRIANGLEFAN, 0, 5 );
DISPLAY->AddFan( v, 5 );
//
// use a strip to draw the thick line
//
pVB->Lock( 0, 0, (BYTE**)&v, 0 );
for( i=0; i<NUM_RADAR_CATEGORIES+1; i++ ) // do one extra to close the fan
{
const int c = i%NUM_RADAR_CATEGORIES;
@@ -211,15 +202,11 @@ void GrooveRadar::GrooveRadarValueMap::DrawPrimitives()
v[i*2+0].p = D3DXVECTOR3( fXInner, fYInner, 0 );
v[i*2+1].p = D3DXVECTOR3( fXOutter, fYOutter, 0 );
v[i*2+0].color = PlayerToColor( (PlayerNumber)p );
v[i*2+1].color = PlayerToColor( (PlayerNumber)p );
v[i*2+1].color = v[i*2+0].color;
}
pVB->Unlock();
pd3dDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, 0, 10 );
DISPLAY->AddStrip( v, 10 );
}
}
void GrooveRadar::GrooveRadarValueMap::TweenOnScreen()
+1 -1
View File
@@ -132,7 +132,7 @@ void LifeMeterBattery::OnDancePointsChange()
iPossibleDancePoints = max( 1, iPossibleDancePoints );
float fPercentDancePoints = iActualDancePoints / (float)iPossibleDancePoints + 0.00001f; // correct for rounding errors
printf( "Actual %d, Possible %d, Percent %f\n", iActualDancePoints, iPossibleDancePoints, fPercentDancePoints );
// printf( "Actual %d, Possible %d, Percent %f\n", iActualDancePoints, iPossibleDancePoints, fPercentDancePoints );
float fNumToDisplay = MAX( 0, fPercentDancePoints*100 );
CString sNumToDisplay = ssprintf("%03.1f", fNumToDisplay);
+2 -2
View File
@@ -58,8 +58,8 @@ public:
virtual void SetDiffuseColor( D3DXCOLOR c ) { for(int i=0; i<NUM_BLUR_GHOSTS; i++) m_sprites[i].SetDiffuseColor(c); };
virtual D3DXCOLOR GetDiffuseColor() { return m_sprites[0].GetDiffuseColor(); };
virtual void SetAddColor( D3DXCOLOR c ) { for(int i=0; i<NUM_BLUR_GHOSTS; i++) m_sprites[i].SetAddColor(c); };
virtual D3DXCOLOR GetAddColor() { return m_sprites[0].GetAddColor(); };
virtual void SetGlowColor( D3DXCOLOR c ) { for(int i=0; i<NUM_BLUR_GHOSTS; i++) m_sprites[i].SetGlowColor(c); };
virtual D3DXCOLOR GetGlowColor() { return m_sprites[0].GetGlowColor(); };
// THE BLUR IS MADE BY DELAYING THE TWEENS
+2 -2
View File
@@ -270,10 +270,10 @@ void WheelItemDisplay::DrawPrimitives()
if( m_fPercentGray > 0 )
{
m_sprSongBar.SetDiffuseColor( D3DXCOLOR(1,1,1,0) );
m_sprSongBar.SetAddColor( D3DXCOLOR(0,0,0,m_fPercentGray) );
m_sprSongBar.SetGlowColor( D3DXCOLOR(0,0,0,m_fPercentGray) );
m_sprSongBar.Draw();
m_sprSongBar.SetDiffuseColor( D3DXCOLOR(1,1,1,1) );
m_sprSongBar.SetAddColor( D3DXCOLOR(0,0,0,0) );
m_sprSongBar.SetGlowColor( D3DXCOLOR(0,0,0,0) );
}
}
break;
+29 -29
View File
@@ -331,17 +331,17 @@ void NoteDisplay::DrawList( int iCount, NoteDisplayInstance cni[], bool bDrawAdd
{
NoteDisplayInstance* pCNI = &cni[i];
const D3DXCOLOR colorAdd = D3DXCOLOR(1,1,1,pCNI->fAddAlpha);
const D3DXCOLOR colorGlow = D3DXCOLOR(1,1,1,pCNI->fAddAlpha);
//
// set vertex colors
//
v[iNumV++].color = colorAdd; // top left
v[iNumV++].color = colorAdd; // bottom left
v[iNumV++].color = colorAdd; // top right
v[iNumV++].color = colorAdd; // top right
v[iNumV++].color = colorAdd; // bottom left
v[iNumV++].color = colorAdd; // bottom right
v[iNumV++].color = colorGlow; // top left
v[iNumV++].color = colorGlow; // bottom left
v[iNumV++].color = colorGlow; // top right
v[iNumV++].color = colorGlow; // top right
v[iNumV++].color = colorGlow; // bottom left
v[iNumV++].color = colorGlow; // bottom right
}
ASSERT( iNumV == iCount*6 ); // two triangles for each note
@@ -472,17 +472,17 @@ void NoteDisplay::DrawList( int iCount, NoteDisplayInstance cni[], bool bDrawAdd
{
NoteDisplayInstance* pCNI = &cni[i];
const D3DXCOLOR colorAdd = D3DXCOLOR(1,1,1,pCNI->fAddAlpha);
const D3DXCOLOR colorGlow = D3DXCOLOR(1,1,1,pCNI->fAddAlpha);
//
// set vertex colors
//
v[iNumV++].color = colorAdd; // top left
v[iNumV++].color = colorAdd; // bottom left
v[iNumV++].color = colorAdd; // top right
v[iNumV++].color = colorAdd; // top right
v[iNumV++].color = colorAdd; // bottom left
v[iNumV++].color = colorAdd; // bottom right
v[iNumV++].color = colorGlow; // top left
v[iNumV++].color = colorGlow; // bottom left
v[iNumV++].color = colorGlow; // top right
v[iNumV++].color = colorGlow; // top right
v[iNumV++].color = colorGlow; // bottom left
v[iNumV++].color = colorGlow; // bottom right
}
ASSERT( iNumV == iCount*6 ); // two triangles for each note
@@ -551,16 +551,16 @@ void NoteDisplay::DrawHold( const HoldNote& hn, const bool bActive, const float
const float fColorScale = SCALE(fLife,0,1,0.5f,1);
const D3DXCOLOR colorDiffuseTop = D3DXCOLOR(fColorScale,fColorScale,fColorScale,fAlphaTop);
const D3DXCOLOR colorDiffuseBottom = D3DXCOLOR(fColorScale,fColorScale,fColorScale,fAlphaBottom);
const D3DXCOLOR colorAddTop = D3DXCOLOR(1,1,1,fAddAlphaTop);
const D3DXCOLOR colorAddBottom = D3DXCOLOR(1,1,1,fAddAlphaBottom);
const D3DXCOLOR colorGlowTop = D3DXCOLOR(1,1,1,fAddAlphaTop);
const D3DXCOLOR colorGlowBottom = D3DXCOLOR(1,1,1,fAddAlphaBottom);
// the shift by -0.5 is to align texels to pixels
DISPLAY->AddQuad(
D3DXVECTOR3(fXTopLeft-0.5f, fYTop-0.5f, 0), colorDiffuseTop, D3DXVECTOR2(fTexCoordLeft, fTexCoordTop), colorAddTop, // top-left
D3DXVECTOR3(fXTopRight-0.5f, fYTop-0.5f, 0), colorDiffuseTop, D3DXVECTOR2(fTexCoordRight, fTexCoordTop), colorAddTop, // top-right
D3DXVECTOR3(fXBottomLeft-0.5f, fYBottom-0.5f,0), colorDiffuseBottom, D3DXVECTOR2(fTexCoordLeft, fTexCoordBottom), colorAddBottom, // bottom-left
D3DXVECTOR3(fXBottomRight-0.5f,fYBottom-0.5f,0), colorDiffuseBottom, D3DXVECTOR2(fTexCoordRight, fTexCoordBottom), colorAddBottom ); // bottom-right
D3DXVECTOR3(fXTopLeft-0.5f, fYTop-0.5f, 0), colorDiffuseTop, D3DXVECTOR2(fTexCoordLeft, fTexCoordTop), // colorGlowTop, // top-left
D3DXVECTOR3(fXTopRight-0.5f, fYTop-0.5f, 0), colorDiffuseTop, D3DXVECTOR2(fTexCoordRight, fTexCoordTop), // colorGlowTop, // top-right
D3DXVECTOR3(fXBottomLeft-0.5f, fYBottom-0.5f,0), colorDiffuseBottom, D3DXVECTOR2(fTexCoordLeft, fTexCoordBottom),// colorGlowBottom, // bottom-left
D3DXVECTOR3(fXBottomRight-0.5f,fYBottom-0.5f,0), colorDiffuseBottom, D3DXVECTOR2(fTexCoordRight, fTexCoordBottom) );//, colorGlowBottom ); // bottom-right
}
//
@@ -589,14 +589,14 @@ void NoteDisplay::DrawHold( const HoldNote& hn, const bool bActive, const float
const float fColorScale = SCALE(fLife,0,1,0.5f,1);
const D3DXCOLOR colorDiffuseTop = D3DXCOLOR(fColorScale,fColorScale,fColorScale,fAlphaTop);
const D3DXCOLOR colorDiffuseBottom = D3DXCOLOR(fColorScale,fColorScale,fColorScale,fAlphaBottom);
const D3DXCOLOR colorAddTop = D3DXCOLOR(1,1,1,fAddAlphaTop);
const D3DXCOLOR colorAddBottom = D3DXCOLOR(1,1,1,fAddAlphaBottom);
const D3DXCOLOR colorGlowTop = D3DXCOLOR(1,1,1,fAddAlphaTop);
const D3DXCOLOR colorGlowBottom = D3DXCOLOR(1,1,1,fAddAlphaBottom);
DISPLAY->AddQuad(
D3DXVECTOR3(fXTopLeft-0.5f, fYTop-0.5f, 0), colorDiffuseTop, D3DXVECTOR2(fTexCoordLeft, fTexCoordTop), colorAddTop, // top-left
D3DXVECTOR3(fXTopRight-0.5f, fYTop-0.5f, 0), colorDiffuseTop, D3DXVECTOR2(fTexCoordRight, fTexCoordTop), colorAddTop, // top-right
D3DXVECTOR3(fXBottomLeft-0.5f, fYBottom-0.5f,0), colorDiffuseBottom, D3DXVECTOR2(fTexCoordLeft, fTexCoordBottom), colorAddBottom, // bottom-left
D3DXVECTOR3(fXBottomRight-0.5f,fYBottom-0.5f,0), colorDiffuseBottom, D3DXVECTOR2(fTexCoordRight, fTexCoordBottom), colorAddBottom ); // bottom-right
D3DXVECTOR3(fXTopLeft-0.5f, fYTop-0.5f, 0), colorDiffuseTop, D3DXVECTOR2(fTexCoordLeft, fTexCoordTop), //colorGlowTop, // top-left
D3DXVECTOR3(fXTopRight-0.5f, fYTop-0.5f, 0), colorDiffuseTop, D3DXVECTOR2(fTexCoordRight, fTexCoordTop), //colorGlowTop, // top-right
D3DXVECTOR3(fXBottomLeft-0.5f, fYBottom-0.5f,0), colorDiffuseBottom, D3DXVECTOR2(fTexCoordLeft, fTexCoordBottom), //colorGlowBottom, // bottom-left
D3DXVECTOR3(fXBottomRight-0.5f,fYBottom-0.5f,0), colorDiffuseBottom, D3DXVECTOR2(fTexCoordRight, fTexCoordBottom) );//, colorGlowBottom ); // bottom-right
}
DISPLAY->FlushQueue();
@@ -612,12 +612,12 @@ void NoteDisplay::DrawHold( const HoldNote& hn, const bool bActive, const float
const float fAddAlpha = GetAddAlpha( fAlpha, fPercentFadeToFail );
const float fColorScale = SCALE(fLife,0,1,0.5f,1);
const D3DXCOLOR colorDiffuse= D3DXCOLOR(fColorScale,fColorScale,fColorScale,fAlpha);
const D3DXCOLOR colorAdd = D3DXCOLOR(1,1,1,fAddAlpha);
const D3DXCOLOR colorGlow = D3DXCOLOR(1,1,1,fAddAlpha);
m_sprHoldParts.SetState( bActive?1:0 );
m_sprHoldParts.SetXY( fX, fY );
m_sprHoldParts.SetDiffuseColor( colorDiffuse );
m_sprHoldParts.SetAddColor( colorAdd );
m_sprHoldParts.SetGlowColor( colorGlow );
m_sprHoldParts.Draw();
}
}
@@ -646,7 +646,7 @@ void NoteDisplay::DrawTap( const int iCol, const float fBeat, const bool bUseHol
m_sprTapParts.SetXY( fXPos, fYPos );
m_sprTapParts.SetRotation( fRotation );
m_sprTapParts.SetAddColor( D3DXCOLOR(1,1,1,fAddAlpha) );
m_sprTapParts.SetGlowColor( D3DXCOLOR(1,1,1,fAddAlpha) );
//
// draw gray part
+3 -3
View File
@@ -130,7 +130,7 @@ void NoteField::DrawMeasureBar( int iMeasureIndex )
m_rectMeasureBar.Draw();
m_textMeasureNumber.SetDiffuseColor( D3DXCOLOR(1,1,1,1) );
m_textMeasureNumber.SetAddColor( D3DXCOLOR(1,1,1,0) );
m_textMeasureNumber.SetGlowColor( D3DXCOLOR(1,1,1,0) );
m_textMeasureNumber.SetText( ssprintf("%d", iMeasureNoDisplay) );
m_textMeasureNumber.SetXY( -m_rectMeasureBar.GetZoomedWidth()/2 + 10, fYPos );
m_textMeasureNumber.Draw();
@@ -154,7 +154,7 @@ void NoteField::DrawBPMText( const float fBeat, const float fBPM )
const float fYPos = ArrowGetYPos( m_PlayerNumber, fYOffset );
m_textMeasureNumber.SetDiffuseColor( D3DXCOLOR(1,0,0,1) );
m_textMeasureNumber.SetAddColor( D3DXCOLOR(1,1,1,cosf(TIMER->GetTimeSinceStart()*2)/2+0.5f) );
m_textMeasureNumber.SetGlowColor( D3DXCOLOR(1,1,1,cosf(TIMER->GetTimeSinceStart()*2)/2+0.5f) );
m_textMeasureNumber.SetText( ssprintf("%.2f", fBPM) );
m_textMeasureNumber.SetXY( -m_rectMeasureBar.GetZoomedWidth()/2 - 60, fYPos );
m_textMeasureNumber.Draw();
@@ -166,7 +166,7 @@ void NoteField::DrawFreezeText( const float fBeat, const float fSecs )
const float fYPos = ArrowGetYPos( m_PlayerNumber, fYOffset );
m_textMeasureNumber.SetDiffuseColor( D3DXCOLOR(0.8f,0.8f,0,1) );
m_textMeasureNumber.SetAddColor( D3DXCOLOR(1,1,1,cosf(TIMER->GetTimeSinceStart()*2)/2+0.5f) );
m_textMeasureNumber.SetGlowColor( D3DXCOLOR(1,1,1,cosf(TIMER->GetTimeSinceStart()*2)/2+0.5f) );
m_textMeasureNumber.SetText( ssprintf("%.2f", fSecs) );
m_textMeasureNumber.SetXY( -m_rectMeasureBar.GetZoomedWidth()/2 - 10, fYPos );
m_textMeasureNumber.Draw();
+6 -7
View File
@@ -232,9 +232,8 @@ void Player::DrawPrimitives()
if( GAMESTATE->m_PlayerOptions[m_PlayerNumber].m_EffectType == PlayerOptions::EFFECT_SPACE )
{
// save old view and projection
DISPLAY->GetDevice()->GetTransform( D3DTS_VIEW, &matOldView );
DISPLAY->GetDevice()->GetTransform( D3DTS_PROJECTION, &matOldProj );
DISPLAY->GetViewTransform( &matOldView );
DISPLAY->GetProjectionTransform( &matOldProj );
// construct view and project matrix
D3DXMATRIX matNewView;
@@ -253,11 +252,11 @@ void Player::DrawPrimitives()
&D3DXVECTOR3( 0.0f, -1.0f, 0.0f )
);
DISPLAY->GetDevice()->SetTransform( D3DTS_VIEW, &matNewView );
DISPLAY->SetViewTransform( &matNewView );
D3DXMATRIX matNewProj;
D3DXMatrixPerspectiveFovLH( &matNewProj, D3DX_PI/4.0f, SCREEN_WIDTH/(float)SCREEN_HEIGHT, 0.0f, 1000.0f );
DISPLAY->GetDevice()->SetTransform( D3DTS_PROJECTION, &matNewProj );
DISPLAY->SetProjectionTransform( &matNewProj );
}
m_GrayArrowRow.Draw();
@@ -267,8 +266,8 @@ void Player::DrawPrimitives()
if( GAMESTATE->m_PlayerOptions[m_PlayerNumber].m_EffectType == PlayerOptions::EFFECT_SPACE )
{
// restire old view and projection
DISPLAY->GetDevice()->SetTransform( D3DTS_VIEW, &matOldView );
DISPLAY->GetDevice()->SetTransform( D3DTS_PROJECTION, &matOldProj );
DISPLAY->SetViewTransform( &matOldView );
DISPLAY->SetProjectionTransform( &matOldProj );
}
m_frameJudgement.Draw();
+11 -4
View File
@@ -34,6 +34,7 @@ PrefsManager::PrefsManager()
m_bOnlyDedicatedMenuButtons = false;
m_bShowFPS = false;
m_BackgroundMode = BGMODE_ANIMATIONS;
m_bShowDanger = true;
m_fBGBrightness = 0.8f;
m_bMenuTimer = true;
m_bEventMode = false;
@@ -41,6 +42,7 @@ PrefsManager::PrefsManager()
m_bAutoPlay = false;
m_fJudgeWindow = 0.18f;
m_fLifeDifficultyScale = 1.0f;
m_iMovieDecodeMS = 2;
ReadGlobalPrefsFromDisk( true );
}
@@ -66,6 +68,7 @@ void PrefsManager::ReadGlobalPrefsFromDisk( bool bSwitchToLastPlayedGame )
ini.GetValueB( "Options", "UseDedicatedMenuButtons",m_bOnlyDedicatedMenuButtons );
ini.GetValueB( "Options", "ShowFPS", m_bShowFPS );
ini.GetValueI( "Options", "BackgroundMode", (int&)m_BackgroundMode );
ini.GetValueB( "Options", "ShowDanger", m_bShowDanger );
ini.GetValueF( "Options", "BGBrightness", m_fBGBrightness );
ini.GetValueB( "Options", "MenuTimer", m_bMenuTimer );
ini.GetValueB( "Options", "EventMode", m_bEventMode );
@@ -73,10 +76,12 @@ void PrefsManager::ReadGlobalPrefsFromDisk( bool bSwitchToLastPlayedGame )
ini.GetValueB( "Options", "AutoPlay", m_bAutoPlay );
ini.GetValueF( "Options", "JudgeWindow", m_fJudgeWindow );
ini.GetValueF( "Options", "LifeDifficultyScale", m_fLifeDifficultyScale );
ini.GetValueI( "Options", "MovieDecodeMS", m_iMovieDecodeMS );
m_asAdditionalSongFolders.RemoveAll();
CString sAdditionalSongFolders;
ini.GetValue( "Options", "SongFolders", sAdditionalSongFolders );
split( sAdditionalSongFolders, ",", m_asSongFolders, true );
ini.GetValue( "Options", "AdditionalSongFolders", sAdditionalSongFolders );
split( sAdditionalSongFolders, ",", m_asAdditionalSongFolders, true );
if( bSwitchToLastPlayedGame )
{
@@ -100,15 +105,17 @@ void PrefsManager::SaveGlobalPrefsToDisk()
ini.GetValueB( "Options", "UseDedicatedMenuButtons",m_bOnlyDedicatedMenuButtons );
ini.SetValueB( "Options", "ShowFPS", m_bShowFPS );
ini.SetValueI( "Options", "BackgroundMode", m_BackgroundMode);
ini.SetValueB( "Options", "ShowDanger", m_bShowDanger );
ini.SetValueF( "Options", "BGBrightness", m_fBGBrightness );
ini.SetValueB( "Options", "EventMode", m_bEventMode );
ini.SetValueB( "Options", "MenuTimer", m_bMenuTimer );
ini.SetValueI( "Options", "NumArcadeStages", m_iNumArcadeStages );
ini.SetValueB( "Options", "AutoPlay", m_bAutoPlay );
ini.SetValueF( "Options", "JudgeWindow", m_fJudgeWindow );
ini.GetValueF( "Options", "LifeDifficultyScale", m_fLifeDifficultyScale );
ini.SetValueF( "Options", "LifeDifficultyScale", m_fLifeDifficultyScale );
ini.SetValueI( "Options", "MovieDecodeMS", m_iMovieDecodeMS );
ini.SetValue( "Options", "SongFolders", join(",", m_asSongFolders) );
ini.SetValue( "Options", "AdditionalSongFolders", join(",", m_asAdditionalSongFolders) );
ini.SetValueI( "Options", "Game", GAMESTATE->m_CurGame );
+3 -1
View File
@@ -35,6 +35,7 @@ public:
bool m_bOnlyDedicatedMenuButtons;
bool m_bShowFPS;
BackgroundMode m_BackgroundMode;
bool m_bShowDanger;
float m_fBGBrightness;
bool m_bMenuTimer;
bool m_bEventMode;
@@ -42,8 +43,9 @@ public:
bool m_bAutoPlay;
float m_fJudgeWindow;
float m_fLifeDifficultyScale;
int m_iMovieDecodeMS;
CStringArray m_asSongFolders;
CStringArray m_asAdditionalSongFolders;
int GetDisplayHeight();
-2
View File
@@ -44,8 +44,6 @@ public:
);
virtual LPDIRECT3DTEXTURE8 GetD3DTexture();
virtual bool IsAMovie() { return true; };
protected:
virtual void Create(
+226 -50
View File
@@ -360,6 +360,10 @@ HRESULT RageDisplay::BeginFrame()
//m_pd3dDevice->SetTextureStageState( 0, D3DTSS_ADDRESSV, D3DTADDRESS_BORDER );
m_pd3dDevice->SetVertexShader( D3DFVF_RAGEVERTEX );
m_pd3dDevice->SetStreamSource( 0, m_pVB, sizeof(RAGEVERTEX) );
return S_OK;
}
@@ -367,6 +371,9 @@ HRESULT RageDisplay::BeginFrame()
HRESULT RageDisplay::EndFrame()
{
FlushQueue();
m_pd3dDevice->EndScene();
@@ -396,8 +403,6 @@ HRESULT RageDisplay::ShowFrame()
}
HRESULT RageDisplay::Invalidate()
{
return S_OK;
@@ -406,17 +411,15 @@ HRESULT RageDisplay::Invalidate()
HRESULT RageDisplay::Restore()
{
return S_OK;
}
void RageDisplay::CreateVertexBuffer()
{
HRESULT hr;
if( FAILED( hr = GetDevice()->CreateVertexBuffer(
if( FAILED( hr = m_pd3dDevice->CreateVertexBuffer(
MAX_NUM_VERTICIES * sizeof(RAGEVERTEX),
D3DUSAGE_WRITEONLY, D3DFVF_RAGEVERTEX,
D3DPOOL_MANAGED, &m_pVB ) ) )
@@ -429,26 +432,67 @@ void RageDisplay::ReleaseVertexBuffer()
SAFE_RELEASE( m_pVB );
}
/*
void RageDisplay::AddTriangle( const RAGEVERTEX& v[3] )
{
COPY( &m_vertQueue[m_iNumVerts], v ); // do a big mem copy
for( int i=0; i<3; i++ )
D3DXVec3TransformCoord( &m_vertQueue[m_iNumVerts+i].p, v[i].p, &GetTopMatrix() );
m_iNumVerts+=3;
}
*/
void RageDisplay::AddQuad( const RAGEVERTEX v[4] ) // upper-left, upper-right, lower-left, lower-right
{
AddQuad(
v[0].p, v[0].color, v[0].t,
v[1].p, v[1].color, v[1].t,
v[2].p, v[2].color, v[2].t,
v[3].p, v[3].color, v[3].t );
}
void RageDisplay::AddFan( const RAGEVERTEX v[], int iNumPrimitives )
{
// HACK: This function does not take winding order into account. It will goof if you turn on culling.
for( int i=0; i<iNumPrimitives; i++ )
{
AddTriangle(
v[0+0].p, v[0+0].color, v[0+0].t,
v[i+1].p, v[i+1].color, v[i+1].t,
v[i+2].p, v[i+2].color, v[i+2].t
);
}
}
void RageDisplay::AddStrip( const RAGEVERTEX v[], int iNumPrimitives )
{
// HACK: This function does not take winding order into account. It will goof if you turn on culling.
for( int i=0; i<iNumPrimitives; i++ )
{
AddTriangle(
v[i+0].p, v[i+0].color, v[i+0].t,
v[i+1].p, v[i+1].color, v[i+1].t,
v[i+2].p, v[i+2].color, v[i+2].t
);
}
}
void RageDisplay::AddTriangle(
const D3DXVECTOR3& p0, const D3DCOLOR& c0, const D3DXVECTOR2& t0, const D3DCOLOR& a0,
const D3DXVECTOR3& p1, const D3DCOLOR& c1, const D3DXVECTOR2& t1, const D3DCOLOR& a1,
const D3DXVECTOR3& p2, const D3DCOLOR& c2, const D3DXVECTOR2& t2, const D3DCOLOR& a2 )
const D3DXVECTOR3& p0, const D3DCOLOR& c0, const D3DXVECTOR2& t0,
const D3DXVECTOR3& p1, const D3DCOLOR& c1, const D3DXVECTOR2& t1,
const D3DXVECTOR3& p2, const D3DCOLOR& c2, const D3DXVECTOR2& t2 )
{
ASSERT( m_iNumVerts < MAX_NUM_VERTICIES-3 );
m_vertQueue[m_iNumVerts].p = p0;
// transform the verticies as we copy
D3DXVec3TransformCoord( &m_vertQueue[m_iNumVerts].p, &p0, &GetTopMatrix() );
m_vertQueue[m_iNumVerts].color = c0;
m_vertQueue[m_iNumVerts].t = t0;
m_addColors[m_iNumVerts] = a0;
m_iNumVerts++;
m_vertQueue[m_iNumVerts].p = p1;
D3DXVec3TransformCoord( &m_vertQueue[m_iNumVerts].p, &p1, &GetTopMatrix() );
m_vertQueue[m_iNumVerts].color = c1;
m_vertQueue[m_iNumVerts].t = t1;
m_addColors[m_iNumVerts] = a1;
m_iNumVerts++;
m_vertQueue[m_iNumVerts].p = p2;
D3DXVec3TransformCoord( &m_vertQueue[m_iNumVerts].p, &p2, &GetTopMatrix() );
m_vertQueue[m_iNumVerts].color = c2;
m_vertQueue[m_iNumVerts].t = t2;
m_addColors[m_iNumVerts] = a2;
m_iNumVerts++;
if( m_iNumVerts > MAX_NUM_VERTICIES-4 )
@@ -456,21 +500,20 @@ void RageDisplay::AddTriangle(
}
void RageDisplay::AddQuad(
const D3DXVECTOR3 &p0, const D3DCOLOR& c0, const D3DXVECTOR2& t0, const D3DCOLOR& a0, // upper-left
const D3DXVECTOR3 &p1, const D3DCOLOR& c1, const D3DXVECTOR2& t1, const D3DCOLOR& a1, // upper-right
const D3DXVECTOR3 &p2, const D3DCOLOR& c2, const D3DXVECTOR2& t2, const D3DCOLOR& a2, // lower-left
const D3DXVECTOR3 &p3, const D3DCOLOR& c3, const D3DXVECTOR2& t3, const D3DCOLOR& a3 ) // lower-right
const D3DXVECTOR3 &p0, const D3DCOLOR& c0, const D3DXVECTOR2& t0, // upper-left
const D3DXVECTOR3 &p1, const D3DCOLOR& c1, const D3DXVECTOR2& t1, // upper-right
const D3DXVECTOR3 &p2, const D3DCOLOR& c2, const D3DXVECTOR2& t2, // lower-left
const D3DXVECTOR3 &p3, const D3DCOLOR& c3, const D3DXVECTOR2& t3 ) // lower-right
{
// trangles must be in clockwise order
// trangles must be in clockwise order in case we ever turn on clipping
AddTriangle(
p0, c0, t0, a0, // upper-left
p2, c2, t2, a1, // lower-left
p3, c3, t3, a2 ); // lower-right
p0, c0, t0, // upper-left
p2, c2, t2, // lower-left
p3, c3, t3 ); // lower-right
AddTriangle(
p0, c0, t0, a0, // upper-left
p3, c3, t3, a1, // lower-right
p1, c1, t1, a2 ); // upper-right
p0, c0, t0, // upper-left
p3, c3, t3, // lower-right
p1, c1, t1 ); // upper-right
}
void RageDisplay::FlushQueue()
@@ -478,77 +521,210 @@ void RageDisplay::FlushQueue()
if( m_iNumVerts == 0 )
return;
ASSERT( (m_iNumVerts % 3) == 0 );
RAGEVERTEX* v;
//
// draw diffuse pass
//
RAGEVERTEX* v;
m_pVB->Lock( 0, 0, (BYTE**)&v, 0 );
memcpy( v, m_vertQueue, sizeof(RAGEVERTEX)*m_iNumVerts );
m_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLELIST, 0, m_iNumVerts/3 );
m_pVB->Unlock();
//
// draw add pass
//
bool bAnyVertsHaveAdd = false;
for( int i=0; i<m_iNumVerts; i++ )
if( m_addColors[i]>>24 != 0 ) // if there is any alpha
bAnyVertsHaveAdd = true;
if( bAnyVertsHaveAdd )
{
SetColorTextureMultDiffuse();
SetColorDiffuse();
m_pVB->Lock( 0, 0, (BYTE**)&v, 0 );
for( int i=0; i<m_iNumVerts; i++ )
m_vertQueue[i].color = m_addColors[i];
m_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLELIST, 0, m_iNumVerts/3 );
m_pVB->Unlock();
}
m_iNumVerts = 0;
}
void RageDisplay::SetViewTransform( D3DXMATRIX* pMatrix )
{
FlushQueue();
m_pd3dDevice->SetTransform( D3DTS_VIEW, pMatrix );
}
void RageDisplay::SetProjectionTransform( D3DXMATRIX* pMatrix )
{
FlushQueue();
m_pd3dDevice->SetTransform( D3DTS_PROJECTION, pMatrix );
}
void RageDisplay::GetViewTransform( D3DXMATRIX* pMatrixOut )
{
m_pd3dDevice->GetTransform( D3DTS_VIEW, pMatrixOut );
}
void RageDisplay::GetProjectionTransform( D3DXMATRIX* pMatrixOut )
{
m_pd3dDevice->GetTransform( D3DTS_PROJECTION, pMatrixOut );
}
void RageDisplay::ResetMatrixStack()
{
m_MatrixStack.SetSize( 1, 20 );
D3DXMatrixIdentity( &GetTopMatrix() );
}
void RageDisplay::PushMatrix()
{
m_MatrixStack.Add( GetTopMatrix() );
ASSERT(m_MatrixStack.GetSize()<20); // check for infinite loop
}
void RageDisplay::PopMatrix()
{
m_MatrixStack.RemoveAt( m_MatrixStack.GetSize()-1 );
}
void RageDisplay::Translate( const float x, const float y, const float z )
{
D3DXMATRIX matTemp;
D3DXMatrixTranslation( &matTemp, x, y, z );
D3DXMATRIX& matTop = GetTopMatrix();
matTop = matTemp * matTop;
}
void RageDisplay::TranslateLocal( const float x, const float y, const float z )
{
D3DXMATRIX matTemp;
D3DXMatrixTranslation( &matTemp, x, y, z );
D3DXMATRIX& matTop = GetTopMatrix();
matTop = matTop * matTemp;
}
void RageDisplay::Scale( const float x, const float y, const float z )
{
D3DXMATRIX matTemp;
D3DXMatrixScaling( &matTemp, x, y, z );
D3DXMATRIX& matTop = GetTopMatrix();
matTop = matTemp * matTop;
}
void RageDisplay::RotateX( const float r )
{
D3DXMATRIX matTemp;
D3DXMatrixRotationX( &matTemp, r );
D3DXMATRIX& matTop = GetTopMatrix();
matTop = matTemp * matTop;
}
void RageDisplay::RotateY( const float r )
{
D3DXMATRIX matTemp;
D3DXMatrixRotationY( &matTemp, r );
D3DXMATRIX& matTop = GetTopMatrix();
matTop = matTemp * matTop;
}
void RageDisplay::RotateZ( const float r )
{
D3DXMATRIX matTemp;
D3DXMatrixRotationZ( &matTemp, r );
D3DXMATRIX& matTop = GetTopMatrix();
matTop = matTemp * matTop;
}
/*
void RageDisplay::RotateYawPitchRoll( const float x, const float y, const float z )
{
D3DXMATRIX matTemp;
D3DXMatrixRotationYawPitchRoll( &matTemp, x, y, z );
D3DXMATRIX& matTop = GetTopMatrix();
matTop = matTemp * matTop;
}
*/
void RageDisplay::SetTexture( RageTexture* pTexture )
{
m_pd3dDevice->SetTexture( 0, pTexture->GetD3DTexture() );
LPDIRECT3DBASETEXTURE8 pNewD3DTexture = pTexture ? pTexture->GetD3DTexture() : NULL;
LPDIRECT3DBASETEXTURE8 pOldD3DTexture;
m_pd3dDevice->GetTexture( 0, &pOldD3DTexture );
if( pOldD3DTexture != pNewD3DTexture )
FlushQueue();
m_pd3dDevice->SetTexture( 0, pNewD3DTexture );
}
void RageDisplay::SetColorTextureMultDiffuse()
{
DWORD dw0, dw1, dw2;
m_pd3dDevice->GetTextureStageState( 0, D3DTSS_COLORARG1, &dw0 );
m_pd3dDevice->GetTextureStageState( 0, D3DTSS_COLORARG2, &dw1 );
m_pd3dDevice->GetTextureStageState( 0, D3DTSS_COLOROP, &dw2 );
if( dw0!=D3DTA_TEXTURE || dw1!=D3DTA_DIFFUSE || dw2!=D3DTOP_MODULATE )
FlushQueue();
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE );
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_MODULATE );
}
void RageDisplay::SetColorDiffuse()
{
DWORD dw0, dw1, dw2;
m_pd3dDevice->GetTextureStageState( 0, D3DTSS_COLORARG1, &dw0 );
m_pd3dDevice->GetTextureStageState( 0, D3DTSS_COLORARG2, &dw1 );
m_pd3dDevice->GetTextureStageState( 0, D3DTSS_COLOROP, &dw2 );
if( dw0!=D3DTA_TEXTURE || dw1!=D3DTA_DIFFUSE || dw2!=D3DTOP_SELECTARG2 )
FlushQueue();
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE );
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_SELECTARG2 );
}
void RageDisplay::SetAlphaTextureMultDiffuse()
{
DWORD dw0, dw1, dw2;
m_pd3dDevice->GetTextureStageState( 0, D3DTSS_ALPHAARG1, &dw0 );
m_pd3dDevice->GetTextureStageState( 0, D3DTSS_ALPHAARG2, &dw1 );
m_pd3dDevice->GetTextureStageState( 0, D3DTSS_ALPHAOP, &dw2 );
if( dw0!=D3DTA_TEXTURE || dw1!=D3DTA_DIFFUSE || dw2!=D3DTOP_MODULATE )
FlushQueue();
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE );
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE );
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_MODULATE );
}
void RageDisplay::SetBlendModeNormal()
{
DWORD dw0, dw1;
m_pd3dDevice->GetRenderState( D3DRS_SRCBLEND, &dw0 );
m_pd3dDevice->GetRenderState( D3DRS_DESTBLEND, &dw1 );
if( dw0!=D3DBLEND_SRCALPHA || dw1!=D3DBLEND_INVSRCALPHA )
FlushQueue();
m_pd3dDevice->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_SRCALPHA );
m_pd3dDevice->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA );
}
void RageDisplay::SetBlendModeAdd()
{
DWORD dw0, dw1;
m_pd3dDevice->GetRenderState( D3DRS_SRCBLEND, &dw0 );
m_pd3dDevice->GetRenderState( D3DRS_DESTBLEND, &dw1 );
if( dw0!=D3DBLEND_ONE || dw1!=D3DBLEND_ONE )
FlushQueue();
m_pd3dDevice->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_ONE );
m_pd3dDevice->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_ONE );
}
void RageDisplay::EnableZBuffer()
{
DWORD dw0, dw1;
m_pd3dDevice->GetRenderState( D3DRS_ZENABLE, &dw0 );
m_pd3dDevice->GetRenderState( D3DRS_ZWRITEENABLE, &dw1 );
if( dw0!=TRUE || dw1!=TRUE )
FlushQueue();
m_pd3dDevice->SetRenderState( D3DRS_ZENABLE, TRUE );
m_pd3dDevice->SetRenderState( D3DRS_ZWRITEENABLE, TRUE );
}
void RageDisplay::DisableZBuffer()
{
DWORD dw0, dw1;
m_pd3dDevice->GetRenderState( D3DRS_ZENABLE, &dw0 );
m_pd3dDevice->GetRenderState( D3DRS_ZWRITEENABLE, &dw1 );
if( dw0!=FALSE || dw1!=FALSE )
FlushQueue();
m_pd3dDevice->SetRenderState( D3DRS_ZENABLE, FALSE );
m_pd3dDevice->SetRenderState( D3DRS_ZWRITEENABLE, FALSE );
}
+31 -84
View File
@@ -37,14 +37,16 @@ const int MAX_NUM_VERTICIES = MAX_NUM_QUADS*4; // 4 verticies per quad
class RageDisplay
{
friend class RageTexture;
public:
RageDisplay( HWND hWnd );
~RageDisplay();
bool SwitchDisplayMode(
const bool bWindowed, const int iWidth, const int iHeight, const int iBPP, const int iFullScreenHz );
LPDIRECT3D8 GetD3D() { return m_pd3d; };
inline LPDIRECT3DDEVICE8 GetDevice() { return m_pd3dDevice; };
// LPDIRECT3D8 GetD3D() { return m_pd3d; };
// inline LPDIRECT3DDEVICE8 GetDevice() { return m_pd3dDevice; };
const D3DCAPS8& GetDeviceCaps() { return m_DeviceCaps; };
HRESULT Reset();
@@ -78,82 +80,22 @@ public:
}
LPDIRECT3DVERTEXBUFFER8 GetVertexBuffer() { return m_pVB; };
// LPDIRECT3DVERTEXBUFFER8 GetVertexBuffer() { return m_pVB; };
void SetViewTransform( D3DXMATRIX* pMatrix );
void SetProjectionTransform( D3DXMATRIX* pMatrix );
void GetViewTransform( D3DXMATRIX* pMatrixOut );
void GetProjectionTransform( D3DXMATRIX* pMatrixOut );
inline void ResetMatrixStack()
{
m_MatrixStack.SetSize( 1, 20 );
D3DXMatrixIdentity( &GetTopMatrix() );
m_pd3dDevice->SetTransform( D3DTS_WORLD, &m_MatrixStack[m_MatrixStack.GetSize()-1] );
};
inline void PushMatrix()
{
m_MatrixStack.Add( GetTopMatrix() );
ASSERT(m_MatrixStack.GetSize()<30); // check for infinite loop
m_pd3dDevice->SetTransform( D3DTS_WORLD, &m_MatrixStack[m_MatrixStack.GetSize()-1] );
};
inline void PopMatrix()
{
m_MatrixStack.RemoveAt( m_MatrixStack.GetSize()-1 );
m_pd3dDevice->SetTransform( D3DTS_WORLD, &m_MatrixStack[m_MatrixStack.GetSize()-1] );
};
inline void Translate( const float x, const float y, const float z )
{
D3DXMATRIX matTemp;
D3DXMatrixTranslation( &matTemp, x, y, z );
D3DXMATRIX& matTop = GetTopMatrix();
matTop = matTemp * matTop;
m_pd3dDevice->SetTransform( D3DTS_WORLD, &matTop );
};
inline void TranslateLocal( const float x, const float y, const float z )
{
D3DXMATRIX matTemp;
D3DXMatrixTranslation( &matTemp, x, y, z );
D3DXMATRIX& matTop = GetTopMatrix();
matTop = matTop * matTemp;
m_pd3dDevice->SetTransform( D3DTS_WORLD, &matTop );
};
inline void Scale( const float x, const float y, const float z )
{
D3DXMATRIX matTemp;
D3DXMatrixScaling( &matTemp, x, y, z );
D3DXMATRIX& matTop = GetTopMatrix();
matTop = matTemp * matTop;
m_pd3dDevice->SetTransform( D3DTS_WORLD, &matTop );
};
inline void RotateX( const float r )
{
D3DXMATRIX matTemp;
D3DXMatrixRotationX( &matTemp, r );
D3DXMATRIX& matTop = GetTopMatrix();
matTop = matTemp * matTop;
m_pd3dDevice->SetTransform( D3DTS_WORLD, &matTop );
};
inline void RotateY( const float r )
{
D3DXMATRIX matTemp;
D3DXMatrixRotationY( &matTemp, r );
D3DXMATRIX& matTop = GetTopMatrix();
matTop = matTemp * matTop;
m_pd3dDevice->SetTransform( D3DTS_WORLD, &matTop );
};
inline void RotateZ( const float r )
{
D3DXMATRIX matTemp;
D3DXMatrixRotationZ( &matTemp, r );
D3DXMATRIX& matTop = GetTopMatrix();
matTop = matTemp * matTop;
m_pd3dDevice->SetTransform( D3DTS_WORLD, &matTop );
};
inline void RotateYawPitchRoll( const float x, const float y, const float z )
{
D3DXMATRIX matTemp;
D3DXMatrixRotationYawPitchRoll( &matTemp, x, y, z );
D3DXMATRIX& matTop = GetTopMatrix();
matTop = matTemp * matTop;
m_pd3dDevice->SetTransform( D3DTS_WORLD, &matTop );
};
void ResetMatrixStack();
void PushMatrix();
void PopMatrix();
void Translate( const float x, const float y, const float z );
void TranslateLocal( const float x, const float y, const float z );
void Scale( const float x, const float y, const float z );
void RotateX( const float r );
void RotateY( const float r );
void RotateZ( const float r );
// void RotateYawPitchRoll( const float x, const float y, const float z );
float GetFPS() { return m_fFPS; };
@@ -194,15 +136,20 @@ protected:
int m_iNumVerts;
public:
// TODO: Elminiate vertex duplication using an index buffer. Would this work with OpenGL though?
// void AddTriangle( const RAGEVERTEX v[3] );
void AddQuad( const RAGEVERTEX v[4] ); // upper-left, upper-right, lower-left, lower-right
void AddFan( const RAGEVERTEX v[], int iNumPrimitives );
void AddStrip( const RAGEVERTEX v[], int iNumPrimitives );
void AddTriangle(
const D3DXVECTOR3& p0, const D3DCOLOR& c0, const D3DXVECTOR2& t0, const D3DCOLOR& a0,
const D3DXVECTOR3& p1, const D3DCOLOR& c1, const D3DXVECTOR2& t1, const D3DCOLOR& a1,
const D3DXVECTOR3& p2, const D3DCOLOR& c2, const D3DXVECTOR2& t2, const D3DCOLOR& a2 );
const D3DXVECTOR3& p0, const D3DCOLOR& c0, const D3DXVECTOR2& t0,
const D3DXVECTOR3& p1, const D3DCOLOR& c1, const D3DXVECTOR2& t1,
const D3DXVECTOR3& p2, const D3DCOLOR& c2, const D3DXVECTOR2& t2 );
void AddQuad(
const D3DXVECTOR3 &p0, const D3DCOLOR& c0, const D3DXVECTOR2& t0, const D3DCOLOR& a0, // upper-left
const D3DXVECTOR3 &p1, const D3DCOLOR& c1, const D3DXVECTOR2& t1, const D3DCOLOR& a1, // upper-right
const D3DXVECTOR3 &p2, const D3DCOLOR& c2, const D3DXVECTOR2& t2, const D3DCOLOR& a2, // lower-left
const D3DXVECTOR3 &p3, const D3DCOLOR& c3, const D3DXVECTOR2& t3, const D3DCOLOR& a3 );// lower-right
const D3DXVECTOR3 &p0, const D3DCOLOR& c0, const D3DXVECTOR2& t0, // upper-left
const D3DXVECTOR3 &p1, const D3DCOLOR& c1, const D3DXVECTOR2& t1, // upper-right
const D3DXVECTOR3 &p2, const D3DCOLOR& c2, const D3DXVECTOR2& t2, // lower-left
const D3DXVECTOR3 &p3, const D3DCOLOR& c3, const D3DXVECTOR2& t3 ); // lower-right
void FlushQueue();
void SetTexture( RageTexture* pTexture );
void SetColorTextureMultDiffuse();
+1 -1
View File
@@ -34,7 +34,7 @@ RageTexture::RageTexture(
// LOG->Trace( "RageTexture::RageTexture()" );
// save a pointer to the D3D device
m_pd3dDevice = pScreen->GetDevice();
m_pd3dDevice = pScreen->m_pd3dDevice;
assert( m_pd3dDevice != NULL );
// save the file path
+1 -1
View File
@@ -63,7 +63,7 @@ public:
virtual void Play() {};
virtual void SetPosition( float fSeconds ) {};
virtual void Pause() {};
virtual bool IsAMovie() = 0;
virtual bool IsAMovie() { return false; };
int GetSourceWidth() {return m_iSourceWidth;};
int GetSourceHeight() {return m_iSourceHeight;};
+1 -1
View File
@@ -36,7 +36,7 @@ ScreenGameOver::ScreenGameOver()
this->AddSubActor( &m_sprGameOver );
// tween game over
m_sprGameOver.SetAddColor( D3DXCOLOR(1,1,1,0) );
m_sprGameOver.SetGlowColor( D3DXCOLOR(1,1,1,0) );
m_sprGameOver.SetDiffuseColor( D3DXCOLOR(1,1,1,0) );
m_sprGameOver.BeginTweeningQueued( 0.5f ); // fade to white
-2
View File
@@ -768,8 +768,6 @@ void ScreenGameplay::Update( float fDeltaTime )
// LOG->Trace( "GAMESTATE->m_fMusicSeconds = %f", GAMESTATE->m_fMusicSeconds );
m_Background.SetSongBeat( fSongBeat, bFreeze, fPositionSeconds );
//LOG->Trace( "m_fOffsetInBeats = %f, m_fBeatsPerSecond = %f, m_Music.GetPositionSeconds = %f", m_fOffsetInBeats, m_fBeatsPerSecond, m_Music.GetPositionSeconds() );
+6
View File
@@ -34,6 +34,7 @@ enum {
GO_SHOWFPS,
GO_BGMODE,
GO_BGBRIGHTNESS,
GO_MOVIEDECODEMS,
NUM_GRAPHIC_OPTIONS_LINES
};
OptionLineData g_GraphicOptionsLines[NUM_GRAPHIC_OPTIONS_LINES] = {
@@ -44,6 +45,7 @@ OptionLineData g_GraphicOptionsLines[NUM_GRAPHIC_OPTIONS_LINES] = {
{ "Show FPS", 2, {"OFF","ON"} },
{ "BG Mode", 4, {"OFF","ANIMATIONS","VISUALIZATIONS","RANDOM MOVIES"} },
{ "BG Brightness", 5, {"20%","40%","60%","80%","100%"} },
{ "Movie Decode MS", 5, {"1ms","2ms","3ms","4ms","5ms"} },
};
ScreenGraphicOptions::ScreenGraphicOptions() :
@@ -111,6 +113,8 @@ void ScreenGraphicOptions::ImportOptions()
else if( PREFSMAN->m_fBGBrightness == 0.8f ) m_iSelectedOption[0][GO_BGBRIGHTNESS] = 3;
else if( PREFSMAN->m_fBGBrightness == 1.0f ) m_iSelectedOption[0][GO_BGBRIGHTNESS] = 4;
else m_iSelectedOption[0][GO_BGBRIGHTNESS] = 2;
m_iSelectedOption[0][GO_MOVIEDECODEMS] = PREFSMAN->m_iMovieDecodeMS-1;
}
void ScreenGraphicOptions::ExportOptions()
@@ -164,6 +168,8 @@ void ScreenGraphicOptions::ExportOptions()
case 4: PREFSMAN->m_fBGBrightness = 1.0f; break;
default: ASSERT(0);
}
PREFSMAN->m_iMovieDecodeMS = m_iSelectedOption[0][GO_MOVIEDECODEMS]+1;
}
void ScreenGraphicOptions::GoToPrevState()
+1 -1
View File
@@ -171,7 +171,7 @@ void ScreenSelectStyle::AfterChange()
m_sprPreview.Load( THEME->GetPathTo("Graphics",ssprintf("select style preview game %d style %d",GAMESTATE->m_CurGame,m_iSelection)) );
m_sprPreview.StopTweening();
m_sprPreview.SetAddColor( D3DXCOLOR(1,1,1,0) );
m_sprPreview.SetGlowColor( D3DXCOLOR(1,1,1,0) );
m_sprPreview.SetDiffuseColor( D3DXCOLOR(1,1,1,0) );
m_sprPreview.BeginTweeningQueued( 0.25f ); // sleep
+1 -1
View File
@@ -111,7 +111,7 @@ ScreenTitleMenu::ScreenTitleMenu()
m_sprLogo.Load( THEME->GetPathTo("Graphics",ssprintf("title menu logo game %d",GAMESTATE->m_CurGame)) );
m_sprLogo.SetXY( LOGO_X, LOGO_Y );
m_sprLogo.SetAddColor( D3DXCOLOR(1,1,1,1) );
m_sprLogo.SetGlowColor( D3DXCOLOR(1,1,1,1) );
m_sprLogo.SetZoomY( 0 );
m_sprLogo.BeginTweeningQueued( 0.5f ); // sleep
m_sprLogo.BeginTweeningQueued( 0.5f, Actor::TWEEN_BOUNCE_END );
+2 -2
View File
@@ -58,8 +58,8 @@ void SongManager::InitSongArrayFromDisk( void(*callback)() )
{
LoadStepManiaSongDir( "Songs", callback );
for( int i=0; i<PREFSMAN->m_asSongFolders.GetSize(); i++ )
LoadStepManiaSongDir( PREFSMAN->m_asSongFolders[i], callback );
for( int i=0; i<PREFSMAN->m_asAdditionalSongFolders.GetSize(); i++ )
LoadStepManiaSongDir( PREFSMAN->m_asAdditionalSongFolders[i], callback );
// compute group names
CArray<Song*, Song*> arraySongs;
+24 -71
View File
@@ -1,9 +1,9 @@
#include "stdafx.h"
/*
-----------------------------------------------------------------------------
File: Sprite.cpp
Class: Sprite
Desc: A bitmap actor that animates and moves around.
Desc: See header.
Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved.
Chris Danford
@@ -190,22 +190,21 @@ void Sprite::Update( float fDeltaTime )
void Sprite::DrawPrimitives()
{
if( m_pTexture == NULL )
return;
if( m_pTexture->IsAMovie() )
::Sleep( PREFSMAN->m_iMovieDecodeMS ); // let the movie decode a frame
// offset so that pixels are aligned to texels
if( PREFSMAN->m_iDisplayResolution == 320 )
DISPLAY->TranslateLocal( -1, -1, 0 );
else
DISPLAY->TranslateLocal( -0.5f, -0.5f, 0 );
if( m_pTexture == NULL )
return;
// use m_temp_* variables to draw the object
// make the object in logical units centered at the origin
FRECT quadVerticies;
switch( m_HorizAlign )
@@ -225,9 +224,7 @@ void Sprite::DrawPrimitives()
}
LPDIRECT3DVERTEXBUFFER8 pVB = DISPLAY->GetVertexBuffer();
RAGEVERTEX* v;
pVB->Lock( 0, 0, (BYTE**)&v, 0 );
static RAGEVERTEX v[4];
v[0].p = D3DXVECTOR3( quadVerticies.left, quadVerticies.bottom, 0 ); // bottom left
v[1].p = D3DXVECTOR3( quadVerticies.left, quadVerticies.top, 0 ); // top left
@@ -254,18 +251,16 @@ void Sprite::DrawPrimitives()
}
pVB->Unlock();
DISPLAY->SetTexture( m_pTexture );
DISPLAY->SetColorTextureMultDiffuse();
DISPLAY->SetAlphaTextureMultDiffuse();
// Set the stage...
LPDIRECT3DDEVICE8 pd3dDevice = DISPLAY->GetDevice();
pd3dDevice->SetTexture( 0, m_pTexture->GetD3DTexture() );
if( m_bBlendAdd )
DISPLAY->SetBlendModeAdd();
else
DISPLAY->SetBlendModeNormal();
pd3dDevice->SetRenderState( D3DRS_SRCBLEND, m_bBlendAdd ? D3DBLEND_ONE : D3DBLEND_SRCALPHA );
pd3dDevice->SetRenderState( D3DRS_DESTBLEND, m_bBlendAdd ? D3DBLEND_ONE : D3DBLEND_INVSRCALPHA );
pd3dDevice->SetVertexShader( D3DFVF_RAGEVERTEX );
pd3dDevice->SetStreamSource( 0, pVB, sizeof(RAGEVERTEX) );
@@ -278,71 +273,29 @@ void Sprite::DrawPrimitives()
{
DISPLAY->PushMatrix();
DISPLAY->TranslateLocal( m_fShadowLength, m_fShadowLength, 0 ); // shift by 5 units
pVB->Lock( 0, 0, (BYTE**)&v, 0 );
v[0].color = v[1].color = v[2].color = v[3].color = D3DXCOLOR(0,0,0,0.5f*m_temp_colorDiffuse[0].a); // semi-transparent black
pVB->Unlock();
pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE );
pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_SELECTARG2 );
pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE );
pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE );
pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_MODULATE );
pd3dDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, 0, 2 );
DISPLAY->AddQuad( v );
DISPLAY->PopMatrix();
}
//////////////////////
// render the diffuse pass
//////////////////////
pVB->Lock( 0, 0, (BYTE**)&v, 0 );
v[0].color = m_temp_colorDiffuse[2]; // bottom left
v[1].color = m_temp_colorDiffuse[0]; // top left
v[2].color = m_temp_colorDiffuse[3]; // bottom right
v[3].color = m_temp_colorDiffuse[1]; // top right
pVB->Unlock();
pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE );
pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_MODULATE );//bBlendAdd ? D3DTOP_ADD : D3DTOP_MODULATE );
pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE );
pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE );
pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_MODULATE );//bBlendAdd ? D3DTOP_ADD : D3DTOP_MODULATE );
// finally! Pump those triangles!
pd3dDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, 0, 2 );
DISPLAY->AddQuad( v );
}
//////////////////////
// render the add pass
// render the glow pass
//////////////////////
if( m_temp_colorAdd.a != 0 )
if( m_temp_colorGlow.a != 0 )
{
pVB->Lock( 0, 0, (BYTE**)&v, 0 );
v[0].color = v[1].color = v[2].color = v[3].color = m_temp_colorAdd;
pVB->Unlock();
pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE );
pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_SELECTARG2 );
pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE );
pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE );
pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_MODULATE );
pd3dDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, 0, 2 );
DISPLAY->SetColorDiffuse();
v[0].color = v[1].color = v[2].color = v[3].color = m_temp_colorGlow;
DISPLAY->AddQuad( v );
}
}
+6 -11
View File
@@ -874,25 +874,20 @@ void Render()
break;
case S_OK:
{
// set texture and alpha properties
LPDIRECT3DDEVICE8 pd3dDevice = DISPLAY->GetDevice();
// calculate view and projection transforms
D3DXMATRIX matProj;
D3DXMatrixOrthoOffCenterLH( &matProj, 0, 640, 480, 0, -1000, 1000 );
pd3dDevice->SetTransform( D3DTS_PROJECTION, &matProj );
D3DXMATRIX mat;
D3DXMatrixOrthoOffCenterLH( &mat, 0, 640, 480, 0, -1000, 1000 );
DISPLAY->SetProjectionTransform( &mat );
D3DXMATRIX matView;
D3DXMatrixIdentity( &matView );
pd3dDevice->SetTransform( D3DTS_VIEW, &matView );
D3DXMatrixIdentity( &mat );
DISPLAY->SetViewTransform( &mat );
DISPLAY->ResetMatrixStack();
// draw the game
SCREENMAN->Draw();
DISPLAY->EndFrame();
}
break;