gfxStructs.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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. #ifndef _GFXSTRUCTS_H_
  23. #define _GFXSTRUCTS_H_
  24. #ifndef _COLOR_H_
  25. #include "core/color.h"
  26. #endif
  27. #ifndef _GFXVERTEXCOLOR_H_
  28. #include "gfx/gfxVertexColor.h"
  29. #endif
  30. #ifndef _GFXENUMS_H_
  31. #include "gfx/gfxEnums.h"
  32. #endif
  33. #ifndef _MMATH_H_
  34. #include "math/mMath.h"
  35. #endif
  36. #ifndef _PROFILER_H_
  37. #include "platform/profiler.h"
  38. #endif
  39. #ifndef _GFXRESOURCE_H_
  40. #include "gfx/gfxResource.h"
  41. #endif
  42. #ifndef _REFBASE_H_
  43. #include "core/util/refBase.h"
  44. #endif
  45. #ifndef _GFXVERTEXTYPES_H_
  46. #include "gfx/gfxVertexTypes.h"
  47. #endif
  48. //-----------------------------------------------------------------------------
  49. struct GFXVideoMode
  50. {
  51. GFXVideoMode();
  52. Point2I resolution;
  53. U32 bitDepth;
  54. U32 refreshRate;
  55. bool fullScreen;
  56. bool wideScreen;
  57. // When this is returned from GFX, it's the max, otherwise it's the desired AA level.
  58. U32 antialiasLevel;
  59. inline bool operator == ( const GFXVideoMode &otherMode ) const
  60. {
  61. if( otherMode.fullScreen != fullScreen )
  62. return false;
  63. if( otherMode.resolution != resolution )
  64. return false;
  65. if( otherMode.bitDepth != bitDepth )
  66. return false;
  67. if( otherMode.refreshRate != refreshRate )
  68. return false;
  69. if( otherMode.wideScreen != wideScreen )
  70. return false;
  71. if( otherMode.antialiasLevel != antialiasLevel)
  72. return false;
  73. return true;
  74. }
  75. inline bool operator !=( const GFXVideoMode& otherMode ) const
  76. {
  77. return !( *this == otherMode );
  78. }
  79. /// Fill whatever fields we can from the passed string, which should be
  80. /// of form "width height [bitDepth [refreshRate] [antialiasLevel]]" Unspecified fields
  81. /// aren't modified, so you may want to set defaults before parsing.
  82. void parseFromString( const char *str );
  83. /// Gets a string representation of the object as
  84. /// "resolution.x resolution.y fullScreen bitDepth refreshRate antialiasLevel"
  85. ///
  86. /// \return (string) A string representation of the object.
  87. const String toString() const;
  88. };
  89. //-----------------------------------------------------------------------------
  90. struct GFXPrimitive
  91. {
  92. GFXPrimitiveType type;
  93. U32 startVertex; /// offset into vertex buffer to change where vertex[0] is
  94. U32 minIndex; /// minimal value we will see in the indices
  95. U32 startIndex; /// start of indices in buffer
  96. U32 numPrimitives; /// how many prims to render
  97. U32 numVertices; /// how many vertices... (used for locking, we lock from minIndex to minIndex + numVertices)
  98. GFXPrimitive()
  99. {
  100. type = GFXPT_FIRST;
  101. startVertex = 0;
  102. minIndex = 0;
  103. startIndex = 0;
  104. numPrimitives = 0;
  105. numVertices = 0;
  106. }
  107. };
  108. /// Passed to GFX for shader defines.
  109. struct GFXShaderMacro
  110. {
  111. GFXShaderMacro() {}
  112. GFXShaderMacro( const GFXShaderMacro &macro )
  113. : name( macro.name ),
  114. value( macro.value )
  115. {}
  116. GFXShaderMacro( const String &name_,
  117. const String &value_ = String::EmptyString )
  118. : name( name_ ),
  119. value( value_ )
  120. {}
  121. ~GFXShaderMacro() {}
  122. /// The macro name.
  123. String name;
  124. /// The optional macro value.
  125. String value;
  126. static void stringize( const Vector<GFXShaderMacro> &macros, String *outString );
  127. };
  128. #endif // _GFXSTRUCTS_H_