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

ColorSpriteState.cpp

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 #include "LampBasic.h"
00026 #include "Graphics2D/SpriteState/ColorSpriteState.h"
00027 #include "Graphics/Renderer/RenderingDevice.h"
00028 
00029 namespace Lamp{
00030 
00031 // 白
00032 const ColorSpriteState ColorSpriteState::whiteState(Color4f(1.f, 1.f, 1.f));
00033 
00034 // 灰色
00035 const ColorSpriteState ColorSpriteState::grayState(Color4f(0.5f, 0.5f, 0.5f));
00036 
00037 // 黒
00038 const ColorSpriteState ColorSpriteState::blackState(Color4f(0.f, 0.f, 0.f));
00039 
00040 // 赤
00041 const ColorSpriteState ColorSpriteState::redState(Color4f(1.f, 0.f, 0.f));
00042 
00043 // 緑
00044 const ColorSpriteState ColorSpriteState::greenState(Color4f(0.f, 1.f, 0.f));
00045 
00046 // 青
00047 const ColorSpriteState ColorSpriteState::blueState(Color4f(0.f, 0.f, 1.f));
00048 
00049 // 黄
00050 const ColorSpriteState ColorSpriteState::yellowState(Color4f(1.f, 1.f, 0.f));
00051 
00052 // 青緑
00053 const ColorSpriteState ColorSpriteState::cyanState(Color4f(0.f, 1.f, 1.f));
00054 
00055 // 赤紫
00056 const ColorSpriteState ColorSpriteState::magentaState(Color4f(1.f, 0.f, 1.f));
00057 
00058 // デフォルト
00059 const ColorSpriteState ColorSpriteState::defaultState(whiteState);
00060 
00061 //------------------------------------------------------------------------------
00062 // コンストラクタ
00063 ColorSpriteState::ColorSpriteState() : color_(Color4f::white){
00064 }
00065 //------------------------------------------------------------------------------
00066 // コンストラクタ
00067 ColorSpriteState::ColorSpriteState(const Color4f& color) : color_(color){
00068 }
00069 //------------------------------------------------------------------------------
00070 // デストラクタ
00071 ColorSpriteState::~ColorSpriteState(){
00072 }
00073 //------------------------------------------------------------------------------
00074 // 描画
00075 //------------------------------------------------------------------------------
00076 // 適用
00077 void ColorSpriteState::apply(SpriteRenderState* renderState){
00078     RenderingDevice* device = RenderingDevice::getInstance();
00079     Color4c color(Color4f(
00080         color_.r * 0.25f, color_.g * 0.25f, color_.b * 0.25f, color_.a));
00081     device->setRenderState(D3DRS_TEXTUREFACTOR, color.getARGB());
00082 }
00083 //------------------------------------------------------------------------------
00084 } // End of namespace Lamp
00085 //------------------------------------------------------------------------------

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