Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123 lines
3.7 KiB

  1. #ifndef NVTRISTRIP_H
  2. #define NVTRISTRIP_H
  3. #ifndef NULL
  4. #define NULL 0
  5. #endif
  6. #pragma comment(lib, "nvtristrip")
  7. ////////////////////////////////////////////////////////////////////////////////////////
  8. // Public interface for stripifier
  9. ////////////////////////////////////////////////////////////////////////////////////////
  10. //GeForce1 and 2 cache size
  11. #define CACHESIZE_GEFORCE1_2 16
  12. //GeForce3 cache size
  13. #define CACHESIZE_GEFORCE3 24
  14. enum PrimType
  15. {
  16. PT_LIST,
  17. PT_STRIP,
  18. PT_FAN
  19. };
  20. struct PrimitiveGroup
  21. {
  22. PrimType type;
  23. unsigned int numIndices;
  24. unsigned short* indices;
  25. ////////////////////////////////////////////////////////////////////////////////////////
  26. PrimitiveGroup() : type(PT_STRIP), numIndices(0), indices(NULL) {}
  27. ~PrimitiveGroup()
  28. {
  29. if(indices)
  30. delete[] indices;
  31. indices = NULL;
  32. }
  33. };
  34. ////////////////////////////////////////////////////////////////////////////////////////
  35. // SetCacheSize()
  36. //
  37. // Sets the cache size which the stripfier uses to optimize the data.
  38. // Controls the length of the generated individual strips.
  39. // This is the "actual" cache size, so 24 for GeForce3 and 16 for GeForce1/2
  40. // You may want to play around with this number to tweak performance.
  41. //
  42. // Default value: 16
  43. //
  44. void SetCacheSize(const unsigned int cacheSize);
  45. ////////////////////////////////////////////////////////////////////////////////////////
  46. // SetStitchStrips()
  47. //
  48. // bool to indicate whether to stitch together strips into one huge strip or not.
  49. // If set to true, you'll get back one huge strip stitched together using degenerate
  50. // triangles.
  51. // If set to false, you'll get back a large number of separate strips.
  52. //
  53. // Default value: true
  54. //
  55. void SetStitchStrips(const bool bStitchStrips);
  56. ////////////////////////////////////////////////////////////////////////////////////////
  57. // SetMinStripSize()
  58. //
  59. // Sets the minimum acceptable size for a strip, in triangles.
  60. // All strips generated which are shorter than this will be thrown into one big, separate list.
  61. //
  62. // Default value: 0
  63. //
  64. void SetMinStripSize(const unsigned int minSize);
  65. ////////////////////////////////////////////////////////////////////////////////////////
  66. // SetListsOnly()
  67. //
  68. // If set to true, will return an optimized list, with no strips at all.
  69. //
  70. // Default value: false
  71. //
  72. void SetListsOnly(const bool bListsOnly);
  73. ////////////////////////////////////////////////////////////////////////////////////////
  74. // GenerateStrips()
  75. //
  76. // in_indices: input index list, the indices you would use to render
  77. // in_numIndices: number of entries in in_indices
  78. // primGroups: array of optimized/stripified PrimitiveGroups
  79. // numGroups: number of groups returned
  80. //
  81. // Be sure to call delete[] on the returned primGroups to avoid leaking mem
  82. //
  83. void GenerateStrips(const unsigned short* in_indices, const unsigned int in_numIndices,
  84. PrimitiveGroup** primGroups, unsigned short* numGroups);
  85. ////////////////////////////////////////////////////////////////////////////////////////
  86. // RemapIndices()
  87. //
  88. // Function to remap your indices to improve spatial locality in your vertex buffer.
  89. //
  90. // in_primGroups: array of PrimitiveGroups you want remapped
  91. // numGroups: number of entries in in_primGroups
  92. // numVerts: number of vertices in your vertex buffer, also can be thought of as the range
  93. // of acceptable values for indices in your primitive groups.
  94. // remappedGroups: array of remapped PrimitiveGroups
  95. //
  96. // Note that, according to the remapping handed back to you, you must reorder your
  97. // vertex buffer.
  98. //
  99. // Credit goes to the MS Xbox crew for the idea for this interface.
  100. //
  101. void RemapIndices(const PrimitiveGroup* in_primGroups, const unsigned short numGroups,
  102. const unsigned short numVerts, PrimitiveGroup** remappedGroups);
  103. #endif