texmgr.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /*
  2. LICENSE
  3. -------
  4. Copyright 2005-2013 Nullsoft, Inc.
  5. All rights reserved.
  6. Redistribution and use in source and binary forms, with or without modification,
  7. are permitted provided that the following conditions are met:
  8. * Redistributions of source code must retain the above copyright notice,
  9. this list of conditions and the following disclaimer.
  10. * Redistributions in binary form must reproduce the above copyright notice,
  11. this list of conditions and the following disclaimer in the documentation
  12. and/or other materials provided with the distribution.
  13. * Neither the name of Nullsoft nor the names of its contributors may be used to
  14. endorse or promote products derived from this software without specific prior written permission.
  15. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
  16. IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  17. FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
  18. CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  19. DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  20. DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
  21. IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  22. OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  23. */
  24. #ifndef GEISS_TEXTURE_MANAGER
  25. #define GEISS_TEXTURE_MANAGER 1
  26. #define NUM_TEX 16
  27. #ifdef _DEBUG
  28. #define D3D_DEBUG_INFO // declare this before including d3d9.h
  29. #endif
  30. #include <d3d9.h>
  31. #include "ns-eel2/ns-eel.h"
  32. #include "md_defines.h"
  33. #define TEXMGR_ERROR_MASK 0x0F
  34. #define TEXMGR_ERR_SUCCESS 0
  35. #define TEXMGR_ERR_BAD_INDEX 1
  36. /*
  37. #define TEXMGR_ERR_OPENING 2
  38. #define TEXMGR_ERR_IMAGE_NOT_24_BIT 3
  39. #define TEXMGR_ERR_IMAGE_TOO_LARGE 4
  40. #define TEXMGR_ERR_CREATESURFACE_FAILED 5
  41. #define TEXMGR_ERR_LOCKSURFACE_FAILED 6
  42. #define TEXMGR_ERR_CORRUPT_JPEG 7
  43. */
  44. #define TEXMGR_ERR_FORMAT 8
  45. #define TEXMGR_ERR_BADFILE 9
  46. #define TEXMGR_ERR_OUTOFMEM 10
  47. #define TEXMGR_WARNING_MASK 0xF0
  48. #define TEXMGR_WARN_ERROR_IN_INIT_CODE 0x10
  49. #define TEXMGR_WARN_ERROR_IN_REG_CODE 0x20
  50. typedef struct
  51. {
  52. LPDIRECT3DTEXTURE9 pSurface;
  53. int img_w, img_h;
  54. /*
  55. int tex_w, tex_h;
  56. float scale_x, scale_y; // the factors by which the original image was squished to become (img_w x img_h) texels in size.
  57. DDPIXELFORMAT ddpf;
  58. */
  59. wchar_t szFileName[512];
  60. float fStartTime;
  61. int nStartFrame;
  62. int nUserData;
  63. // stuff for expressions:
  64. char m_szExpr[8192]; // for expression eval
  65. NSEEL_CODEHANDLE m_codehandle; // for expression eval
  66. // input variables for expression eval
  67. double *var_time, *var_frame, *var_fps, *var_progress;
  68. double *var_bass, *var_bass_att, *var_mid, *var_mid_att, *var_treb, *var_treb_att;
  69. // output variables for expression eval
  70. double *var_x, *var_y;
  71. double *var_sx, *var_sy, *var_rot, *var_flipx, *var_flipy;
  72. double *var_r, *var_g, *var_b, *var_a;
  73. double *var_blendmode;
  74. double *var_repeatx, *var_repeaty;
  75. double *var_done, *var_burn;
  76. NSEEL_VMCTX tex_eel_ctx;
  77. }
  78. td_tex;
  79. class texmgr
  80. {
  81. public:
  82. texmgr();
  83. ~texmgr();
  84. // members
  85. void Init(LPDIRECT3DDEVICE9 lpDD); // DirectDraw object
  86. int LoadTex(wchar_t *szFilename, int iSlot, char *szInitCode, char *szCode, float time, int frame, unsigned int ck);
  87. void KillTex(int iSlot);
  88. void Finish();
  89. // data
  90. td_tex m_tex[NUM_TEX];
  91. protected:
  92. // members
  93. //bool TryCreateDDrawSurface(int iSlot, int w, int h);
  94. void FreeVars(int iSlot);
  95. void FreeCode(int iSlot);
  96. void RegisterBuiltInVariables(int iSlot);
  97. bool RunInitCode(int iSlot, char *szInitCode);
  98. bool RecompileExpressions(int iSlot);
  99. void StripLinefeedCharsAndComments(char *src, char *dest);
  100. // data
  101. LPDIRECT3DDEVICE9 m_lpDD;
  102. };
  103. #endif