gfxD3D9Device.regen-states.cpp 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2012 GarageGames, LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to
  6. // deal in the Software without restriction, including without limitation the
  7. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8. // sell copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  20. // IN THE SOFTWARE.
  21. //-----------------------------------------------------------------------------
  22. #include "gfx/D3D9/gfxD3D9Device.h"
  23. #include "console/console.h"
  24. #include "gfx/D3D9/gfxD3D9EnumTranslate.h"
  25. // Cut and paste from console.log into GFXD3D9Device::initStates()
  26. void GFXD3D9Device::regenStates()
  27. {
  28. DWORD temp;
  29. Con::printf( " //-------------------------------------" );
  30. Con::printf( " // Auto-generated default states, see regenStates() for details" );
  31. Con::printf( " //" );
  32. Con::printf( "" );
  33. Con::printf( " // Render states" );
  34. for( U32 state = GFXRenderState_FIRST; state < GFXRenderState_COUNT; state++ )
  35. {
  36. if( GFXD3D9RenderState[state] == GFX_UNSUPPORTED_VAL )
  37. continue;
  38. temp = 0;
  39. mD3DDevice->GetRenderState( GFXD3D9RenderState[state], &temp );
  40. Con::printf( " mD3DDevice->SetRenderState( GFXD3D9RenderState[%d], %d );", state, temp );
  41. }
  42. #ifndef TORQUE_OS_XENON
  43. Con::printf( "" );
  44. Con::printf( " // Texture Stage states" );
  45. for( U32 stage = 0; stage < TEXTURE_STAGE_COUNT; stage++ )
  46. {
  47. if( stage >= GFX->getNumSamplers() )
  48. {
  49. Con::errorf( "Sampler %d out of range for this device, ignoring.", stage );
  50. break;
  51. }
  52. for( U32 state = GFXTSS_FIRST; state < GFXTSS_COUNT; state++ )
  53. {
  54. if( GFXD3D9TextureStageState[state] == GFX_UNSUPPORTED_VAL )
  55. continue;
  56. temp = 0;
  57. mD3DDevice->GetTextureStageState( stage, GFXD3D9TextureStageState[state], &temp );
  58. Con::printf( " mD3DDevice->SetTextureStageState( %d, GFXD3D9TextureStageState[%d], %d );", stage, state, temp );
  59. }
  60. }
  61. #endif
  62. Con::printf( "" );
  63. Con::printf( " // Sampler states" );
  64. for( U32 stage = 0; stage < TEXTURE_STAGE_COUNT; stage++ )
  65. {
  66. if( stage >= GFX->getNumSamplers() )
  67. {
  68. Con::errorf( "Sampler %d out of range for this device, ignoring.", stage );
  69. break;
  70. }
  71. for( U32 state = GFXSAMP_FIRST; state < GFXSAMP_COUNT; state++ )
  72. {
  73. if( GFXD3D9SamplerState[state] == GFX_UNSUPPORTED_VAL )
  74. continue;
  75. temp = 0;
  76. mD3DDevice->GetSamplerState( stage, GFXD3D9SamplerState[state], &temp );
  77. Con::printf( " mD3DDevice->SetSamplerState( %d, GFXD3D9SamplerState[%d], %d );", stage, state, temp );
  78. }
  79. }
  80. }