ilttexmod.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. // The ILTTexMod interface allows the game to modify textures and bump maps in realtime.
  2. #ifndef __ILTTEXMOD_H__
  3. #define __ILTTEXMOD_H__
  4. #include "ltpvalue.h"
  5. // Color data is always loaded into memory, but you can have a bumpmap loaded as well.
  6. #define THANDLE_BUMPMAP (1<<0)
  7. #define TLOCK_TEXTURE 0 // If this is used, then the data is in PValue format.
  8. #define TLOCK_BUMPMAP 1 // If this is used, then the data is a DBYTE heightmap.
  9. class TextureInfo
  10. {
  11. public:
  12. uint32 m_Width;
  13. uint32 m_Height;
  14. };
  15. class SharedTexture;
  16. typedef SharedTexture* HTEXTURE;
  17. // Texture-modification interface.
  18. class ILTTexMod
  19. {
  20. public:
  21. // Use these to get and release texture handles.
  22. // The first time you get a texture handle, it will allocate space for the texture and/or
  23. // the bumpmap, based on the flags you specify. If you need to specify different flags,
  24. // you must release ALL texture handles and get a new one.
  25. // When all texture handles for a texture are released, the texture goes back to its
  26. // original form (from its disk file).
  27. virtual LTRESULT GetTextureHandle(
  28. char *pFilename,
  29. HTEXTURE &hTexture,
  30. const uint32 flags // Combination of the THANDLE_ flags.
  31. )=0;
  32. virtual LTRESULT ReleaseTextureHandle(const HTEXTURE hTexture)=0;
  33. // Get info about a texture.
  34. virtual LTRESULT GetTextureInfo(const HTEXTURE hTexture, TextureInfo &info)=0;
  35. // Returns LT_YES if the texture was drawn in the last Render call and LT_NO otherwise.
  36. // (Or LT_INVALIDPARAMS if the texture handle is invalid).
  37. // This should be called before you ever update a texture's contents. If it returns
  38. // LT_NO, then you don't need to update the texture because it's not being viewed.
  39. virtual LTRESULT WasTextureDrawnLastFrame(const HTEXTURE hTexture)=0;
  40. // The texture lock returns a uint8 pointer to the data because you should iterate over
  41. // the texture's lines like this:
  42. // uint8 *pLines;
  43. // if(pInterface->LockTexture(hTexture, &rect, lockFlags, pLines, lPitch) == LT_OK)
  44. // {
  45. // height = rect.bottom - rect.top;
  46. // while(height--)
  47. // {
  48. // pRealData = (cast pLines to a PValue or DBYTE and fill the line)
  49. // pLines += lPitch;
  50. // }
  51. //
  52. // pInterface->UnlockTexture(hTexture);
  53. // }
  54. virtual LTRESULT LockTexture(
  55. const HTEXTURE hTexture, // Texture handle.
  56. const LTRect *pRect, // Rect to lock (NULL for the whole texture).
  57. const uint32 lockType, // Must be one of the TLOCK_ defs.
  58. uint8* &pData, // Data (format depends on TLOCK_ flags).
  59. long &lPitch // Pitch in bytes.
  60. )=0;
  61. // Once you unlock the texture, the engine converts the data to the renderer's format.
  62. // It also automatically updates the texture's mipmaps (if any). Ideally, textures
  63. // that you're updating in realtime won't have mipmaps.
  64. virtual LTRESULT UnlockTexture(const HTEXTURE hTexture)=0;
  65. };
  66. #endif // __ILTTEXMOD_H__