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

# AddressModeSpriteState.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/AddressModeSpriteState.h"
    00027 #include "Graphics/Renderer/RenderingDevice.h"
    00028
    00029 namespace Lamp{
    00030
    00031 // クランプ
    00032 const AddressModeSpriteState AddressModeSpriteState::clampState(
    00033     addressModeClamp, addressModeClamp);
    00034
    00035 // ラップ
    00036 const AddressModeSpriteState AddressModeSpriteState::wrapState(
    00037     addressModeWrap, addressModeWrap);
    00038
    00039 // ミラー
    00040 const AddressModeSpriteState AddressModeSpriteState::mirrorState(
    00041     addressModeMirror, addressModeMirror);
    00042
    00043 // デフォルト
    00044 const AddressModeSpriteState AddressModeSpriteState::defaultState(clampState);
    00045
    00046 // アドレスモード文字列テーブル
    00047 const String AddressModeSpriteState::addressModeStringTable[] = {
    00048     "Wrap",
    00049     "Clamp",
    00050     "Mirror",
    00051 };
    00052
    00053 //------------------------------------------------------------------------------
    00054 // コンストラクタ
    00055 AddressModeSpriteState::AddressModeSpriteState() :
    00056     addressModeU_(addressModeClamp), addressModeV_(addressModeClamp){
    00057 }
    00058 //------------------------------------------------------------------------------
    00059 // コンストラクタ
    00060 AddressModeSpriteState::AddressModeSpriteState(
    00061     AddressMode addressModeU, AddressMode addressModeV) :
    00062     addressModeU_(addressModeU), addressModeV_(addressModeV){
    00063     Assert((addressModeU_ >= 0) && (addressModeU_ < addressModeMax));
    00064     Assert((addressModeV_ >= 0) && (addressModeV_ < addressModeMax));
    00065 }
    00066 //------------------------------------------------------------------------------
    00067 // デストラクタ
    00068 AddressModeSpriteState::~AddressModeSpriteState(){
    00069 }
    00070 //------------------------------------------------------------------------------
    00071 // 描画
    00072 //------------------------------------------------------------------------------
    00073 // 適用
    00074 void AddressModeSpriteState::apply(SpriteRenderState* renderState){
    00075     RenderingDevice* device = RenderingDevice::getInstance();
    00076     device->setTextureAddressMode2(0, addressModeU_, addressModeV_);
    00077 }
    00078 //------------------------------------------------------------------------------
    00079 // アドレスモード
    00080 //------------------------------------------------------------------------------
    00081 // アドレスモードから文字列への変換
    00082 const String& AddressModeSpriteState::addressModeToString(
    00083     AddressMode addressMode){
    00084     Assert((addressMode >= 0) && (addressMode < addressModeMax));
    00085     return addressModeStringTable[addressMode];
    00086 }
    00087 //------------------------------------------------------------------------------
    00088 // 文字列からアドレスモードへの変換
    00089 AddressModeSpriteState::AddressMode
    00090     AddressModeSpriteState::addressModeFromString(
    00091     const String& addressModeString){
    00092     for(int i = 0; i < addressModeMax; i++){
    00093         if(addressModeStringTable[i].equals(addressModeString)){
    00094             return AddressMode(i);
    00095         }
    00096     }
    00097     ErrorOut("AddressModeSpriteState::addressModeFromString() " +
    00098         addressModeString);
    00099     return addressModeMax;
    00100 }
    00101 //------------------------------------------------------------------------------
    00102 } // End of namespace Lamp
    00103 //------------------------------------------------------------------------------