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 "Graphics/Enumeration/GraphicsDeviceEnumeration.h" 00027 #include "Graphics/System/LampGraphics.h" 00028 00029 namespace Lamp{ 00030 00031 // インスタンス 00032 GraphicsDeviceEnumeration* GraphicsDeviceEnumeration::instance_ = NULL; 00033 00034 //------------------------------------------------------------------------------ 00035 // コンストラクタ 00036 GraphicsDeviceEnumeration::GraphicsDeviceEnumeration(){ 00037 Assert(instance_ == NULL); 00038 instance_ = this; 00039 enumerated_ = false; 00040 // デフォルトの許可フォーマット 00041 addAllowedFormat(D3DFMT_X8R8G8B8); 00042 addAllowedFormat(D3DFMT_X1R5G5B5); 00043 addAllowedFormat(D3DFMT_R5G6B5); 00044 addAllowedFormat(D3DFMT_A2R10G10B10); 00045 // 空のグラフィックスデバイス確認設定 00046 setConfirmGraphicsDevice(this); 00047 // 最小フルスクリーンサイズ 00048 setMinimumFullscreenWidth(640); 00049 setMinimumFullscreenHeight(480); 00050 // 最小ビット深度 00051 setMinimumAdapterColorChannelBits(5); 00052 setMinimumBackBufferAlphaChannelBits(0); 00053 setMinimumDepthBits(15); 00054 setMinimumStencilBits(0); 00055 // 画面モードの必要性 00056 setRequiresWindowMode(false); 00057 setRequiresFullscreenMode(false); 00058 // 深度、ステンシルバッファを使用する 00059 setUsesDepthStencilBuffer(true); 00060 // 混合頂点演算を使用しない 00061 setUsesMixedVertexProcessing(false); 00062 } 00063 //------------------------------------------------------------------------------ 00064 // デストラクタ 00065 GraphicsDeviceEnumeration::~GraphicsDeviceEnumeration(){ 00066 // アダプタの削除 00067 for(int i = getAdapterCount() - 1; i >= 0; i--){ 00068 delete getAdapter(i); 00069 } 00070 Assert(instance_ == this); 00071 instance_ = NULL; 00072 } 00073 //------------------------------------------------------------------------------ 00074 // 列挙 00075 bool GraphicsDeviceEnumeration::enumerate(){ 00076 if(enumerated_){ return true; } 00077 Direct3D* direct3D = LampGraphics::getDirect3D(); 00078 u_int adapterCount = direct3D->GetAdapterCount(); 00079 for(u_int i = 0; i < adapterCount; i++){ 00080 GraphicsAdapterInformation* adapter = new GraphicsAdapterInformation(i); 00081 adapter->enumerate(this); 00082 // アダプタに含まれるデバイスが0なら削除 00083 if(adapter->getDeviceCount() == 0){ 00084 delete adapter; 00085 continue; 00086 } 00087 adapters_.add(adapter); 00088 } 00089 enumerated_ = true; 00090 return true; 00091 } 00092 //------------------------------------------------------------------------------ 00093 } // End of namespace Lamp 00094 //------------------------------------------------------------------------------