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.

157 lines
5.2 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: Defines the interface a given texture for the 3D renderer. Current
  4. // implementations are for world textures (WADTexture.cpp) and sprite
  5. // textures (Texture.cpp).
  6. //
  7. //=============================================================================
  8. #ifndef IEDITORTEXTURE_H
  9. #define IEDITORTEXTURE_H
  10. #pragma once
  11. #include <utlvector.h>
  12. class CDC;
  13. class CPalette;
  14. class IMaterial;
  15. //
  16. // Set your texture ID to this in your implementation's constructor.
  17. //
  18. #define TEXTURE_ID_NONE -1
  19. //
  20. // Texture formats. hack: MUST correlate with radio buttons in IDD_OPTIONS_CONFIGS.
  21. //
  22. enum TEXTUREFORMAT
  23. {
  24. tfNone = -1,
  25. tfWAD = 0,
  26. tfWAL = 1,
  27. tfWAD3 = 2,
  28. tfWAD4 = 3,
  29. tfWAD5 = 4,
  30. tfVMT = 5,
  31. tfSprite = 6 // dvs: not sure if I want to do it this way
  32. };
  33. //
  34. // Flags for DrawTexData_t.
  35. //
  36. #define drawCaption 0x01
  37. #define drawResizeAlways 0x02
  38. #define drawIcons 0x04
  39. #define drawErrors 0x08
  40. #define drawUsageCount 0x10
  41. struct DrawTexData_t
  42. {
  43. int nFlags;
  44. int nUsageCount;
  45. };
  46. class IEditorTexture
  47. {
  48. public:
  49. virtual ~IEditorTexture(void)
  50. {
  51. }
  52. //
  53. // dvs: remove one of these
  54. //
  55. virtual int GetImageWidth( void ) const = 0;
  56. virtual int GetImageHeight( void ) const = 0;
  57. virtual int GetWidth( void ) const = 0;
  58. virtual int GetHeight( void ) const = 0;
  59. virtual float GetDecalScale( void ) const = 0;
  60. //
  61. // dvs: Try to remove as many of these as possible:
  62. //
  63. virtual const char *GetName( void ) const = 0;
  64. virtual int GetShortName( char *szShortName ) const = 0;
  65. virtual int GetKeywords( char *szKeywords ) const = 0;
  66. virtual void Draw(CDC *pDC, RECT &rect, int iFontHeight, int iIconHeight, DrawTexData_t &DrawTexData) = 0;
  67. virtual TEXTUREFORMAT GetTextureFormat( void ) const = 0;
  68. virtual int GetSurfaceAttributes( void ) const = 0;
  69. virtual int GetSurfaceContents(void ) const = 0;
  70. virtual int GetSurfaceValue( void ) const = 0;
  71. virtual CPalette *GetPalette( void ) const = 0;
  72. virtual bool HasData( void ) const = 0;
  73. virtual bool HasPalette( void ) const = 0;
  74. virtual bool Load( void ) = 0; // ensure that texture is loaded. could this be done internally?
  75. virtual void Reload( bool bFullReload ) = 0; // The texture changed. If bFullReload is true, then the material system reloads it too.
  76. virtual bool IsLoaded( void ) const = 0;
  77. virtual const char *GetFileName( void ) const = 0;
  78. virtual bool IsWater( void ) const = 0;
  79. //-----------------------------------------------------------------------------
  80. // Purpose:
  81. // Input : pData -
  82. // Output :
  83. //-----------------------------------------------------------------------------
  84. virtual int GetImageDataRGB( void *pData = NULL ) = 0;
  85. //-----------------------------------------------------------------------------
  86. // Purpose:
  87. // Input : pData -
  88. // Output :
  89. //-----------------------------------------------------------------------------
  90. virtual int GetImageDataRGBA( void *pData = NULL ) = 0;
  91. //-----------------------------------------------------------------------------
  92. // Purpose: Returns true if this texture has an alpha component, false if not.
  93. //-----------------------------------------------------------------------------
  94. virtual bool HasAlpha( void ) const = 0;
  95. //-----------------------------------------------------------------------------
  96. // Purpose: Returns whether this texture is a dummy texture or not. Dummy textures
  97. // serve as placeholders for textures that were found in the map, but
  98. // not in the WAD (or the materials tree). The dummy texture enables us
  99. // to bind the texture, find it by name, etc.
  100. //-----------------------------------------------------------------------------
  101. virtual bool IsDummy( void ) const = 0; // dvs: perhaps not the best name?
  102. //-----------------------------------------------------------------------------
  103. // Purpose: Returns the unique texture ID for this texture object. The texture ID
  104. // identifies the texture object across all renderers, and is assigned
  105. // by the first renderer that actually binds the texture thru BindTexture.
  106. //
  107. // Only the renderer ever needs to call SetTextureID.
  108. //-----------------------------------------------------------------------------
  109. virtual int GetTextureID( void ) const = 0;
  110. //-----------------------------------------------------------------------------
  111. // Purpose: Sets the unique texture ID for this texture object. The texture ID
  112. // identifies the texture object across all renderers, and is assigned
  113. // by the first renderer that actually binds the texture thru BindTexture.
  114. //
  115. // Only the renderer should ever call SetTextureID!
  116. //-----------------------------------------------------------------------------
  117. virtual void SetTextureID( int nTextureID ) = 0;
  118. //-----------------------------------------------------------------------------
  119. // Returns the material system material associated with a texture
  120. //-----------------------------------------------------------------------------
  121. virtual IMaterial* GetMaterial( bool bForceLoad=true ) { return 0; }
  122. };
  123. typedef CUtlVector<IEditorTexture *> EditorTextureList_t;
  124. #endif // IEDITORTEXTURE_H