00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
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
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 }
00134