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.

122 lines
5.3 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: An extra interface implemented by the material system
  4. // implementation of vgui::ISurface
  5. //
  6. // $Revision: $
  7. // $NoKeywords: $
  8. //===========================================================================//
  9. #ifndef IMATSYSTEMSURFACE_H
  10. #define IMATSYSTEMSURFACE_H
  11. #ifdef _WIN32
  12. #pragma once
  13. #endif
  14. #include <vgui/VGUI.h>
  15. #include "vgui/ISurface.h"
  16. //-----------------------------------------------------------------------------
  17. // Forward declarations
  18. //-----------------------------------------------------------------------------
  19. class VMatrix;
  20. class IMaterial;
  21. struct InputEvent_t;
  22. //-----------------------------------------------------------------------------
  23. // Callbacks for mouse getting + setting
  24. //-----------------------------------------------------------------------------
  25. typedef void (*GetMouseCallback_t)(int &x, int &y);
  26. typedef void (*SetMouseCallback_t)(int x, int y);
  27. //-----------------------------------------------------------------------------
  28. // Callbacks for sound playing
  29. //-----------------------------------------------------------------------------
  30. typedef void (*PlaySoundFunc_t)(const char *pFileName);
  31. //-----------------------------------------------------------------------------
  32. //
  33. // An extra interface implemented by the material system implementation of vgui::ISurface
  34. //
  35. //-----------------------------------------------------------------------------
  36. #define MAT_SYSTEM_SURFACE_INTERFACE_VERSION "MatSystemSurface008"
  37. class IMatSystemSurface : public vgui::ISurface
  38. {
  39. public:
  40. // Hook needed to get input to work.
  41. // If the app drives the input (like the engine needs to do for VCR mode),
  42. // it can set bLetAppDriveInput to true and call HandleInputEvent for the input events.
  43. virtual void AttachToWindow( void *hwnd, bool bLetAppDriveInput=false ) = 0;
  44. // Tells the surface to ignore windows messages
  45. virtual void EnableWindowsMessages( bool bEnable ) = 0;
  46. // Starts, ends 3D painting
  47. // NOTE: These methods should only be called from within the paint()
  48. // method of a panel.
  49. virtual void Begin3DPaint( int iLeft, int iTop, int iRight, int iBottom, bool bRenderToTexture = true ) = 0;
  50. virtual void End3DPaint() = 0;
  51. // NOTE: This also should only be called from within the paint()
  52. // method of a panel. Use it to disable clipping for the rendering
  53. // of this panel.
  54. virtual void DisableClipping( bool bDisable ) = 0;
  55. virtual void GetClippingRect( int &left, int &top, int &right, int &bottom, bool &bClippingDisabled ) = 0; // <<<<< NOTE: output flag is *disabled* state, not enabled, to match the rest of the interface
  56. virtual void SetClippingRect( int left, int top, int right, int bottom ) = 0;
  57. // Prevents vgui from changing the cursor
  58. virtual bool IsCursorLocked() const = 0;
  59. // Sets the mouse get + set callbacks
  60. virtual void SetMouseCallbacks( GetMouseCallback_t getFunc, SetMouseCallback_t setFunc ) = 0;
  61. // Installs a function to play sounds
  62. virtual void InstallPlaySoundFunc( PlaySoundFunc_t soundFunc ) = 0;
  63. // Some drawing methods that cannot be accomplished under Win32
  64. virtual void DrawColoredCircle( int centerx, int centery, float radius, int r, int g, int b, int a ) = 0;
  65. virtual int DrawColoredText( vgui::HFont font, int x, int y, int r, int g, int b, int a, PRINTF_FORMAT_STRING const char *fmt, ... ) = 0;
  66. // Draws text with current font at position and wordwrapped to the rect using color values specified
  67. virtual void DrawColoredTextRect( vgui::HFont font, int x, int y, int w, int h, int r, int g, int b, int a, PRINTF_FORMAT_STRING const char *fmt, ... ) = 0;
  68. virtual void DrawTextHeight( vgui::HFont font, int w, int& h, PRINTF_FORMAT_STRING const char *fmt, ... ) = 0;
  69. // Returns the length of the text string in pixels
  70. virtual int DrawTextLen( vgui::HFont font, PRINTF_FORMAT_STRING const char *fmt, ... ) = 0;
  71. // Draws a panel in 3D space. Assumes view + projection are already set up
  72. // Also assumes the (x,y) coordinates of the panels are defined in 640xN coords
  73. // (N isn't necessary 480 because the panel may not be 4x3)
  74. // The width + height specified are the size of the panel in world coordinates
  75. virtual void DrawPanelIn3DSpace( vgui::VPANEL pRootPanel, const VMatrix &panelCenterToWorld, int nPixelWidth, int nPixelHeight, float flWorldWidth, float flWorldHeight ) = 0;
  76. // Binds a material to a surface texture ID
  77. virtual void DrawSetTextureMaterial( int id, IMaterial *pMaterial ) = 0;
  78. // Handles an input event, returns true if the event should be filtered from the rest of the game
  79. virtual bool HandleInputEvent( const InputEvent_t &event ) = 0;
  80. virtual void Set3DPaintTempRenderTarget( const char *pRenderTargetName ) = 0;
  81. virtual void Reset3DPaintTempRenderTarget( void ) = 0;
  82. // Gets a material bound to a surface texture ID
  83. virtual IMaterial *DrawGetTextureMaterial( int id ) = 0;
  84. virtual void GetFullscreenViewportAndRenderTarget( int & x, int & y, int & w, int & h, ITexture **ppRenderTarget ) = 0;
  85. virtual void SetFullscreenViewportAndRenderTarget( int x, int y, int w, int h, ITexture *pRenderTarget ) = 0;
  86. // get texture id for a texture
  87. virtual int DrawGetTextureId( ITexture *pTexture ) = 0;
  88. // begin and end skin composition painting
  89. virtual void BeginSkinCompositionPainting() = 0;
  90. virtual void EndSkinCompositionPainting() = 0;
  91. };
  92. #endif // IMATSYSTEMSURFACE_H