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

SpriteRenderer.h

Go to the documentation of this file.
00001 //------------------------------------------------------------------------------
00002 // Lamp : Open source game middleware
00003 // Copyright (C) 2004  Junpei Ohtani ( Email : junpee@users.sourceforge.jp )
00004 //
00005 // This library is free software; you can redistribute it and/or
00006 // modify it under the terms of the GNU Lesser General Public
00007 // License as published by the Free Software Foundation; either
00008 // version 2.1 of the License, or (at your option) any later version.
00009 //
00010 // This library is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013 // Lesser General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU Lesser General Public
00016 // License along with this library; if not, write to the Free Software
00017 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 //------------------------------------------------------------------------------
00019 
00020 /** @file
00021  * スプライトレンダラヘッダ
00022  * @author Junpee
00023  */
00024 
00025 #ifndef SPRITE_RENDERER_H_
00026 #define SPRITE_RENDERER_H_
00027 
00028 #include <Core/Container/ArrayList.h>
00029 
00030 namespace Lamp{
00031 
00032 class SpriteRequest;
00033 class SpriteRenderState;
00034 class SpriteGraphicsBuffer;
00035 
00036 //------------------------------------------------------------------------------
00037 /**
00038  * スプライトレンダラ
00039  */
00040 class SpriteRenderer{
00041 public:
00042     //--------------------------------------------------------------------------
00043     // 生成、破棄
00044     //--------------------------------------------------------------------------
00045     /**
00046      * コンストラクタ
00047      * @param maxPriority 最大優先度
00048      * @param defaultPriority デフォルト優先度
00049      */
00050     SpriteRenderer(int maxPriority = 16, int defaultPriority = 8);
00051 
00052     /**
00053      * デストラクタ
00054      */
00055     virtual ~SpriteRenderer();
00056 
00057     //--------------------------------------------------------------------------
00058     // リクエスト
00059     //--------------------------------------------------------------------------
00060     /**
00061      * リクエスト
00062      * @param spriteRequest スプライトリクエスト
00063      */
00064     virtual void request(SpriteRequest* spriteRequest){
00065         request(spriteRequest, defaultPriority_);
00066     }
00067 
00068     /**
00069      * リクエスト
00070      * @param spriteRequest スプライトリクエスト
00071      * @param priority 優先度
00072      */
00073     virtual void request(SpriteRequest* spriteRequest, int priority);
00074 
00075     //--------------------------------------------------------------------------
00076     /**
00077      * リクエスト
00078      * @param spriteRequest スプライトリクエスト
00079      */
00080     virtual void request(const SpriteRequest* spriteRequest){
00081         // インターフェース内部で最適化を行うためにconstをはずす
00082         // 外向けの変数自体はレンダリング時にいじらない
00083         request((SpriteRequest*)spriteRequest);
00084     }
00085 
00086     /**
00087      * リクエスト
00088      * @param spriteRequest スプライトリクエスト
00089      * @param priority 優先度
00090      */
00091     virtual void request(const SpriteRequest* spriteRequest, int priority){
00092         // インターフェース内部で最適化を行うためにconstをはずす
00093         // 外向けの変数自体はレンダリング時にいじらない
00094         request((SpriteRequest*)spriteRequest, priority);
00095     }
00096 
00097     //--------------------------------------------------------------------------
00098     /**
00099      * デフォルトステートのリクエスト
00100      */
00101     virtual void requestDefaultState(){ requestDefaultState(defaultPriority_); }
00102 
00103     /**
00104      * デフォルトステートのリクエスト
00105      * @param priority 優先度
00106      */
00107     virtual void requestDefaultState(int priority);
00108 
00109     //--------------------------------------------------------------------------
00110     // レンダリング
00111     //--------------------------------------------------------------------------
00112     /**
00113      * レンダリング
00114      */
00115     virtual void render(){ render(0, (maxPriority_ - 1)); }
00116 
00117     /**
00118      * レンダリング
00119      * @param startPriority 開始優先度
00120      * @param endPriority 終了優先度
00121      */
00122     virtual void render(int startPriority, int endPriority);
00123 
00124     //--------------------------------------------------------------------------
00125     // 優先度
00126     //--------------------------------------------------------------------------
00127     /**
00128      * 最大優先度の取得
00129      */
00130     virtual int getMaxPriority() const{ return maxPriority_; }
00131 
00132     /**
00133      * デフォルト優先度の設定
00134      * @param defaultPriority デフォルト優先度
00135      */
00136     virtual void setDefaultPriority(int defaultPriority){
00137         Assert((defaultPriority >= 0) && (defaultPriority < maxPriority_));
00138         defaultPriority_ = defaultPriority;
00139     }
00140 
00141     /**
00142      * デフォルト優先度の取得
00143      * @return デフォルト優先度
00144      */
00145     virtual int getDefaultPriority() const{ return defaultPriority_; }
00146 
00147 protected:
00148     //--------------------------------------------------------------------------
00149     /**
00150      * デフォルトステートの適用
00151      */
00152     virtual void applyDefaultState(SpriteRenderState* renderState);
00153 
00154     /**
00155      * レンダラステートの適用
00156      */
00157     virtual void applyRendererState();
00158 
00159 private:
00160     //--------------------------------------------------------------------------
00161     // コピーコンストラクタの隠蔽
00162     SpriteRenderer(const SpriteRenderer& copy);
00163 
00164     // 代入コピーの隠蔽
00165     void operator =(const SpriteRenderer& copy);
00166 
00167     //--------------------------------------------------------------------------
00168     // リクエスト
00169     ArrayList<SpriteRequest*>* requests_;
00170     // グラフィックスバッファ
00171     SpriteGraphicsBuffer* graphicsBuffer_;
00172     // 最大優先度
00173     int maxPriority_;
00174     // デフォルト優先度
00175     int defaultPriority_;
00176 
00177 };
00178 
00179 //------------------------------------------------------------------------------
00180 } // End of namespace Lamp
00181 #endif // End of SPRITE_RENDERER_H_
00182 //------------------------------------------------------------------------------

Generated on Wed Mar 16 10:29:36 2005 for Lamp by doxygen 1.3.2