Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members

RageTexture.h

Go to the documentation of this file.
00001 /* RageTexture - Abstract class for a texture and metadata. */ 00002 00003 #ifndef RAGE_TEXTURE_H 00004 #define RAGE_TEXTURE_H 00005 00006 #include "RageTypes.h" 00007 #include "RageTextureID.h" 00008 00009 class RageTexture 00010 { 00011 public: 00012 RageTexture( RageTextureID file ); 00013 virtual ~RageTexture() = 0; 00014 virtual void Update( float fDeltaTime ) {} 00015 virtual void Reload() {} 00016 virtual void Invalidate() { } /* only called by RageTextureManager::InvalidateTextures */ 00017 virtual unsigned GetTexHandle() const = 0; // accessed by RageDisplay 00018 00019 // movie texture/animated texture stuff 00020 virtual void SetPosition( float fSeconds ) {} // seek 00021 virtual void DecodeSeconds( float fSeconds ) {} // decode 00022 virtual void SetPlaybackRate( float fRate ) {} 00023 virtual bool IsAMovie() const { return false; } 00024 void SetLooping(bool looping) { } 00025 00026 int GetSourceWidth() const {return m_iSourceWidth;} 00027 int GetSourceHeight() const {return m_iSourceHeight;} 00028 int GetTextureWidth() const {return m_iTextureWidth;} 00029 int GetTextureHeight() const{return m_iTextureHeight;} 00030 int GetImageWidth() const {return m_iImageWidth;} 00031 int GetImageHeight() const {return m_iImageHeight;} 00032 00033 int GetFramesWide() const {return m_iFramesWide;} 00034 int GetFramesHigh() const {return m_iFramesHigh;} 00035 00036 int GetSourceFrameWidth() const {return GetSourceWidth() / GetFramesWide();} 00037 int GetSourceFrameHeight() const {return GetSourceHeight() / GetFramesHigh();} 00038 int GetTextureFrameWidth() const {return GetTextureWidth() / GetFramesWide();} 00039 int GetTextureFrameHeight() const {return GetTextureHeight() / GetFramesHigh();} 00040 int GetImageFrameWidth() const {return GetImageWidth() / GetFramesWide();} 00041 int GetImageFrameHeight() const {return GetImageHeight() / GetFramesHigh();} 00042 00043 /* Use these to convert between the different coordinate systems: */ 00044 float GetSourceToImageCoordsRatio() const { return float(GetImageWidth()) / GetSourceWidth(); } 00045 float GetImageToTexCoordsRatio() const { return 1.0f / GetTextureWidth(); } 00046 float GetSourceToTexCoordsRatio() const { return GetSourceToImageCoordsRatio() * GetImageToTexCoordsRatio(); } 00047 00048 const RectF *GetTextureCoordRect( int frameNo ) const; 00049 int GetNumFrames() const { return m_iFramesWide*m_iFramesHigh; } 00050 00051 /* Used by RageTextureManager. Order is important; see RageTextureManager.cpp. */ 00052 const RageTextureID::TexPolicy &GetPolicy() const { return m_ID.Policy; } 00053 RageTextureID::TexPolicy &GetPolicy() { return m_ID.Policy; } 00054 int m_iRefCount; 00055 bool m_bWasUsed; 00056 00057 /* The ID that we were asked to load: */ 00058 const RageTextureID &GetID() const { return m_ID; } 00059 00060 static void GetFrameDimensionsFromFileName( CString sPath, int* puFramesWide, int* puFramesHigh ); 00061 static int GetFrameCountFromFileName( CString sPath ); 00062 00063 private: 00064 /* We might change settings when loading (due to hints, hardware 00065 * limitations, etc). The data actually loaded is here: */ 00066 RageTextureID m_ID; 00067 00068 protected: 00069 00070 int m_iSourceWidth, m_iSourceHeight; // dimensions of the original image loaded from disk 00071 int m_iTextureWidth, m_iTextureHeight; // dimensions of the texture in memory 00072 int m_iImageWidth, m_iImageHeight; // dimensions of the image in the texture 00073 int m_iFramesWide, m_iFramesHigh; // The number of frames of animation in each row and column of this texture 00074 vector<RectF> m_TextureCoordRects; // size = m_iFramesWide * m_iFramesHigh 00075 00076 virtual void CreateFrameRects(); 00077 }; 00078 00079 #endif 00080 00081 /* 00082 * Copyright (c) 2001-2004 Chris Danford 00083 * All rights reserved. 00084 * 00085 * Permission is hereby granted, free of charge, to any person obtaining a 00086 * copy of this software and associated documentation files (the 00087 * "Software"), to deal in the Software without restriction, including 00088 * without limitation the rights to use, copy, modify, merge, publish, 00089 * distribute, and/or sell copies of the Software, and to permit persons to 00090 * whom the Software is furnished to do so, provided that the above 00091 * copyright notice(s) and this permission notice appear in all copies of 00092 * the Software and that both the above copyright notice(s) and this 00093 * permission notice appear in supporting documentation. 00094 * 00095 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 00096 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00097 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF 00098 * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS 00099 * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT 00100 * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 00101 * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR 00102 * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 00103 * PERFORMANCE OF THIS SOFTWARE. 00104 */

Generated on Thu Jan 27 20:57:29 2005 for StepMania by doxygen 1.3.7