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 #include "LampBasic.h" 00026 #include "Graphics2D/Renderer/SpriteRenderState.h" 00027 #include "Graphics2D/Renderer/SpriteGraphicsBuffer.h" 00028 #include "Graphics2D/Sprite/SpritePicture.h" 00029 #include "Graphics/Renderer/RenderingDevice.h" 00030 00031 namespace Lamp{ 00032 00033 //------------------------------------------------------------------------------ 00034 // 生成、破棄 00035 //------------------------------------------------------------------------------ 00036 // コンストラクタ 00037 SpriteRenderState::SpriteRenderState(SpriteGraphicsBuffer* graphicsBuffer) : 00038 graphicsBuffer_(graphicsBuffer), picture_(NULL){ 00039 // レンダーターゲットサイズを取得する 00040 RenderingDevice* device = RenderingDevice::getInstance(); 00041 renderTargetSize_.set(device->getRenderTargetSize()); 00042 } 00043 //------------------------------------------------------------------------------ 00044 // デストラクタ 00045 SpriteRenderState::~SpriteRenderState(){ 00046 } 00047 //------------------------------------------------------------------------------ 00048 // 描画 00049 //------------------------------------------------------------------------------ 00050 // リクエスト 00051 void SpriteRenderState::request(SpritePicture* picture, 00052 const Point2f& minPosition, const Point2f& maxPosition, 00053 const TexCoord2& minUV, const TexCoord2& maxUV){ 00054 // ピクチャに変更があればバッファを書き出す 00055 if(picture_ != picture){ 00056 render(); 00057 picture_ = picture; 00058 RenderingDevice* device = RenderingDevice::getInstance(); 00059 if(picture_ == NULL){ 00060 device->setTexture(0, (Direct3DTexture*)NULL); 00061 }else{ 00062 device->setTexture(0, picture_->getD3DTexture()); 00063 } 00064 } 00065 graphicsBuffer_->request(minPosition, maxPosition, minUV, maxUV); 00066 } 00067 //------------------------------------------------------------------------------ 00068 // レンダリング 00069 void SpriteRenderState::render(){ 00070 graphicsBuffer_->render(); 00071 } 00072 //------------------------------------------------------------------------------ 00073 } // End of namespace Lamp 00074 //------------------------------------------------------------------------------