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 #ifndef GRAPHICS_DEVICE_SETTINGS_H_
00026 #define GRAPHICS_DEVICE_SETTINGS_H_
00027
00028 #include <Graphics/Enumeration/GraphicsDeviceComboInformation.h>
00029
00030 namespace Lamp{
00031
00032 class GraphicsAdapterInformation;
00033 class GraphicsDeviceInformation;
00034
00035
00036
00037
00038
00039 class GraphicsDeviceSettings{
00040 public:
00041
00042
00043
00044
00045
00046 static GraphicsDeviceSettings* getInstance(){
00047 Assert(instance_ != NULL);
00048 return instance_;
00049 }
00050
00051
00052
00053
00054
00055 GraphicsDeviceSettings(){
00056 Assert(instance_ == NULL);
00057 instance_ = this;
00058 isWindowed_ = true;
00059
00060 windowedAdapterInformation_ = NULL;
00061 windowedDeviceInformation_ = NULL;
00062 windowedDeviceComboInformation_ = NULL;
00063 windowedDisplayMode_.Width = 0;
00064 windowedDisplayMode_.Height = 0;
00065 windowedDisplayMode_.Format = D3DFMT_UNKNOWN;
00066 windowedDisplayMode_.RefreshRate = 0;
00067 windowedDepthStencilFormat_ = D3DFMT_UNKNOWN;
00068 windowedMultiSampleType_ = D3DMULTISAMPLE_NONE;
00069 windowedMultiSampleQuality_ = 0;
00070 windowedVertexProcessingType_ = VertexProcessingType::software;
00071 windowedPresentationInterval_ = 0;
00072 windowSize_.set(0, 0);
00073
00074 fullscreenAdapterInformation_ = NULL;
00075 fullscreenDeviceInformation_ = NULL;
00076 fullscreenDeviceComboInformation_ = NULL;
00077 fullscreenDisplayMode_.Width = 0;
00078 fullscreenDisplayMode_.Height = 0;
00079 fullscreenDisplayMode_.Format = D3DFMT_UNKNOWN;
00080 fullscreenDisplayMode_.RefreshRate = 0;
00081 fullscreenDepthStencilFormat_ = D3DFMT_UNKNOWN;
00082 fullscreenMultiSampleType_ = D3DMULTISAMPLE_NONE;
00083 fullscreenMultiSampleQuality_ = 0;
00084 fullscreenVertexProcessingType_ = VertexProcessingType::software;
00085 fullscreenPresentationInterval_ = 0;
00086 }
00087
00088
00089
00090
00091 ~GraphicsDeviceSettings(){
00092 Assert(instance_ == this);
00093 instance_ = NULL;
00094 }
00095
00096
00097
00098
00099
00100 virtual void buildPresentationParameters(
00101 D3DPRESENT_PARAMETERS* parameters, HWND windowHandle){
00102
00103 parameters->Windowed = isWindowed();
00104
00105 parameters->hDeviceWindow = windowHandle;
00106
00107 parameters->BackBufferCount = 1;
00108
00109 parameters->MultiSampleType = getMultiSampleType();
00110 parameters->MultiSampleQuality = getMultiSampleQuality();
00111
00112 parameters->SwapEffect = D3DSWAPEFFECT_DISCARD;
00113
00114 bool useDepthBuffer = getDepthStencilEnabled();
00115 parameters->EnableAutoDepthStencil = useDepthBuffer;
00116 parameters->AutoDepthStencilFormat = getDepthStencilFormat();
00117 parameters->Flags = 0;
00118 if(useDepthBuffer){
00119 parameters->Flags |= D3DPRESENTFLAG_DISCARD_DEPTHSTENCIL;
00120 }
00121
00122 DimensionI backBufferSize = getBackBufferSize();
00123 parameters->BackBufferWidth = backBufferSize.width;
00124 parameters->BackBufferHeight = backBufferSize.height;
00125 parameters->BackBufferFormat = getBackBufferFormat();
00126 parameters->PresentationInterval = getPresentationInterval();
00127 if(isWindowed()){
00128 parameters->FullScreen_RefreshRateInHz = 0;
00129 }else{
00130 parameters->FullScreen_RefreshRateInHz =
00131 getDisplayMode().RefreshRate;
00132 }
00133 }
00134
00135
00136
00137
00138
00139
00140 virtual void setWindowed(bool isWindowed){ isWindowed_ = isWindowed; }
00141
00142
00143
00144
00145
00146 virtual bool isWindowed(){ return isWindowed_; }
00147
00148
00149
00150
00151
00152
00153 virtual DimensionI getBackBufferSize(){
00154 DimensionI backBufferSize;
00155 if(isWindowed()){
00156 backBufferSize.set(windowSize_.width, windowSize_.height);
00157 }else{
00158 backBufferSize.set(getDisplayMode().Width, getDisplayMode().Height);
00159 }
00160 return backBufferSize;
00161 }
00162
00163
00164
00165
00166
00167 virtual D3DFORMAT getBackBufferFormat(){
00168 return getDeviceComboInformation()->getBackBufferFormat();
00169 }
00170
00171
00172
00173
00174
00175
00176 virtual void setAdapterInformation(
00177 GraphicsAdapterInformation* adapterInformation){
00178 if(isWindowed_){ windowedAdapterInformation_ = adapterInformation;; }
00179 else{ fullscreenAdapterInformation_ = adapterInformation; }
00180 }
00181
00182
00183
00184
00185
00186 virtual GraphicsAdapterInformation* getAdapterInformation(){
00187 if(isWindowed_){ return windowedAdapterInformation_; }
00188 else{ return fullscreenAdapterInformation_; }
00189 }
00190
00191
00192
00193
00194
00195
00196 virtual void setDeviceInformation(
00197 GraphicsDeviceInformation* deviceInformation){
00198 if(isWindowed_){ windowedDeviceInformation_ = deviceInformation;; }
00199 else{ fullscreenDeviceInformation_ = deviceInformation; }
00200 }
00201
00202
00203
00204
00205
00206 virtual GraphicsDeviceInformation* getDeviceInformation(){
00207 if(isWindowed_){ return windowedDeviceInformation_; }
00208 else{ return fullscreenDeviceInformation_; }
00209 }
00210
00211
00212
00213
00214
00215
00216 virtual void setDeviceComboInformation(
00217 GraphicsDeviceComboInformation* deviceComboInformation){
00218 if(isWindowed_){
00219 windowedDeviceComboInformation_ = deviceComboInformation;
00220 }else{
00221 fullscreenDeviceComboInformation_ = deviceComboInformation;
00222 }
00223 }
00224
00225
00226
00227
00228
00229 virtual GraphicsDeviceComboInformation* getDeviceComboInformation(){
00230 if(isWindowed_){ return windowedDeviceComboInformation_; }
00231 else{ return fullscreenDeviceComboInformation_; }
00232 }
00233
00234
00235
00236
00237
00238
00239 virtual void setDisplayMode(D3DDISPLAYMODE displayMode){
00240 if(isWindowed_){ windowedDisplayMode_ = displayMode; }
00241 else{ fullscreenDisplayMode_ = displayMode; }
00242 }
00243
00244
00245
00246
00247
00248 virtual D3DDISPLAYMODE getDisplayMode(){
00249 if(isWindowed_){ return windowedDisplayMode_; }
00250 else{ return fullscreenDisplayMode_; }
00251 }
00252
00253
00254
00255
00256
00257
00258 virtual bool getDepthStencilEnabled(){
00259 return (getDepthStencilFormat() != D3DFMT_UNKNOWN);
00260 }
00261
00262
00263
00264
00265
00266 virtual void setDepthStencilFormat(D3DFORMAT depthStencilFormat){
00267 if(isWindowed_){ windowedDepthStencilFormat_ = depthStencilFormat; }
00268 else{ fullscreenDepthStencilFormat_ = depthStencilFormat; }
00269 }
00270
00271
00272
00273
00274
00275 virtual D3DFORMAT getDepthStencilFormat(){
00276 if(isWindowed_){ return windowedDepthStencilFormat_; }
00277 else{ return fullscreenDepthStencilFormat_; }
00278 }
00279
00280
00281
00282
00283
00284
00285 virtual void setMultiSampleType(D3DMULTISAMPLE_TYPE multiSampleType){
00286 if(isWindowed_){ windowedMultiSampleType_ = multiSampleType; }
00287 else{ fullscreenMultiSampleType_ = multiSampleType; }
00288 }
00289
00290
00291
00292
00293
00294 virtual D3DMULTISAMPLE_TYPE getMultiSampleType(){
00295 if(isWindowed_){ return windowedMultiSampleType_; }
00296 else{ return fullscreenMultiSampleType_; }
00297 }
00298
00299
00300
00301
00302
00303
00304 virtual void setMultiSampleQuality(u_int multiSampleQuality){
00305 if(isWindowed_){ windowedMultiSampleQuality_ = multiSampleQuality; }
00306 else{ fullscreenMultiSampleQuality_ = multiSampleQuality; }
00307 }
00308
00309
00310
00311
00312
00313 virtual u_int getMultiSampleQuality(){
00314 if(isWindowed_){ return windowedMultiSampleQuality_; }
00315 else{ return fullscreenMultiSampleQuality_; }
00316 }
00317
00318
00319
00320
00321
00322
00323 virtual void setVertexProcessingType(
00324 VertexProcessingType vertexProcessingType){
00325 if(isWindowed_){ windowedVertexProcessingType_ = vertexProcessingType; }
00326 else{ fullscreenVertexProcessingType_ = vertexProcessingType; }
00327 }
00328
00329
00330
00331
00332
00333 virtual VertexProcessingType getVertexProcessingType(){
00334 if(isWindowed_){ return windowedVertexProcessingType_; }
00335 else{ return fullscreenVertexProcessingType_; }
00336 }
00337
00338
00339
00340
00341
00342
00343 virtual void setPresentationInterval(u_int presentationInterval){
00344 if(isWindowed_){ windowedPresentationInterval_ = presentationInterval; }
00345 else{ fullscreenPresentationInterval_ = presentationInterval; }
00346 }
00347
00348
00349
00350
00351
00352 virtual u_int getPresentationInterval(){
00353 if(isWindowed_){ return windowedPresentationInterval_; }
00354 else{ return fullscreenPresentationInterval_; }
00355 }
00356
00357
00358
00359
00360
00361
00362
00363
00364 virtual void setWindowedAdapterInformation(
00365 GraphicsAdapterInformation* adapterInformation){
00366 windowedAdapterInformation_ = adapterInformation;
00367 }
00368
00369
00370
00371
00372
00373 virtual GraphicsAdapterInformation* getWindowedAdapterInformation(){
00374 return windowedAdapterInformation_;
00375 }
00376
00377
00378
00379
00380
00381
00382 virtual void setWindowedDeviceInformation(
00383 GraphicsDeviceInformation* deviceInformation){
00384 windowedDeviceInformation_ = deviceInformation;
00385 }
00386
00387
00388
00389
00390
00391 virtual GraphicsDeviceInformation* getWindowedDeviceInformation(){
00392 return windowedDeviceInformation_;
00393 }
00394
00395
00396
00397
00398
00399
00400 virtual void setWindowedDeviceComboInformation(
00401 GraphicsDeviceComboInformation* deviceComboInformation){
00402 windowedDeviceComboInformation_ = deviceComboInformation;
00403 }
00404
00405
00406
00407
00408
00409 virtual GraphicsDeviceComboInformation* getWindowedDeviceComboInformation(){
00410 return windowedDeviceComboInformation_;
00411 }
00412
00413
00414
00415
00416
00417
00418 virtual void setWindowedDisplayMode(D3DDISPLAYMODE displayMode){
00419 windowedDisplayMode_ = displayMode;
00420 }
00421
00422
00423
00424
00425
00426 virtual D3DDISPLAYMODE getWindowedDisplayMode(){
00427 return windowedDisplayMode_;
00428 }
00429
00430
00431
00432
00433
00434
00435 virtual void setWindowedDepthStencilFormat(D3DFORMAT depthStencilFormat){
00436 windowedDepthStencilFormat_ = depthStencilFormat;
00437 }
00438
00439
00440
00441
00442
00443 virtual D3DFORMAT getWindowedDepthStencilFormat(){
00444 return windowedDepthStencilFormat_;
00445 }
00446
00447
00448
00449
00450
00451
00452 virtual void setWindowedMultiSampleType(
00453 D3DMULTISAMPLE_TYPE multiSampleType){
00454 windowedMultiSampleType_ = multiSampleType;
00455 }
00456
00457
00458
00459
00460
00461 virtual D3DMULTISAMPLE_TYPE getWindowedMultiSampleType(){
00462 return windowedMultiSampleType_;
00463 }
00464
00465
00466
00467
00468
00469
00470 virtual void setWindowedMultiSampleQuality(u_int multiSampleQuality){
00471 windowedMultiSampleQuality_ = multiSampleQuality;
00472 }
00473
00474
00475
00476
00477
00478 virtual u_int getWindowedMultiSampleQuality(){
00479 return windowedMultiSampleQuality_;
00480 }
00481
00482
00483
00484
00485
00486
00487 virtual void setWindowedVertexProcessingType(
00488 VertexProcessingType vertexProcessingType){
00489 windowedVertexProcessingType_ = vertexProcessingType;
00490 }
00491
00492
00493
00494
00495
00496 virtual VertexProcessingType getWindowedVertexProcessingType(){
00497 return windowedVertexProcessingType_;
00498 }
00499
00500
00501
00502
00503
00504
00505 virtual void setWindowedPresentationInterval(u_int presentationInterval){
00506 windowedPresentationInterval_ = presentationInterval;
00507 }
00508
00509
00510
00511
00512
00513 virtual u_int getWindowedPresentationInterval(){
00514 return windowedPresentationInterval_;
00515 }
00516
00517
00518
00519
00520
00521
00522 virtual void setWindowSize(DimensionI size){ windowSize_ = size; }
00523
00524
00525
00526
00527
00528 virtual const DimensionI& getWindowSize(){ return windowSize_; }
00529
00530
00531
00532
00533
00534
00535
00536
00537 virtual void setFullscreenAdapterInformation(
00538 GraphicsAdapterInformation* adapterInformation){
00539 fullscreenAdapterInformation_ = adapterInformation;
00540 }
00541
00542
00543
00544
00545
00546 virtual GraphicsAdapterInformation* getFullscreenAdapterInformation(){
00547 return fullscreenAdapterInformation_;
00548 }
00549
00550
00551
00552
00553
00554
00555 virtual void setFullscreenDeviceInformation(
00556 GraphicsDeviceInformation* deviceInformation){
00557 fullscreenDeviceInformation_ = deviceInformation;
00558 }
00559
00560
00561
00562
00563
00564 virtual GraphicsDeviceInformation* getFullscreenDeviceInformation(){
00565 return fullscreenDeviceInformation_;
00566 }
00567
00568
00569
00570
00571
00572
00573 virtual void setFullscreenDeviceComboInformation(
00574 GraphicsDeviceComboInformation* deviceComboInformation){
00575 fullscreenDeviceComboInformation_ = deviceComboInformation;
00576 }
00577
00578
00579
00580
00581
00582 virtual GraphicsDeviceComboInformation*
00583 getFullscreenDeviceComboInformation(){
00584 return fullscreenDeviceComboInformation_;
00585 }
00586
00587
00588
00589
00590
00591
00592 virtual void setFullscreenDisplayMode(D3DDISPLAYMODE displayMode){
00593 fullscreenDisplayMode_ = displayMode;
00594 }
00595
00596
00597
00598
00599
00600 virtual D3DDISPLAYMODE getFullscreenDisplayMode(){
00601 return fullscreenDisplayMode_;
00602 }
00603
00604
00605
00606
00607
00608
00609 virtual void setFullscreenDepthStencilFormat(D3DFORMAT depthStencilFormat){
00610 fullscreenDepthStencilFormat_ = depthStencilFormat;
00611 }
00612
00613
00614
00615
00616
00617 virtual D3DFORMAT getFullscreenDepthStencilFormat(){
00618 return fullscreenDepthStencilFormat_;
00619 }
00620
00621
00622
00623
00624
00625
00626 virtual void setFullscreenMultiSampleType(
00627 D3DMULTISAMPLE_TYPE multiSampleType){
00628 fullscreenMultiSampleType_ = multiSampleType;
00629 }
00630
00631
00632
00633
00634
00635 virtual D3DMULTISAMPLE_TYPE getFullscreenMultiSampleType(){
00636 return fullscreenMultiSampleType_;
00637 }
00638
00639
00640
00641
00642
00643
00644 virtual void setFullscreenMultiSampleQuality(u_int multiSampleQuality){
00645 fullscreenMultiSampleQuality_ = multiSampleQuality;
00646 }
00647
00648
00649
00650
00651
00652 virtual u_int getFullscreenMultiSampleQuality(){
00653 return fullscreenMultiSampleQuality_;
00654 }
00655
00656
00657
00658
00659
00660
00661 virtual void setFullscreenVertexProcessingType(
00662 VertexProcessingType vertexProcessingType){
00663 fullscreenVertexProcessingType_ = vertexProcessingType;
00664 }
00665
00666
00667
00668
00669
00670 virtual VertexProcessingType getFullscreenVertexProcessingType(){
00671 return fullscreenVertexProcessingType_;
00672 }
00673
00674
00675
00676
00677
00678
00679 virtual void setFullscreenPresentationInterval(u_int presentationInterval){
00680 fullscreenPresentationInterval_ = presentationInterval;
00681 }
00682
00683
00684
00685
00686
00687 virtual u_int getFullscreenPresentationInterval(){
00688 return fullscreenPresentationInterval_;
00689 }
00690
00691 private:
00692
00693 bool isWindowed_;
00694
00695
00696
00697
00698
00699
00700 GraphicsAdapterInformation* windowedAdapterInformation_;
00701
00702 GraphicsDeviceInformation* windowedDeviceInformation_;
00703
00704 GraphicsDeviceComboInformation* windowedDeviceComboInformation_;
00705
00706 D3DDISPLAYMODE windowedDisplayMode_;
00707
00708 D3DFORMAT windowedDepthStencilFormat_;
00709
00710 D3DMULTISAMPLE_TYPE windowedMultiSampleType_;
00711
00712 u_int windowedMultiSampleQuality_;
00713
00714 VertexProcessingType windowedVertexProcessingType_;
00715
00716 u_int windowedPresentationInterval_;
00717
00718 DimensionI windowSize_;
00719
00720
00721
00722
00723
00724
00725 GraphicsAdapterInformation* fullscreenAdapterInformation_;
00726
00727 GraphicsDeviceInformation* fullscreenDeviceInformation_;
00728
00729 GraphicsDeviceComboInformation* fullscreenDeviceComboInformation_;
00730
00731 D3DDISPLAYMODE fullscreenDisplayMode_;
00732
00733 D3DFORMAT fullscreenDepthStencilFormat_;
00734
00735 D3DMULTISAMPLE_TYPE fullscreenMultiSampleType_;
00736
00737 u_int fullscreenMultiSampleQuality_;
00738
00739 VertexProcessingType fullscreenVertexProcessingType_;
00740
00741 u_int fullscreenPresentationInterval_;
00742
00743
00744 static GraphicsDeviceSettings* instance_;
00745
00746 };
00747
00748
00749 }
00750 #endif // End of GRAPHICS_DEVICE_SETTINGS_H_
00751