diff --git a/stepmania/Themes/default/metrics.ini b/stepmania/Themes/default/metrics.ini index 2229146990..fb70e9c63d 100644 --- a/stepmania/Themes/default/metrics.ini +++ b/stepmania/Themes/default/metrics.ini @@ -456,11 +456,11 @@ HelpText=Press START to continue TimerSeconds=15 [ScreenSelectMusic] -BannerX=160 -BannerY=162 -BannerOnCommand=x,148;y,172;addx,-400;bounceend,0.5;addx,400 +BannerX=148 +BannerY=172 +BannerOnCommand=addx,-400;bounceend,0.5;addx,400 BannerOffCommand=bouncebegin,0.5;addx,-400 -BannerWidth=282 +BannerWidth=284 BannerHeight=92 BannerFrameX=160 BannerFrameY=162 diff --git a/stepmania/src/Actor.cpp b/stepmania/src/Actor.cpp index 76d3d7faff..c9f82c5d4e 100644 --- a/stepmania/src/Actor.cpp +++ b/stepmania/src/Actor.cpp @@ -47,7 +47,8 @@ void Actor::Reset() m_fShadowLength = 4; m_bTextureWrapping = false; m_bIsAnimating = true; - m_bBlendAdd = false; + m_BlendMode = BLEND_NORMAL; + m_bUseZBuffer = false; } Actor::Actor() @@ -184,6 +185,15 @@ void Actor::BeginDraw() // set the world matrix and calculate actor properties } } +void Actor::SetRenderStates() +{ + // set Actor-defined render states + DISPLAY->SetTextureWrapping( m_bTextureWrapping ); + DISPLAY->SetBlendMode( m_BlendMode ); + DISPLAY->SetZBuffer( m_bUseZBuffer ); + DISPLAY->SetBackfaceCull( m_bUseBackfaceCull ); +} + void Actor::EndDraw() { DISPLAY->PopMatrix(); @@ -733,8 +743,8 @@ void Actor::Command( CString sCommandString ) else if( sName=="scaletocover" ) { RectI R(iParam(1), iParam(2), iParam(3), iParam(4)); ScaleToCover(R); } // Commands that take effect immediately (ignoring the tweening queue): else if( sName=="animate" ) EnableAnimation( bParam(1) ); - else if( sName=="texturewrapping" ) EnableTextureWrapping( bParam(1) ); - else if( sName=="additiveblend" ) EnableAdditiveBlend( bParam(1) ); + else if( sName=="texturewrapping" ) SetTextureWrapping( bParam(1) ); + else if( sName=="additiveblend" ) SetBlendMode( bParam(1) ? BLEND_ADD : BLEND_NORMAL ); else { CString sError = ssprintf( "Unrecognized command name '%s' in command string '%s'.", sName.c_str(), sCommandString.c_str() ); diff --git a/stepmania/src/Actor.h b/stepmania/src/Actor.h index 2a28bb85cc..30e1463cf2 100644 --- a/stepmania/src/Actor.h +++ b/stepmania/src/Actor.h @@ -54,7 +54,8 @@ public: // let subclasses override virtual void Draw(); // calls, BeginDraw, DrawPrimitives, EndDraw virtual void BeginDraw(); // pushes transform onto world matrix stack - virtual void DrawPrimitives() {} // override with Actor specific action + virtual void SetRenderStates(); // Actor should call at beginning of their DrawPrimitives() + virtual void DrawPrimitives() {}; // Derivitives should override virtual void EndDraw(); // pops transform from world matrix stack bool IsFirstUpdate(); virtual void Update( float fDeltaTime ); @@ -219,14 +220,18 @@ public: void SetShadowLength( float fLength ); void EnableShadow( bool b ) { m_bShadow = b; } - - virtual void EnableAdditiveBlend( bool b ) { m_bBlendAdd = b; } - virtual void EnableAnimation( bool b ) { m_bIsAnimating = b; } virtual void StartAnimating() { this->EnableAnimation(true); }; virtual void StopAnimating() { this->EnableAnimation(false); }; - virtual void EnableTextureWrapping( bool b ) { m_bTextureWrapping = b; } + + // + // render states + // + virtual void SetBlendMode( BlendMode mode ) { m_BlendMode = mode; } + virtual void SetTextureWrapping( bool b ) { m_bTextureWrapping = b; } + virtual void SetUseZBuffer( bool b ) { m_bUseZBuffer = b; } + virtual void SetUseBackfaceCull( bool b ) { m_bUseBackfaceCull = b; } // // fade command @@ -302,10 +307,15 @@ protected: // bool m_bShadow; float m_fShadowLength; - bool m_bTextureWrapping; bool m_bIsAnimating; - bool m_bBlendAdd; + // + // render states + // + bool m_bTextureWrapping; + BlendMode m_BlendMode; + bool m_bUseZBuffer; + bool m_bUseBackfaceCull; }; #endif diff --git a/stepmania/src/ActorFrame.cpp b/stepmania/src/ActorFrame.cpp index fb5b6e2aa3..99948707fd 100644 --- a/stepmania/src/ActorFrame.cpp +++ b/stepmania/src/ActorFrame.cpp @@ -48,6 +48,10 @@ void ActorFrame::MoveToHead( Actor* pActor ) void ActorFrame::DrawPrimitives() { + // Don't set Actor-defined render states because we won't be drawing + // any geometry that belongs to this object. + // Actor::DrawPrimitives(); + // draw all sub-ActorFrames while we're in the ActorFrame's local coordinate space for( unsigned i=0; iDraw(); @@ -77,6 +81,15 @@ void ActorFrame::SetDiffuse( RageColor c ) m_SubActors[i]->SetDiffuse(c ); } +void ActorFrame::SetUseZBuffer( bool b ) +{ + Actor::SetUseZBuffer( b ); + + // set all sub-Actors + for( unsigned i=0; iSetUseZBuffer( b ); +} + float ActorFrame::GetTweenTimeLeft() const { float m = Actor::GetTweenTimeLeft(); diff --git a/stepmania/src/ActorFrame.h b/stepmania/src/ActorFrame.h index 52a73626ae..a2e91be646 100644 --- a/stepmania/src/ActorFrame.h +++ b/stepmania/src/ActorFrame.h @@ -27,6 +27,8 @@ public: virtual void SetDiffuse( RageColor c ); + virtual void SetUseZBuffer( bool b ); + /* Amount of time until all tweens (and all children's tweens) have stopped: */ virtual float GetTweenTimeLeft() const; diff --git a/stepmania/src/BGAnimationLayer.cpp b/stepmania/src/BGAnimationLayer.cpp index d2b669ba47..8a41aa10d0 100644 --- a/stepmania/src/BGAnimationLayer.cpp +++ b/stepmania/src/BGAnimationLayer.cpp @@ -132,7 +132,7 @@ void BGAnimationLayer::LoadFromVisualization( CString sMoviePath ) m_Sprites.push_back(new Sprite); m_Sprites.back()->LoadBG( sMoviePath ); m_Sprites.back()->StretchTo( RectI(SCREEN_LEFT,SCREEN_TOP,SCREEN_RIGHT,SCREEN_BOTTOM) ); - m_Sprites.back()->EnableAdditiveBlend( true ); + m_Sprites.back()->SetBlendMode( BLEND_ADD ); } @@ -326,7 +326,7 @@ void BGAnimationLayer::LoadFromAniLayerFile( CString sPath ) { m_Sprites.push_back(new Sprite); m_Sprites.back()->Load( ID ); - m_Sprites.back()->EnableTextureWrapping( true ); // gets rid of some "cracks" + m_Sprites.back()->SetTextureWrapping( true ); // gets rid of some "cracks" switch( effect ) { @@ -385,7 +385,7 @@ void BGAnimationLayer::LoadFromAniLayerFile( CString sPath ) if( sPath.Find("add") != -1 ) for( unsigned i=0; iEnableAdditiveBlend( true ); + m_Sprites[i]->SetBlendMode( BLEND_ADD ); /* CString sDir, sFName, sExt; @@ -582,7 +582,7 @@ void BGAnimationLayer::LoadFromIni( CString sAniDir, CString sLayer ) { m_Sprites.push_back(NewSprite(IsBanner)); m_Sprites.back()->Load( ID ); - m_Sprites.back()->EnableTextureWrapping( true ); // gets rid of some "cracks" + m_Sprites.back()->SetTextureWrapping( true ); // gets rid of some "cracks" m_Sprites.back()->SetZoom( randomf(m_fZoomMin,m_fZoomMax) ); } } diff --git a/stepmania/src/Banner.h b/stepmania/src/Banner.h index 5cd378a30b..e4999de9f3 100644 --- a/stepmania/src/Banner.h +++ b/stepmania/src/Banner.h @@ -12,7 +12,7 @@ */ #include "CroppedSprite.h" -#include "RageTextureManager.h" +#include "RageTexture.h" class Song; class Course; diff --git a/stepmania/src/BitmapText.cpp b/stepmania/src/BitmapText.cpp index cd2b3dc664..a6e905a525 100644 --- a/stepmania/src/BitmapText.cpp +++ b/stepmania/src/BitmapText.cpp @@ -280,14 +280,9 @@ void BitmapText::DrawPrimitives() return; DISPLAY->SetTextureModeModulate(); - if( m_bBlendAdd ) - DISPLAY->SetBlendModeAdd(); - else - DISPLAY->SetBlendModeNormal(); - /* Draw if we're not fully transparent or the zbuffer is enabled (which ignores - * alpha). */ - if( m_temp.diffuse[0].a != 0 || DISPLAY->ZBufferEnabled()) + /* Draw if we're not fully transparent or the zbuffer is enabled */ + if( m_temp.diffuse[0].a != 0 ) { ////////////////////// // render the shadow diff --git a/stepmania/src/CourseContentsList.cpp b/stepmania/src/CourseContentsList.cpp index 6345640e38..bdbe4929c7 100644 --- a/stepmania/src/CourseContentsList.cpp +++ b/stepmania/src/CourseContentsList.cpp @@ -96,7 +96,7 @@ void CourseContentsList::Update( float fDeltaTime ) void CourseContentsList::DrawPrimitives() { // turn on Z buffer to clip items - DISPLAY->EnableZBuffer(); + DISPLAY->SetZBuffer( true ); // write to z buffer so that top and bottom are clipped m_quad.SetZ( 1 ); @@ -128,7 +128,7 @@ void CourseContentsList::DrawPrimitives() } // turn off Z buffer - DISPLAY->DisableZBuffer(); + DISPLAY->SetZBuffer( false ); } void CourseContentsList::TweenInAfterChangedCourse() diff --git a/stepmania/src/DancingCharacters.cpp b/stepmania/src/DancingCharacters.cpp index 53a5b6444d..42b81c5305 100644 --- a/stepmania/src/DancingCharacters.cpp +++ b/stepmania/src/DancingCharacters.cpp @@ -67,7 +67,7 @@ void DancingCharacters::DrawPrimitives() m_CameraAt, RageVector3(0,1,0) ); - DISPLAY->EnableLighting( true ); + DISPLAY->SetLighting( true ); DISPLAY->SetLightDirectional( 0, RageColor(0.4f,0.4f,0.4f,1), @@ -78,7 +78,7 @@ void DancingCharacters::DrawPrimitives() ActorFrame::DrawPrimitives(); DISPLAY->SetLightOff( 0 ); - DISPLAY->EnableLighting( false ); + DISPLAY->SetLighting( false ); DISPLAY->ExitPerspective(); } diff --git a/stepmania/src/FadingBanner.cpp b/stepmania/src/FadingBanner.cpp index 2c2af06671..3aff089a54 100644 --- a/stepmania/src/FadingBanner.cpp +++ b/stepmania/src/FadingBanner.cpp @@ -16,6 +16,8 @@ FadingBanner::FadingBanner() { m_iIndexFront = 0; + for( int i=0; i<2; i++ ) + this->AddChild( &m_Banner[i] ); } void FadingBanner::SetCroppedSize( float fWidth, float fHeight ) @@ -26,14 +28,13 @@ void FadingBanner::SetCroppedSize( float fWidth, float fHeight ) void FadingBanner::Update( float fDeltaTime ) { - Actor::Update( fDeltaTime ); - for( int i=0; i<2; i++ ) - m_Banner[i].Update( fDeltaTime ); + ActorFrame::Update( fDeltaTime ); } void FadingBanner::DrawPrimitives() { - Actor::DrawPrimitives(); + // draw manually +// ActorFrame::DrawPrimitives(); m_Banner[GetBackIndex()].Draw(); m_Banner[m_iIndexFront].Draw(); } diff --git a/stepmania/src/FadingBanner.h b/stepmania/src/FadingBanner.h index 6608c9a608..300cd209f1 100644 --- a/stepmania/src/FadingBanner.h +++ b/stepmania/src/FadingBanner.h @@ -12,8 +12,9 @@ */ #include "Banner.h" +#include "ActorFrame.h" -class FadingBanner : public Actor +class FadingBanner : public ActorFrame { public: FadingBanner(); diff --git a/stepmania/src/LifeMeterBar.cpp b/stepmania/src/LifeMeterBar.cpp index a6690a2162..5c771a0887 100644 --- a/stepmania/src/LifeMeterBar.cpp +++ b/stepmania/src/LifeMeterBar.cpp @@ -116,7 +116,7 @@ public: void DrawPrimitives() { - DISPLAY->EnableZBuffer(); + DISPLAY->SetZBuffer( true ); if( GAMESTATE->IsPlayerEnabled(m_PlayerNumber) ) { @@ -139,7 +139,7 @@ public: } - DISPLAY->DisableZBuffer(); + DISPLAY->SetZBuffer( false ); m_sprFrame.Draw(); diff --git a/stepmania/src/Model.cpp b/stepmania/src/Model.cpp index 08fb83f18c..0333182d4b 100644 --- a/stepmania/src/Model.cpp +++ b/stepmania/src/Model.cpp @@ -24,6 +24,8 @@ Model::Model () { m_pModel = NULL; m_pBones = NULL; + m_bTextureWrapping = true; + m_bUseZBuffer = true; } Model::~Model () @@ -723,13 +725,13 @@ bool Model::LoadMilkshapeAsciiBones( CString sPath ) void Model::DrawPrimitives() { + if (!m_pModel) return; - DISPLAY->Scale( 1, -1, 1 ); // flip so positive Y is up + Actor::DrawPrimitives(); // set Actor-specified render states - DISPLAY->SetBlendModeNormal(); - DISPLAY->EnableZBuffer(); + DISPLAY->Scale( 1, -1, 1 ); // flip Y so positive is up for (int i = 0; i < (int)m_pModel->Meshes.size(); i++) { @@ -796,7 +798,7 @@ void Model::DrawPrimitives() DISPLAY->DrawIndexedTriangles( &TempVertices[0], (Uint16*)&pMesh->Triangles[0], pMesh->Triangles.size()*3 ); } - DISPLAY->DisableZBuffer(); + DISPLAY->SetZBuffer( false ); } diff --git a/stepmania/src/NoteDisplay.cpp b/stepmania/src/NoteDisplay.cpp index cb33ed37d2..44d6290ba1 100644 --- a/stepmania/src/NoteDisplay.cpp +++ b/stepmania/src/NoteDisplay.cpp @@ -418,12 +418,12 @@ void NoteDisplay::DrawHold( const HoldNote& hn, const bool bActive, const float RageTexture* pTexture = pBottomCap->GetTexture(); const RectF *pRect = pBottomCap->GetCurrentTextureCoordRect(); DISPLAY->SetTexture( pTexture ); - DISPLAY->SetBlendModeNormal(); + DISPLAY->SetBlendMode( BLEND_NORMAL ); if( bDrawGlowOnly ) DISPLAY->SetTextureModeGlow(); else DISPLAY->SetTextureModeModulate(); - DISPLAY->EnableTextureWrapping(false); + DISPLAY->SetTextureWrapping(false); const float fFrameWidth = pBottomCap->GetUnzoomedWidth(); const float fFrameHeight = pBottomCap->GetUnzoomedHeight(); @@ -483,12 +483,12 @@ void NoteDisplay::DrawHold( const HoldNote& hn, const bool bActive, const float RageTexture* pTexture = pSprBody->GetTexture(); const RectF *pRect = pSprBody->GetCurrentTextureCoordRect(); DISPLAY->SetTexture( pTexture ); - DISPLAY->SetBlendModeNormal(); + DISPLAY->SetBlendMode( BLEND_NORMAL ); if( bDrawGlowOnly ) DISPLAY->SetTextureModeGlow(); else DISPLAY->SetTextureModeModulate(); - DISPLAY->EnableTextureWrapping(); + DISPLAY->SetTextureWrapping( true ); const float fFrameWidth = pSprBody->GetUnzoomedWidth(); @@ -561,12 +561,12 @@ void NoteDisplay::DrawHold( const HoldNote& hn, const bool bActive, const float RageTexture* pTexture = pSprTopCap->GetTexture(); const RectF *pRect = pSprTopCap->GetCurrentTextureCoordRect(); DISPLAY->SetTexture( pTexture ); - DISPLAY->SetBlendModeNormal(); + DISPLAY->SetBlendMode( BLEND_NORMAL ); if( bDrawGlowOnly ) DISPLAY->SetTextureModeGlow(); else DISPLAY->SetTextureModeModulate(); - DISPLAY->EnableTextureWrapping(false); + DISPLAY->SetTextureWrapping(false); const float fFrameWidth = pSprTopCap->GetUnzoomedWidth(); const float fFrameHeight = pSprTopCap->GetUnzoomedHeight(); @@ -705,7 +705,7 @@ void NoteDisplay::DrawTap( const int iCol, const float fBeat, const bool bOnSame if( cache->m_bUseLighting ) { - DISPLAY->EnableLighting( true ); + DISPLAY->SetLighting( true ); DISPLAY->SetLightDirectional( 0, RageColor(0.0f,0.0f,0.0f,1), @@ -719,7 +719,7 @@ void NoteDisplay::DrawTap( const int iCol, const float fBeat, const bool bOnSame if( cache->m_bUseLighting ) { DISPLAY->SetLightOff( 0 ); - DISPLAY->EnableLighting( false ); + DISPLAY->SetLighting( false ); } } diff --git a/stepmania/src/RageDisplay.cpp b/stepmania/src/RageDisplay.cpp index f8e7ded6e7..9553df9fad 100644 --- a/stepmania/src/RageDisplay.cpp +++ b/stepmania/src/RageDisplay.cpp @@ -132,6 +132,10 @@ void RageDisplay::SetupOpenGL() glDisable(GL_DEPTH_TEST); glDisable(GL_CULL_FACE); + /* Reject pixels that are completely transparent early in the pipeline */ + glAlphaFunc( GL_GREATER, 0.01f ); + glEnable( GL_ALPHA_TEST ); + /* * Set state variables */ @@ -906,13 +910,6 @@ void RageDisplay::SetTextureModeModulate() glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); } -/* Set the blend mode for both texture and alpha. This is all that's - * available pre-OpenGL 1.4. */ -void RageDisplay::SetBlendMode(int src, int dst) -{ - glBlendFunc( GLenum(src), GLenum(dst) ); -} - void RageDisplay::SetTextureModeGlow(GlowMode m) { if(m == GLOW_WHITEN && !m_oglspecs->EXT_texture_env_combine) @@ -921,7 +918,7 @@ void RageDisplay::SetTextureModeGlow(GlowMode m) switch(m) { case GLOW_BRIGHTEN: - SetBlendMode( GL_SRC_ALPHA, GL_ONE ); + glBlendFunc( GL_SRC_ALPHA, GL_ONE ); return; case GLOW_WHITEN: @@ -940,33 +937,46 @@ void RageDisplay::SetTextureModeGlow(GlowMode m) } } -void RageDisplay::SetBlendModeNormal() +void RageDisplay::SetBlendMode( BlendMode mode ) { - SetBlendMode( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); -} -void RageDisplay::SetBlendModeAdd() -{ - SetBlendMode( GL_ONE, GL_ONE ); + switch( mode ) + { + case BLEND_NORMAL: + glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); + break; + case BLEND_ADD: + glBlendFunc( GL_ONE, GL_ONE ); + break; + case BLEND_NO_EFFECT: + glBlendFunc( GL_ZERO, GL_ONE ); + break; + default: + ASSERT(0); + } } -bool RageDisplay::ZBufferEnabled() const +bool RageDisplay::IsZBufferEnabled() const { bool a; glGetBooleanv( GL_DEPTH_TEST, (unsigned char*)&a ); return a; } -void RageDisplay::EnableZBuffer() +void RageDisplay::SetZBuffer( bool b ) { - glEnable( GL_DEPTH_TEST ); + if( b ) + glEnable( GL_DEPTH_TEST ); + else + glDisable( GL_DEPTH_TEST ); } -void RageDisplay::DisableZBuffer() +void RageDisplay::ClearZBuffer() { - glDisable( GL_DEPTH_TEST ); + glClear( GL_DEPTH_BUFFER_BIT ); } -void RageDisplay::EnableTextureWrapping(bool b) + +void RageDisplay::SetTextureWrapping( bool b ) { - GLenum mode = b? GL_REPEAT:GL_CLAMP; + GLenum mode = b ? GL_REPEAT : GL_CLAMP; glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, mode ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, mode ); } @@ -986,7 +996,7 @@ void RageDisplay::SetMaterial( glMaterialf( GL_FRONT, GL_SHININESS, shininess ); } -void RageDisplay::EnableLighting(bool b) +void RageDisplay::SetLighting( bool b ) { if( b ) glEnable( GL_LIGHTING ); else glDisable( GL_LIGHTING ); @@ -1016,4 +1026,12 @@ void RageDisplay::SetLightDirectional( glLightfv(GL_LIGHT0, GL_POSITION, position); glPopMatrix(); -} \ No newline at end of file +} + +void RageDisplay::SetBackfaceCull( bool b ) +{ + if( b ) + glEnable( GL_CULL_FACE ); + else + glDisable( GL_CULL_FACE ); +} diff --git a/stepmania/src/RageDisplay.h b/stepmania/src/RageDisplay.h index 19b1b24320..e180219df6 100644 --- a/stepmania/src/RageDisplay.h +++ b/stepmania/src/RageDisplay.h @@ -22,6 +22,7 @@ struct RageVertex; const int REFRESH_DEFAULT = 0; struct oglspecs_t; + class RageDisplay { friend class RageTexture; @@ -58,17 +59,19 @@ public: void PostMultMatrix( const RageMatrix &f ); void PreMultMatrix( const RageMatrix &f ); + void SetBlendMode( BlendMode mode ); + void SetTexture( RageTexture* pTexture ); - void SetTextureModeModulate(); - void SetTextureModeGlow(GlowMode m = GLOW_WHITEN ); - void SetBlendModeNormal(); - void SetBlendModeAdd(); - bool ZBufferEnabled() const; - void EnableZBuffer(); - void DisableZBuffer(); - void EnableTextureWrapping(bool b=true); + void SetTextureModeGlow( GlowMode m = GLOW_WHITEN ); + void SetTextureWrapping( bool b ); + bool IsZBufferEnabled() const; + void SetZBuffer( bool b ); + void ClearZBuffer(); + + void SetBackfaceCull( bool b ); + void SetMaterial( float emissive[4], float ambient[4], @@ -77,7 +80,7 @@ public: float shininess ); - void EnableLighting(bool b=true); + void SetLighting( bool b ); void SetLightOff( int index ); void SetLightDirectional( int index, @@ -119,7 +122,6 @@ public: protected: void AddVerts( const RageVertex v[], int iNumVerts ); - void SetBlendMode(int src, int dst); void SetupOpenGL(); void SetupExtensions(); void SetViewport(int shift_left, int shift_down); diff --git a/stepmania/src/RageTypes.h b/stepmania/src/RageTypes.h index fd1b9d6e1c..fa1014c221 100644 --- a/stepmania/src/RageTypes.h +++ b/stepmania/src/RageTypes.h @@ -11,11 +11,12 @@ ----------------------------------------------------------------------------- */ -/* This is shared between Actor and RageDisplay. I don't want to put this in +/* These are shared between Actor and RageDisplay. I don't want to put this in * Actor (because Rage shouldn't touch Actor) and I don't want to have Actor.h * depend on RageDisplay (since that'd boost RDisplay.h a lot), so let's just * put this here. */ enum GlowMode { GLOW_BRIGHTEN, GLOW_WHITEN }; +enum BlendMode { BLEND_NORMAL, BLEND_ADD, BLEND_NO_EFFECT }; struct RageVector2 { diff --git a/stepmania/src/Sample3dObject.cpp b/stepmania/src/Sample3dObject.cpp deleted file mode 100644 index b96d91e999..0000000000 --- a/stepmania/src/Sample3dObject.cpp +++ /dev/null @@ -1,103 +0,0 @@ -/* - * This is a demonstration 3d object. I created this to give some basic - * code that sets up normal 3d object rendering. (The Space code sets - * up perspective and then renders 2d, which is different.) This actor - * should be positioned just like any other actor, calling SetX and SetY - * in the parent; that position will become the center of the frustum. - */ -#include "global.h" - -#include "Sample3dObject.h" - -#include "RageDisplay.h" -#include - -#include "SDL.h" -#include "SDL_opengl.h" - -Sample3dObject::Sample3dObject() -{ - rot = 0; - -} - -void Sample3dObject::Update( float fDeltaTime ) -{ - rot += fDeltaTime * 360.f; - rot = float(fmod(rot, 360.f)); -} - -/* One note about rendering: you get a 640x480 viewport to render in, centered - * on the location the actor is set to. That means that if the center isn't - * the center of the real screen, part of the view is offscreen and there's - * a portion of the screen you can't render to. If you want to render things - * like fullscreen background animations (characters), call SetX(CENTER_X) on - * and SetY(CENTER_Y) on the object so it gets the whole screen. - */ -void Sample3dObject::DrawPrimitives() -{ - /* If this is a sub-object (3d object within a 3d object), this won't - * actually do anything: */ - DISPLAY->EnterPerspective(60); - - DISPLAY->SetTexture(NULL); - DISPLAY->EnableZBuffer(); - - glColor4f(1,1,1,1); - glPushMatrix(); - - /* By default, 0,0,0 is the center of the object, at the location the actor - * is set to. We have to translate away from the viewpoint (negative Z) - * to get away from the viewer (and in front of the near clip plane). */ - glTranslatef (0,0,-5); - - { /* Standard ugly OpenGL lighting stuff. */ - GLfloat mat_ambient[] = { 1.0, 1.0, 1.0, 1.0 }; - GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 1.0 }; - GLfloat light_position[] = { 0.0, 0.0, 0.0, 1.0 }; - GLfloat lm_ambient[] = { 0.3f, 0.3f, 0.3f, 1.0f }; - - glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient); - glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); - glMaterialf(GL_FRONT, GL_SHININESS, 100.0); - glLightfv(GL_LIGHT0, GL_POSITION, light_position); - glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lm_ambient); - - glEnable(GL_LIGHTING); - glEnable(GL_LIGHT0); - } - - GLfloat sphere_diffuse[] = { 0.7f, 0.0f, 0.7f, 1.0f }; - glMaterialfv(GL_FRONT, GL_DIFFUSE, sphere_diffuse); - GLUquadricObj *quadObj = gluNewQuadric(); - gluQuadricDrawStyle(quadObj, GLenum(GLU_FILL)); - gluQuadricNormals(quadObj, GLenum(GLU_SMOOTH)); - - glRotatef (rot, 0.0, 1.0, 0.0); - - glPushMatrix(); - glTranslatef (1,0,0); - gluSphere(quadObj, .25, 8, 16); - glPopMatrix(); - - glPushMatrix(); - glTranslatef (-1,0,0); - gluSphere(quadObj, .35, 8, 16); - glPopMatrix(); - - gluDeleteQuadric(quadObj); - glPopMatrix(); - - DISPLAY->ExitPerspective(); - DISPLAY->DisableZBuffer(); - - glDisable(GL_LIGHTING); - glDisable(GL_LIGHT0); -} - -/* - * Copyright (c) 2002 by the person(s) listed below. All rights reserved. - * - * Glenn Maynard - */ - diff --git a/stepmania/src/Sample3dObject.h b/stepmania/src/Sample3dObject.h deleted file mode 100644 index fe92ca79d7..0000000000 --- a/stepmania/src/Sample3dObject.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef SAMPLE_3D_OBJECT -#define SAMPLE_3D_OBJECT - -#include "ActorFrame.h" - -class Sample3dObject: public ActorFrame -{ - float rot; - -public: - Sample3dObject(); - void Update( float fDeltaTime ); - void DrawPrimitives(); - -}; - -#endif - -/* - * Copyright (c) 2002 by the person(s) listed below. All rights reserved. - * - * Glenn Maynard - */ diff --git a/stepmania/src/ScreenEz2SelectMusic.cpp b/stepmania/src/ScreenEz2SelectMusic.cpp index 0456e31989..461a46023d 100644 --- a/stepmania/src/ScreenEz2SelectMusic.cpp +++ b/stepmania/src/ScreenEz2SelectMusic.cpp @@ -28,6 +28,7 @@ #include "Notes.h" #include "RageTimer.h" #include "ActorUtil.h" +#include "RageTextureManager.h" #define SCROLLING_LIST_X THEME->GetMetricF("ScreenEz2SelectMusic","ScrollingListX") #define SCROLLING_LIST_Y THEME->GetMetricF("ScreenEz2SelectMusic","ScrollingListY") diff --git a/stepmania/src/ScreenSandbox.cpp b/stepmania/src/ScreenSandbox.cpp index 30d23f2c86..45ea55949b 100644 --- a/stepmania/src/ScreenSandbox.cpp +++ b/stepmania/src/ScreenSandbox.cpp @@ -62,7 +62,7 @@ void ScreenSandbox::Update( float fDeltaTime ) void ScreenSandbox::DrawPrimitives() { - DISPLAY->EnableLighting( true ); + DISPLAY->SetLighting( true ); DISPLAY->SetLightDirectional( 0, RageColor(0,0,0,0), @@ -73,7 +73,7 @@ void ScreenSandbox::DrawPrimitives() Screen::DrawPrimitives(); DISPLAY->SetLightOff( 0 ); - DISPLAY->EnableLighting( false ); + DISPLAY->SetLighting( false ); } void ScreenSandbox::MenuLeft( PlayerNumber pn ) diff --git a/stepmania/src/ScreenSelectMusic.cpp b/stepmania/src/ScreenSelectMusic.cpp index 0ede298c55..6db8a32420 100644 --- a/stepmania/src/ScreenSelectMusic.cpp +++ b/stepmania/src/ScreenSelectMusic.cpp @@ -32,7 +32,8 @@ #include "Notes.h" #include "ActorUtil.h" #include "RageDisplay.h" - +#include "RageTextureManager.h" + const int NUM_SCORE_DIGITS = 9; @@ -69,9 +70,17 @@ ScreenSelectMusic::ScreenSelectMusic() : Screen("ScreenSelectMusic") m_MusicWheel.SetName( "Wheel" ); this->AddChild( &m_MusicWheel ); + m_sprBannerMask.SetName( "Banner" ); // use the same metrics and animation as Banner + m_sprBannerMask.Load( THEME->GetPathToG("ScreenSelectMusic banner mask") ); + m_sprBannerMask.SetBlendMode( BLEND_NO_EFFECT ); // don't draw to color buffer + m_sprBannerMask.SetUseZBuffer( true ); // do draw to the zbuffer + m_sprBannerMask.SetZ( m_sprBannerMask.GetZ()+0.05f ); + this->AddChild( &m_sprBannerMask ); + // this is loaded SetSong and TweenToSong m_Banner.SetName( "Banner" ); m_Banner.SetCroppedSize( BANNER_WIDTH, BANNER_HEIGHT ); + m_Banner.SetUseZBuffer( true ); // do have to pass the z test this->AddChild( &m_Banner ); m_sprBannerFrame.SetName( "BannerFrame" ); @@ -202,8 +211,9 @@ void ScreenSelectMusic::DrawPrimitives() void ScreenSelectMusic::TweenOnScreen() { - SET_XY_AND_ON_COMMAND( m_sprBannerFrame ); + SET_XY_AND_ON_COMMAND( m_sprBannerMask ); SET_XY_AND_ON_COMMAND( m_Banner ); + SET_XY_AND_ON_COMMAND( m_sprBannerFrame ); SET_XY_AND_ON_COMMAND( m_BPMDisplay ); SET_XY_AND_ON_COMMAND( m_sprStage ); SET_XY_AND_ON_COMMAND( m_sprCDTitle ); @@ -237,8 +247,9 @@ void ScreenSelectMusic::TweenOnScreen() void ScreenSelectMusic::TweenOffScreen() { - OFF_COMMAND( m_sprBannerFrame ); + OFF_COMMAND( m_sprBannerMask ); OFF_COMMAND( m_Banner ); + OFF_COMMAND( m_sprBannerFrame ); OFF_COMMAND( m_BPMDisplay ); OFF_COMMAND( m_sprStage ); OFF_COMMAND( m_sprCDTitle ); diff --git a/stepmania/src/ScreenSelectMusic.h b/stepmania/src/ScreenSelectMusic.h index 77a6d410bc..2a55563ec7 100644 --- a/stepmania/src/ScreenSelectMusic.h +++ b/stepmania/src/ScreenSelectMusic.h @@ -60,8 +60,9 @@ protected: MenuElements m_Menu; - Sprite m_sprBannerFrame; + Sprite m_sprBannerMask; FadingBanner m_Banner; + Sprite m_sprBannerFrame; BPMDisplay m_BPMDisplay; Sprite m_sprStage; Sprite m_sprCDTitle; diff --git a/stepmania/src/Sprite.cpp b/stepmania/src/Sprite.cpp index eb993f3125..c14ce70289 100644 --- a/stepmania/src/Sprite.cpp +++ b/stepmania/src/Sprite.cpp @@ -264,7 +264,7 @@ void Sprite::DrawPrimitives() case align_top: quadVerticies.top = 0; quadVerticies.bottom = m_size.y; break; case align_middle: quadVerticies.top = -m_size.y/2; quadVerticies.bottom = m_size.y/2; break; case align_bottom: quadVerticies.top = -m_size.y; quadVerticies.bottom = 0; break; - default: ASSERT( false ); + default: ASSERT(0); } @@ -276,28 +276,24 @@ void Sprite::DrawPrimitives() DISPLAY->SetTexture( m_pTexture ); + // Must call this after setting the texture or else texture + // parameters have no effect. + Actor::SetRenderStates(); // set Actor-specified render states + if( m_pTexture ) { float TexCoords[8]; GetActiveTexCoords(TexCoords); TexCoordsFromArray(v, TexCoords); - - DISPLAY->EnableTextureWrapping(m_bTextureWrapping); } DISPLAY->SetTextureModeModulate(); - if( m_bBlendAdd ) - DISPLAY->SetBlendModeAdd(); - else - DISPLAY->SetBlendModeNormal(); - /* Draw if we're not fully transparent or the zbuffer is enabled (which ignores - * alpha). */ + /* Draw if we're not fully transparent */ if( m_temp.diffuse[0].a > 0 || m_temp.diffuse[1].a > 0 || m_temp.diffuse[2].a > 0 || - m_temp.diffuse[3].a > 0 || - DISPLAY->ZBufferEnabled() ) + m_temp.diffuse[3].a > 0 ) { ////////////////////// // render the shadow @@ -311,13 +307,6 @@ void Sprite::DrawPrimitives() DISPLAY->PopMatrix(); } - /* If the texture doesn't have alpha, and we're not changing alpha in diffuse, - * don't bother to blend when doing the diffuse pass. */ -/* I'm not sure this actually helps anywhere. - if(m_pTexture && !m_bBlendAdd && m_pTexture->GetActualID().iAlphaBits == 0 && - m_temp.diffuse[0].a + m_temp.diffuse[1].a + m_temp.diffuse[2].a + m_temp.diffuse[3].a == 4) - glDisable(GL_BLEND); -*/ ////////////////////// // render the diffuse pass ////////////////////// diff --git a/stepmania/src/StepMania.dsp b/stepmania/src/StepMania.dsp index 67a6d233b9..9ceeb15757 100644 --- a/stepmania/src/StepMania.dsp +++ b/stepmania/src/StepMania.dsp @@ -1,5 +1,5 @@ # Microsoft Developer Studio Project File - Name="StepMania" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# Microsoft Developer Studio Generated Build File, Format Version 60000 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Application" 0x0101 @@ -57,10 +57,10 @@ LINK32=link.exe # SUBTRACT LINK32 /verbose /pdb:none # Begin Special Build Tool IntDir=.\../Release6 -TargetDir=\Stepmania\stepmania +TargetDir=\stepmania\stepmania TargetName=StepMania SOURCE="$(InputPath)" -PreLink_Cmds=disasm\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\ +PreLink_Cmds=disasm\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\ PostBuild_Cmds=disasm\mapconv $(IntDir)\$(TargetName).map $(TargetDir)\StepMania.vdi ia32.vdi # End Special Build Tool @@ -92,10 +92,10 @@ LINK32=link.exe # SUBTRACT LINK32 /verbose /profile /pdb:none /incremental:no /nodefaultlib # Begin Special Build Tool IntDir=.\../Debug6 -TargetDir=\Stepmania\stepmania +TargetDir=\stepmania\stepmania TargetName=StepMania-debug SOURCE="$(InputPath)" -PreLink_Cmds=disasm\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\ +PreLink_Cmds=disasm\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\ PostBuild_Cmds=disasm\mapconv $(IntDir)\$(TargetName).map $(TargetDir)\StepMania.vdi ia32.vdi # End Special Build Tool @@ -1028,14 +1028,6 @@ SOURCE=.\Quad.h # End Source File # Begin Source File -SOURCE=.\Sample3dObject.cpp -# End Source File -# Begin Source File - -SOURCE=.\Sample3dObject.h -# End Source File -# Begin Source File - SOURCE=.\Sprite.cpp # End Source File # Begin Source File diff --git a/stepmania/src/StepMania.vcproj b/stepmania/src/StepMania.vcproj index a8177ae5df..7029fbe917 100644 --- a/stepmania/src/StepMania.vcproj +++ b/stepmania/src/StepMania.vcproj @@ -1217,12 +1217,6 @@ cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\ - - - -