gfxStructs.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  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. // This class is used to interact with an API's fixed function lights. See GFX->setLight
  50. class GFXLightInfo
  51. {
  52. public:
  53. enum Type {
  54. Point = 0,
  55. Spot = 1,
  56. Vector = 2,
  57. Ambient = 3,
  58. };
  59. Type mType;
  60. Point3F mPos;
  61. VectorF mDirection;
  62. ColorF mColor;
  63. ColorF mAmbient;
  64. F32 mRadius;
  65. F32 mInnerConeAngle;
  66. F32 mOuterConeAngle;
  67. /// @todo Revisit below (currently unused by fixed function lights)
  68. Point3F position;
  69. ColorF ambient;
  70. ColorF diffuse;
  71. ColorF specular;
  72. VectorF spotDirection;
  73. F32 spotExponent;
  74. F32 spotCutoff;
  75. F32 constantAttenuation;
  76. F32 linearAttenuation;
  77. F32 quadraticAttenuation;
  78. };
  79. //-----------------------------------------------------------------------------
  80. // Material definition for FF lighting
  81. struct GFXLightMaterial
  82. {
  83. ColorF ambient;
  84. ColorF diffuse;
  85. ColorF specular;
  86. ColorF emissive;
  87. F32 shininess;
  88. };
  89. //-----------------------------------------------------------------------------
  90. struct GFXVideoMode
  91. {
  92. GFXVideoMode();
  93. Point2I resolution;
  94. U32 bitDepth;
  95. U32 refreshRate;
  96. bool fullScreen;
  97. bool wideScreen;
  98. // When this is returned from GFX, it's the max, otherwise it's the desired AA level.
  99. U32 antialiasLevel;
  100. inline bool operator == ( const GFXVideoMode &otherMode ) const
  101. {
  102. if( otherMode.fullScreen != fullScreen )
  103. return false;
  104. if( otherMode.resolution != resolution )
  105. return false;
  106. if( otherMode.bitDepth != bitDepth )
  107. return false;
  108. if( otherMode.refreshRate != refreshRate )
  109. return false;
  110. if( otherMode.wideScreen != wideScreen )
  111. return false;
  112. if( otherMode.antialiasLevel != antialiasLevel)
  113. return false;
  114. return true;
  115. }
  116. inline bool operator !=( const GFXVideoMode& otherMode ) const
  117. {
  118. return !( *this == otherMode );
  119. }
  120. /// Fill whatever fields we can from the passed string, which should be
  121. /// of form "width height [bitDepth [refreshRate] [antialiasLevel]]" Unspecified fields
  122. /// aren't modified, so you may want to set defaults before parsing.
  123. void parseFromString( const char *str );
  124. /// Gets a string representation of the object as
  125. /// "resolution.x resolution.y fullScreen bitDepth refreshRate antialiasLevel"
  126. ///
  127. /// \return (string) A string representation of the object.
  128. const String toString() const;
  129. };
  130. //-----------------------------------------------------------------------------
  131. struct GFXPrimitive
  132. {
  133. GFXPrimitiveType type;
  134. U32 startVertex; /// offset into vertex buffer to change where vertex[0] is
  135. U32 minIndex; /// minimal value we will see in the indices
  136. U32 startIndex; /// start of indices in buffer
  137. U32 numPrimitives; /// how many prims to render
  138. U32 numVertices; /// how many vertices... (used for locking, we lock from minIndex to minIndex + numVertices)
  139. GFXPrimitive()
  140. {
  141. dMemset( this, 0, sizeof( GFXPrimitive ) );
  142. }
  143. };
  144. /// Passed to GFX for shader defines.
  145. struct GFXShaderMacro
  146. {
  147. GFXShaderMacro() {}
  148. GFXShaderMacro( const GFXShaderMacro &macro )
  149. : name( macro.name ),
  150. value( macro.value )
  151. {}
  152. GFXShaderMacro( const String &name_,
  153. const String &value_ = String::EmptyString )
  154. : name( name_ ),
  155. value( value_ )
  156. {}
  157. ~GFXShaderMacro() {}
  158. /// The macro name.
  159. String name;
  160. /// The optional macro value.
  161. String value;
  162. static void stringize( const Vector<GFXShaderMacro> &macros, String *outString );
  163. };
  164. #endif // _GFXSTRUCTS_H_