PVRTPFXParserAPI.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. /******************************************************************************
  2. @File PVRTPFXParserAPI.h
  3. @Title OGLES2/PVRTPFXParserAPI.h
  4. @Version
  5. @Copyright Copyright (C) Imagination Technologies Limited.
  6. @Platform Windows + Linux
  7. @Description Declaration of PFX file parser
  8. ******************************************************************************/
  9. #ifndef _PVRTPFXPARSERAPI_H_
  10. #define _PVRTPFXPARSERAPI_H_
  11. #include "../PVRTError.h"
  12. /****************************************************************************
  13. ** Structures
  14. ****************************************************************************/
  15. /*! Application supplies an array of these so PVRTPFX can translate strings to numbers */
  16. struct SPVRTPFXUniformSemantic
  17. {
  18. const char *p; // String containing semantic
  19. unsigned int n; // Application-defined semantic value
  20. };
  21. /*! PVRTPFX returns an array of these to indicate GL locations & semantics to the application */
  22. struct SPVRTPFXUniform
  23. {
  24. unsigned int nLocation; // GL location of the Uniform
  25. unsigned int nSemantic; // Application-defined semantic value
  26. unsigned int nIdx; // Index; for example two semantics might be LIGHTPOSITION0 and LIGHTPOSITION1
  27. };
  28. /*! An array of these is gained from PVRTPFX so the application can fill in the texture handles*/
  29. struct SPVRTPFXTexture
  30. {
  31. const char *p; // texture FileName
  32. GLuint ui; // Loaded texture handle
  33. };
  34. /*!**************************************************************************
  35. @Class CPVRTPFXEffect
  36. @Brief PFX effect
  37. ****************************************************************************/
  38. class CPVRTPFXEffect
  39. {
  40. public:
  41. SPVRTContext *m_psContext;
  42. CPVRTPFXParser *m_pParser;
  43. unsigned int m_nEffect;
  44. GLuint m_uiProgram; // Loaded program
  45. unsigned int *m_pnTextureIdx; // Array of indices into the texture array
  46. SPVRTPFXTexture *m_psTextures; // Array of loaded textures
  47. public:
  48. /*!***************************************************************************
  49. @Function CPVRTPFXEffect Blank Constructor
  50. @Description Sets the context and initialises the member variables to zero.
  51. *****************************************************************************/
  52. CPVRTPFXEffect();
  53. /*!***************************************************************************
  54. @Function CPVRTPFXEffect Constructor
  55. @Description Sets the context and initialises the member variables to zero.
  56. *****************************************************************************/
  57. CPVRTPFXEffect(SPVRTContext &sContext);
  58. /*!***************************************************************************
  59. @Function CPVRTPFXEffect Destructor
  60. @Description Calls Destroy().
  61. *****************************************************************************/
  62. ~CPVRTPFXEffect();
  63. /*!***************************************************************************
  64. @Function Load
  65. @Input src PFX Parser Object
  66. @Input pszEffect Effect name
  67. @Input pszFileName Effect file name
  68. @Output pReturnError Error string
  69. @Returns EPVRTError PVR_SUCCESS if load succeeded
  70. @Description Loads the specified effect from the CPVRTPFXParser object.
  71. Compiles and links the shaders. Initialises texture data.
  72. *****************************************************************************/
  73. EPVRTError Load(CPVRTPFXParser &src, const char * const pszEffect, const char * const pszFileName, CPVRTString *pReturnError);
  74. /*!***************************************************************************
  75. @Function Destroy
  76. @Description Deletes the gl program object and texture data.
  77. *****************************************************************************/
  78. void Destroy();
  79. /*!***************************************************************************
  80. @Function Activate
  81. @Returns PVR_SUCCESS if activate succeeded
  82. @Description Selects the gl program object and binds the textures.
  83. *****************************************************************************/
  84. EPVRTError Activate();
  85. /*!***************************************************************************
  86. @Function BuildUniformTable
  87. @Output ppsUniforms pointer to uniform data array
  88. @Output pnUniformCount pointer to number of uniforms
  89. @Output pnUnknownUniformCount pointer to number of unknown uniforms
  90. @Input psUniformSemantics pointer to uniform semantic data array
  91. @Input nSemantics number of uniform semantics
  92. @Output pReturnError error string
  93. @Returns EPVRTError PVR_SUCCESS if succeeded
  94. @Description Builds the uniform table from the semantics.
  95. *****************************************************************************/
  96. EPVRTError BuildUniformTable(
  97. SPVRTPFXUniform ** const ppsUniforms,
  98. unsigned int * const pnUniformCount,
  99. unsigned int * const pnUnknownUniformCount,
  100. const SPVRTPFXUniformSemantic * const psUniformSemantics,
  101. const unsigned int nSemantics,
  102. CPVRTString *pReturnError);
  103. /*!***************************************************************************
  104. @Function GetTextureArray
  105. @Output nCount number of textures
  106. @Returns SPVRTPFXTexture* pointer to the texture data array
  107. @Description Gets the texture data array.
  108. *****************************************************************************/
  109. const SPVRTPFXTexture *GetTextureArray(unsigned int &nCount) const;
  110. /*!***************************************************************************
  111. @Function SetTexture
  112. @Input nIdx texture number
  113. @Input ui opengl texture handle
  114. @Input u32flags texture flags
  115. @Description Sets the textrue and applys the filtering.
  116. *****************************************************************************/
  117. void SetTexture(const unsigned int nIdx, const GLuint ui, const unsigned int u32flags=0);
  118. /*!***************************************************************************
  119. @Function SetDefaultSemanticValue
  120. @Input pszName name of uniform
  121. @Input psDefaultValue pointer to default value
  122. @Description Sets the dafault value for the uniform semantic.
  123. *****************************************************************************/
  124. void SetDefaultUniformValue(const char *const pszName, const SPVRTSemanticDefaultData *psDefaultValue);
  125. };
  126. #endif /* _PVRTPFXPARSERAPI_H_ */
  127. /*****************************************************************************
  128. End of file (PVRTPFXParserAPI.h)
  129. *****************************************************************************/