Counter Strike : Global Offensive Source Code
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.

126 lines
5.6 KiB

  1. //===== Copyright � 1996-2005, 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. FORWARD_DECLARE_HANDLE( InputContextHandle_t );
  23. //-----------------------------------------------------------------------------
  24. // Callbacks for mouse getting + setting
  25. //-----------------------------------------------------------------------------
  26. typedef void (*GetMouseCallback_t)(int &x, int &y);
  27. typedef void (*SetMouseCallback_t)(int x, int y);
  28. //-----------------------------------------------------------------------------
  29. // Callbacks for sound playing
  30. //-----------------------------------------------------------------------------
  31. typedef void (*PlaySoundFunc_t)(const char *pFileName);
  32. //-----------------------------------------------------------------------------
  33. //
  34. // An extra interface implemented by the material system implementation of vgui::ISurface
  35. //
  36. //-----------------------------------------------------------------------------
  37. class IMatSystemSurface : public vgui::ISurface
  38. {
  39. public:
  40. // If the app drives the input (like the engine needs to do for VCR mode),
  41. // it can call this, setting bLetAppDriveInput to true and call
  42. // HandleInputEvent for the input events.
  43. virtual void SetAppDrivesInput( bool bLetAppDriveInput ) = 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. // When manual supersampling of rendertarget is enabled then the render
  50. // target will double the width and height of the rendering region if possible, or will otherwise
  51. // increase the rendering region to fill up the width/height of the render target maintaining
  52. // the aspect ratio.
  53. virtual void Begin3DPaint( int iLeft, int iTop, int iRight, int iBottom, bool bSupersampleRT = false ) = 0;
  54. virtual void End3DPaint( bool bIgnoreAlphaWhenCompositing = false ) = 0;
  55. // NOTE: This also should only be called from within the paint()
  56. // method of a panel. Use it to disable clipping for the rendering
  57. // of this panel.
  58. virtual void DisableClipping( bool bDisable ) = 0;
  59. // Prevents vgui from changing the cursor
  60. virtual bool IsCursorLocked() const = 0;
  61. // Sets the mouse get + set callbacks
  62. virtual void SetMouseCallbacks( GetMouseCallback_t getFunc, SetMouseCallback_t setFunc ) = 0;
  63. // Installs a function to play sounds
  64. virtual void InstallPlaySoundFunc( PlaySoundFunc_t soundFunc ) = 0;
  65. // Some drawing methods that cannot be accomplished under Win32
  66. virtual void DrawColoredCircle( int centerx, int centery, float radius, int r, int g, int b, int a ) = 0;
  67. virtual void DrawColoredText( vgui::HFont font, int x, int y, int r, int g, int b, int a, PRINTF_FORMAT_STRING const char *fmt, ... ) = 0;
  68. // Draws text with current font at position and wordwrapped to the rect using color values specified
  69. 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;
  70. virtual void DrawTextHeight( vgui::HFont font, int w, int& h, PRINTF_FORMAT_STRING char *fmt, ... ) = 0;
  71. // Returns the length of the text string in pixels
  72. virtual int DrawTextLen( vgui::HFont font, PRINTF_FORMAT_STRING const char *fmt, ... ) = 0;
  73. // Draws a panel in 3D space. Assumes view + projection are already set up
  74. // Also assumes the (x,y) coordinates of the panels are defined in 640xN coords
  75. // (N isn't necessary 480 because the panel may not be 4x3)
  76. // The width + height specified are the size of the panel in world coordinates
  77. virtual void DrawPanelIn3DSpace( vgui::VPANEL pRootPanel, const VMatrix &panelCenterToWorld, int nPixelWidth, int nPixelHeight, float flWorldWidth, float flWorldHeight ) = 0;
  78. // Binds a material to a surface texture ID
  79. virtual void DrawSetTextureMaterial( int id, IMaterial *pMaterial ) = 0;
  80. // Handles an input event, returns true if the event should be filtered from the rest of the game
  81. virtual bool HandleInputEvent( const InputEvent_t &event ) = 0;
  82. virtual void Set3DPaintTempRenderTarget( const char *pRenderTargetName ) = 0;
  83. virtual void Reset3DPaintTempRenderTarget( void ) = 0;
  84. // Gets a material bound to a surface texture ID
  85. virtual IMaterial *DrawGetTextureMaterial( int id ) = 0;
  86. // Sets the VGui input context
  87. virtual void SetInputContext( InputContextHandle_t hContext ) = 0;
  88. // uploads a part of a texture, used for font rendering
  89. virtual void DrawSetSubTextureRGBA( int textureID, int drawX, int drawY, unsigned const char *rgba, int subTextureWide, int subTextureTall ) = 0;
  90. // Draws a gradient filled rect where the colors may be different
  91. virtual void DrawTexturedSubRectGradient( int x0, int y0, int x1, int y1, float texs0, float text0, float texs1, float text1, Color colStart, Color colEnd, bool bHorizontal ) = 0;
  92. // Sets texture RGBA with linear scaling (normally it's pointsampling on the DrawSetTextureRGBA call)
  93. virtual void DrawSetTextureRGBALinear( int id, const unsigned char *rgba, int wide, int tall ) = 0;
  94. };
  95. #endif // IMATSYSTEMSURFACE_H