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/DeviceSelector/GraphicsDeviceSelector.h"
00027 #include "Graphics/System/GraphicsDeviceSettings.h"
00028 #include "Graphics/Enumeration/GraphicsDeviceEnumeration.h"
00029
00030 namespace Lamp{
00031
00032
00033
00034 bool GraphicsDeviceSelector::chooseDeviceSettings(
00035 HWND windowHandle, bool startFullscreen){
00036 GraphicsDeviceSettings* settings = GraphicsDeviceSettings::getInstance();
00037 bool foundWindowed = findBestWindowedMode(windowHandle, false, false);
00038 bool foundFullscreen = findBestFullscreenMode(windowHandle, false, false);
00039
00040 settings->setWindowed(true);
00041
00042 if(startFullscreen && foundFullscreen){ settings->setWindowed(false); }
00043
00044 if((!foundWindowed) && foundFullscreen){ settings->setWindowed(false); }
00045
00046 if((!foundWindowed) && (!foundFullscreen)){ return false; }
00047 return true;
00048 }
00049
00050
00051 void GraphicsDeviceSelector::buildWindowModeSettings(
00052 HWND windowHandle, const D3DDISPLAYMODE& displayMode,
00053 GraphicsAdapterInformation* bestAdapter,
00054 GraphicsDeviceInformation* bestDevice,
00055 GraphicsDeviceComboInformation* bestDeviceCombo){
00056
00057 GraphicsDeviceEnumeration* enumeration =
00058 GraphicsDeviceEnumeration::getInstance();
00059 GraphicsDeviceSettings* settings = GraphicsDeviceSettings::getInstance();
00060 settings->setWindowed(true);
00061 settings->setAdapterInformation(bestAdapter);
00062 settings->setDeviceInformation(bestDevice);
00063 settings->setDeviceComboInformation(bestDeviceCombo);
00064 settings->setDisplayMode(displayMode);
00065 if(enumeration->getUsesDepthStencilBuffer()){
00066
00067 settings->setDepthStencilFormat(
00068 bestDeviceCombo->getDepthStencilFormat(0));
00069 }
00070
00071 settings->setMultiSampleType(bestDeviceCombo->getMultiSampleType(0));
00072 settings->setMultiSampleQuality(0);
00073
00074 settings->setVertexProcessingType(
00075 bestDeviceCombo->getVertexProcessingType(0));
00076
00077 settings->setPresentationInterval(
00078 bestDeviceCombo->getPresentationInterval(0));
00079
00080 RECT windowRect;
00081 ::GetClientRect(windowHandle, &windowRect);
00082 DimensionI windowSize(windowRect.right - windowRect.left,
00083 windowRect.bottom - windowRect.top);
00084 settings->setWindowSize(windowSize);
00085
00086 DebugOut("BestWindow %s %s\n%s\n",
00087 bestAdapter->toString().getBytes(),
00088 bestDevice->toString().getBytes(),
00089 bestDeviceCombo->toString().getBytes());
00090 DebugOut("( %d x %d ) %dHz window (%d x %d)\n\n",
00091 displayMode.Width, displayMode.Height,
00092 displayMode.RefreshRate, windowSize.width, windowSize.height);
00093
00094 }
00095
00096
00097 void GraphicsDeviceSelector::buildFullscreenModeSettings(
00098 const D3DDISPLAYMODE& displayMode,
00099 GraphicsAdapterInformation* bestAdapter,
00100 GraphicsDeviceInformation* bestDevice,
00101 GraphicsDeviceComboInformation* bestDeviceCombo){
00102
00103 GraphicsDeviceEnumeration* enumeration =
00104 GraphicsDeviceEnumeration::getInstance();
00105 GraphicsDeviceSettings* settings = GraphicsDeviceSettings::getInstance();
00106 settings->setWindowed(false);
00107 settings->setAdapterInformation(bestAdapter);
00108 settings->setDeviceInformation(bestDevice);
00109 settings->setDeviceComboInformation(bestDeviceCombo);
00110 settings->setDisplayMode(displayMode);
00111 if(enumeration->getUsesDepthStencilBuffer()){
00112
00113 settings->setDepthStencilFormat(
00114 bestDeviceCombo->getDepthStencilFormat(0));
00115 }
00116
00117 settings->setMultiSampleType(bestDeviceCombo->getMultiSampleType(0));
00118 settings->setMultiSampleQuality(0);
00119
00120 settings->setVertexProcessingType(
00121 bestDeviceCombo->getVertexProcessingType(0));
00122
00123 settings->setPresentationInterval(
00124 bestDeviceCombo->getPresentationInterval(0));
00125
00126 DebugOut("BestFullscreen %s %s\n%s\n",
00127 bestAdapter->toString().getBytes(),
00128 bestDevice->toString().getBytes(),
00129 bestDeviceCombo->toString().getBytes());
00130 DebugOut("( %d x %d ) %dHz\n\n",
00131 displayMode.Width, displayMode.Height,
00132 displayMode.RefreshRate);
00133 }
00134
00135 }
00136