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

GraphicsDeviceInformation.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 "Graphics/Enumeration/GraphicsDeviceInformation.h"
00027 #include "Graphics/Enumeration/GraphicsDeviceEnumeration.h"
00028 #include "Graphics/System/LampGraphics.h"
00029 #include "Graphics/Primitive/GraphicsBufferFormat.h"
00030 
00031 namespace Lamp{
00032 
00033 //------------------------------------------------------------------------------
00034 // コンストラクタ
00035 GraphicsDeviceInformation::GraphicsDeviceInformation(){
00036 }
00037 //------------------------------------------------------------------------------
00038 // デストラクタ
00039 GraphicsDeviceInformation::~GraphicsDeviceInformation(){
00040     // デバイスコンボの削除
00041     for(int i = getDeviceComboCount() - 1; i >= 0; i--){
00042         delete getDeviceCombo(i);
00043     }
00044 }
00045 //------------------------------------------------------------------------------
00046 // 列挙
00047 bool GraphicsDeviceInformation::enumerate(
00048     GraphicsDeviceEnumeration* enumeration,
00049     GraphicsAdapterInformation* adapterInformation, D3DDEVTYPE deviceType){
00050     // メンバの設定
00051     adapterOrdinal_ = adapterInformation->getAdapterOrdinal();
00052     deviceType_ = deviceType;
00053     // デバイス能力の取得
00054     Direct3D* direct3D = LampGraphics::getDirect3D();
00055     if(DirectXFailed(direct3D->GetDeviceCaps(
00056         adapterOrdinal_, deviceType_, &deviceCapability_))){
00057         return false;
00058     }
00059     // NULLリファレンスドライバは無視する
00060     if((deviceCapability_.PrimitiveMiscCaps & D3DPMISCCAPS_NULLREFERENCE) != 0){
00061         return false;
00062     }
00063 
00064     // デバイスコンボの列挙
00065     // 全バックバッファフォーマット
00066     const D3DFORMAT backBufferFormats[] = {
00067         D3DFMT_A8R8G8B8,
00068         D3DFMT_X8R8G8B8,
00069         D3DFMT_A2R10G10B10,
00070         D3DFMT_R5G6B5,
00071         D3DFMT_A1R5G5B5,
00072         D3DFMT_X1R5G5B5};
00073     const u_int backBufferFormatsCount =
00074         sizeof(backBufferFormats) / sizeof(backBufferFormats[0]);
00075     const bool isWindowedFlags[] = { false, true };
00076     // アダプタフォーマットループ
00077     int adapterFormatCount = adapterInformation->getAdapterFormatCount();
00078     for(int i = 0; i < adapterFormatCount; i++){
00079         D3DFORMAT adapterFormat = adapterInformation->getAdapterFormat(i);
00080         // バックバッファフォーマットループ
00081         for(int j = 0; j < backBufferFormatsCount; j++){
00082             D3DFORMAT backBufferFormat = backBufferFormats[j];
00083             GraphicsBufferFormat bufferFormat(backBufferFormat);
00084             // バックバッファのアルファビットのチェック
00085             if(bufferFormat.getAlphaChannelBits() <
00086                 enumeration->getMinimumBackBufferAlphaChannelBits()){
00087                 continue;
00088             }
00089             // フルスクリーン、ウィンドウループ
00090             for(u_int k = 0; k < 2; k++){
00091                 bool isWindowed = isWindowedFlags[k];
00092                 // ウィンドウモードのチェック
00093                 if((!isWindowed) && enumeration->getRequiresWindowMode()){
00094                     continue;
00095                 }
00096                 if(isWindowed && enumeration->getRequiresFullscreenMode()){
00097                     continue;
00098                 }
00099                 // デバイスタイプチェック
00100                 if(DirectXFailed(direct3D->CheckDeviceType(
00101                     adapterOrdinal_, deviceType_,
00102                     adapterFormat, backBufferFormat, isWindowed))){
00103                     continue;
00104                 }
00105                 // デバイスコンボの作成
00106                 GraphicsDeviceComboInformation* deviceCombo =
00107                     new GraphicsDeviceComboInformation(
00108                     adapterFormat, backBufferFormat, isWindowed);
00109                 if(!deviceCombo->enumerate(enumeration, this)){
00110                     delete deviceCombo;
00111                     continue;
00112                 }
00113                 deviceCombos_.add(deviceCombo);
00114             }
00115         }
00116     }
00117     return true;
00118 }
00119 //------------------------------------------------------------------------------
00120 // 文字列への変換
00121 String GraphicsDeviceInformation::toString(){
00122     String result;
00123     if(deviceType_ == D3DDEVTYPE_HAL){
00124         result = "D3DDEVTYPE_HAL";
00125     }else if(deviceType_ == D3DDEVTYPE_REF){
00126         result = "D3DDEVTYPE_REF";
00127     }else if(deviceType_ == D3DDEVTYPE_SW){
00128         result = "D3DDEVTYPE_SW";
00129     }
00130     return result;
00131 }
00132 //------------------------------------------------------------------------------
00133 } // End of namespace Lamp
00134 //------------------------------------------------------------------------------

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