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.

643 lines
22 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //===========================================================================//
  7. #ifndef MATSYSTEMSURFACE_H
  8. #define MATSYSTEMSURFACE_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include <vgui/VGUI.h>
  13. #include <vgui/ISurface.h>
  14. #include <vgui/IPanel.h>
  15. #include <vgui/IClientPanel.h>
  16. #include <vgui_controls/Panel.h>
  17. #include <vgui/IInput.h>
  18. #include <vgui_controls/Controls.h>
  19. #include <vgui/Point.h>
  20. #include "materialsystem/imaterialsystem.h"
  21. #include "VGuiMatSurface/IMatSystemSurface.h"
  22. #include "materialsystem/imesh.h"
  23. #include "materialsystem/imaterial.h"
  24. #include "utlvector.h"
  25. #include "utlsymbol.h"
  26. #include "materialsystem/MaterialSystemUtil.h"
  27. #include "tier1/utldict.h"
  28. #include "tier3/tier3.h"
  29. using namespace vgui;
  30. class IImage;
  31. extern class IMaterialSystem *g_pMaterialSystem;
  32. //-----------------------------------------------------------------------------
  33. // The default material system embedded panel
  34. //-----------------------------------------------------------------------------
  35. class CMatEmbeddedPanel : public vgui::Panel
  36. {
  37. typedef vgui::Panel BaseClass;
  38. public:
  39. CMatEmbeddedPanel();
  40. virtual void OnThink();
  41. VPANEL IsWithinTraverse(int x, int y, bool traversePopups);
  42. };
  43. //-----------------------------------------------------------------------------
  44. //
  45. // Implementation of the VGUI surface on top of the material system
  46. //
  47. //-----------------------------------------------------------------------------
  48. class CMatSystemSurface : public CTier3AppSystem< IMatSystemSurface >
  49. {
  50. typedef CTier3AppSystem< IMatSystemSurface > BaseClass;
  51. public:
  52. CMatSystemSurface();
  53. virtual ~CMatSystemSurface();
  54. // Methods of IAppSystem
  55. virtual bool Connect( CreateInterfaceFn factory );
  56. virtual void Disconnect();
  57. virtual void *QueryInterface( const char *pInterfaceName );
  58. virtual InitReturnVal_t Init();
  59. virtual void Shutdown();
  60. // initialization
  61. virtual void SetEmbeddedPanel(vgui::VPANEL pEmbeddedPanel);
  62. // returns true if a panel is minimzed
  63. bool IsMinimized(vgui::VPANEL panel);
  64. // Sets the only panel to draw. Set to NULL to clear.
  65. void RestrictPaintToSinglePanel(vgui::VPANEL panel);
  66. // frame
  67. virtual void RunFrame();
  68. // implementation of vgui::ISurface
  69. virtual vgui::VPANEL GetEmbeddedPanel();
  70. // drawing context
  71. virtual void PushMakeCurrent(vgui::VPANEL panel,bool useInSets);
  72. virtual void PopMakeCurrent(vgui::VPANEL panel);
  73. // rendering functions
  74. virtual void DrawSetColor(int r,int g,int b,int a);
  75. virtual void DrawSetColor(Color col);
  76. virtual void DrawLine( int x0, int y0, int x1, int y1 );
  77. virtual void DrawTexturedLine( const vgui::Vertex_t &a, const vgui::Vertex_t &b );
  78. virtual void DrawPolyLine(int *px, int *py, int numPoints);
  79. virtual void DrawTexturedPolyLine( const vgui::Vertex_t *p, int n );
  80. virtual void DrawFilledRect(int x0, int y0, int x1, int y1);
  81. virtual void DrawFilledRectArray( IntRect *pRects, int numRects );
  82. virtual void DrawFilledRectFastFade( int x0, int y0, int x1, int y1, int fadeStartPt, int fadeEndPt, unsigned int alpha0, unsigned int alpha1, bool bHorizontal );
  83. virtual void DrawFilledRectFade( int x0, int y0, int x1, int y1, unsigned int alpha0, unsigned int alpha1, bool bHorizontal );
  84. virtual void DrawOutlinedRect(int x0, int y0, int x1, int y1);
  85. virtual void DrawOutlinedCircle(int x, int y, int radius, int segments);
  86. // textured rendering functions
  87. virtual int CreateNewTextureID( bool procedural = false );
  88. virtual bool IsTextureIDValid(int id);
  89. virtual bool DrawGetTextureFile(int id, char *filename, int maxlen );
  90. virtual int DrawGetTextureId( char const *filename );
  91. virtual int DrawGetTextureId( ITexture *pTexture );
  92. virtual void DrawSetTextureFile(int id, const char *filename, int hardwareFilter, bool forceReload);
  93. virtual void DrawSetTexture(int id);
  94. virtual void DrawGetTextureSize(int id, int &wide, int &tall);
  95. virtual bool DeleteTextureByID(int id);
  96. virtual IVguiMatInfo *DrawGetTextureMatInfoFactory(int id);
  97. virtual void DrawSetTextureRGBA(int id, const unsigned char *rgba, int wide, int tall, int hardwareFilter, bool forceReload);
  98. virtual void DrawTexturedRect(int x0, int y0, int x1, int y1);
  99. virtual void DrawTexturedSubRect( int x0, int y0, int x1, int y1, float texs0, float text0, float texs1, float text1 );
  100. virtual void DrawTexturedPolygon(int n, vgui::Vertex_t *pVertices, bool bClipVertices = true );
  101. virtual void DrawPrintText(const wchar_t *text, int textLen, FontDrawType_t drawType = FONT_DRAW_DEFAULT);
  102. virtual void DrawUnicodeChar(wchar_t wch, FontDrawType_t drawType = FONT_DRAW_DEFAULT );
  103. virtual void DrawUnicodeString( const wchar_t *pwString, FontDrawType_t drawType = FONT_DRAW_DEFAULT );
  104. virtual void DrawSetTextFont(vgui::HFont font);
  105. virtual void DrawFlushText();
  106. virtual void DrawSetTextColor(int r, int g, int b, int a);
  107. virtual void DrawSetTextColor(Color col);
  108. virtual void DrawSetTextScale(float sx, float sy);
  109. virtual void DrawSetTextPos(int x, int y);
  110. virtual void DrawGetTextPos(int& x,int& y);
  111. virtual vgui::IHTML *CreateHTMLWindow(vgui::IHTMLEvents *events,vgui::VPANEL context);
  112. virtual void PaintHTMLWindow(vgui::IHTML *htmlwin);
  113. virtual void DeleteHTMLWindow(vgui::IHTML *htmlwin);
  114. virtual bool BHTMLWindowNeedsPaint(IHTML *htmlwin);
  115. virtual void GetScreenSize(int &wide, int &tall);
  116. virtual void SetAsTopMost(vgui::VPANEL panel, bool state);
  117. virtual void BringToFront(vgui::VPANEL panel);
  118. virtual void SetForegroundWindow (vgui::VPANEL panel);
  119. virtual void SetPanelVisible(vgui::VPANEL panel, bool state);
  120. virtual void SetMinimized(vgui::VPANEL panel, bool state);
  121. virtual void FlashWindow(vgui::VPANEL panel, bool state);
  122. virtual void SetTitle(vgui::VPANEL panel, const wchar_t *title);
  123. virtual const wchar_t *GetTitle( vgui::VPANEL panel );
  124. virtual void SetAsToolBar(vgui::VPANEL panel, bool state); // removes the window's task bar entry (for context menu's, etc.)
  125. // windows stuff
  126. virtual void CreatePopup(VPANEL panel, bool minimized, bool showTaskbarIcon = true, bool disabled = false, bool mouseInput = true , bool kbInput = true);
  127. virtual void SwapBuffers(vgui::VPANEL panel);
  128. virtual void Invalidate(vgui::VPANEL panel);
  129. virtual void SetCursor(vgui::HCursor cursor);
  130. virtual bool IsCursorVisible();
  131. virtual void SetCursorAlwaysVisible(bool visible);
  132. virtual void ApplyChanges();
  133. virtual bool IsWithin(int x, int y);
  134. virtual bool HasFocus();
  135. virtual bool SupportsFeature(SurfaceFeature_e feature);
  136. // engine-only focus handling (replacing WM_FOCUS windows handling)
  137. virtual void SetTopLevelFocus(vgui::VPANEL panel);
  138. // fonts
  139. virtual vgui::HFont CreateFont();
  140. virtual bool SetFontGlyphSet(vgui::HFont font, const char *windowsFontName, int tall, int weight, int blur, int scanlines, int flags, int nRangeMin = 0, int nRangeMax = 0);
  141. virtual bool SetBitmapFontGlyphSet(vgui::HFont font, const char *windowsFontName, float scalex, float scaley, int flags);
  142. virtual int GetFontTall(HFont font);
  143. virtual int GetFontTallRequested(HFont font);
  144. virtual int GetFontAscent(HFont font, wchar_t wch);
  145. virtual bool IsFontAdditive(HFont font);
  146. virtual void GetCharABCwide(HFont font, int ch, int &a, int &b, int &c);
  147. virtual void GetTextSize(HFont font, const wchar_t *text, int &wide, int &tall);
  148. virtual int GetCharacterWidth(vgui::HFont font, int ch);
  149. virtual bool AddCustomFontFile(const char *fontName, const char *fontFileName);
  150. virtual bool AddBitmapFontFile(const char *fontFileName);
  151. virtual void SetBitmapFontName( const char *pName, const char *pFontFilename );
  152. virtual const char *GetBitmapFontName( const char *pName );
  153. virtual void PrecacheFontCharacters(HFont font, const wchar_t *pCharacters);
  154. virtual void ClearTemporaryFontCache( void );
  155. virtual const char *GetFontName( HFont font );
  156. virtual const char *GetFontFamilyName( HFont font );
  157. // GameUI-only accessed functions
  158. // uploads a part of a texture, used for font rendering
  159. void DrawSetSubTextureRGBA(int textureID, int drawX, int drawY, unsigned const char *rgba, int subTextureWide, int subTextureTall);
  160. void DrawUpdateRegionTextureRGBA( int nTextureID, int x, int y, const unsigned char *pchData, int wide, int tall, ImageFormat imageFormat );
  161. // notify icons?!?
  162. virtual vgui::VPANEL GetNotifyPanel();
  163. virtual void SetNotifyIcon(vgui::VPANEL context, vgui::HTexture icon, vgui::VPANEL panelToReceiveMessages, const char *text);
  164. // plays a sound
  165. virtual void PlaySound(const char *fileName);
  166. //!! these functions Should not be accessed directly, but only through other vgui items
  167. //!! need to move these to seperate interface
  168. virtual int GetPopupCount();
  169. virtual vgui::VPANEL GetPopup( int index );
  170. virtual bool ShouldPaintChildPanel(vgui::VPANEL childPanel);
  171. virtual bool RecreateContext(vgui::VPANEL panel);
  172. virtual void AddPanel(vgui::VPANEL panel);
  173. virtual void ReleasePanel(vgui::VPANEL panel);
  174. virtual void MovePopupToFront(vgui::VPANEL panel);
  175. virtual void SolveTraverse(vgui::VPANEL panel, bool forceApplySchemeSettings);
  176. virtual void PaintTraverse(vgui::VPANEL panel);
  177. virtual void EnableMouseCapture(vgui::VPANEL panel, bool state);
  178. virtual void SetWorkspaceInsets( int left, int top, int right, int bottom );
  179. virtual void GetWorkspaceBounds(int &x, int &y, int &wide, int &tall);
  180. // Hook needed to Get input to work
  181. virtual void AttachToWindow( void *hwnd, bool bLetAppDriveInput );
  182. virtual bool HandleInputEvent( const InputEvent_t &event );
  183. void InitFullScreenBuffer( const char *pszRenderTargetName );
  184. virtual void Set3DPaintTempRenderTarget( const char *pRenderTargetName );
  185. virtual void Reset3DPaintTempRenderTarget( void );
  186. // Begins, ends 3D painting
  187. virtual void Begin3DPaint( int iLeft, int iTop, int iRight, int iBottom, bool bRenderToTexture = true );
  188. virtual void End3DPaint();
  189. virtual void BeginSkinCompositionPainting() OVERRIDE;
  190. virtual void EndSkinCompositionPainting() OVERRIDE;
  191. // Disable clipping during rendering
  192. virtual void DisableClipping( bool bDisable ) OVERRIDE;
  193. virtual void GetClippingRect( int &left, int &top, int &right, int &bottom, bool &bClippingDisabled ) OVERRIDE;
  194. virtual void SetClippingRect( int left, int top, int right, int bottom ) OVERRIDE;
  195. // Prevents vgui from changing the cursor
  196. virtual bool IsCursorLocked() const;
  197. // Sets the mouse Get + Set callbacks
  198. virtual void SetMouseCallbacks( GetMouseCallback_t GetFunc, SetMouseCallback_t SetFunc );
  199. // Tells the surface to ignore windows messages
  200. virtual void EnableWindowsMessages( bool bEnable );
  201. // Installs a function to play sounds
  202. virtual void InstallPlaySoundFunc( PlaySoundFunc_t soundFunc );
  203. // Some drawing methods that cannot be accomplished under Win32
  204. virtual void DrawColoredCircle( int centerx, int centery, float radius, int r, int g, int b, int a );
  205. virtual int DrawColoredText( vgui::HFont font, int x, int y, int r, int g, int b, int a, PRINTF_FORMAT_STRING const char *fmt, ... );
  206. 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, ... );
  207. virtual void DrawTextHeight( vgui::HFont font, int w, int& h, PRINTF_FORMAT_STRING const char *fmt, ... );
  208. // Returns the length in pixels of the text
  209. virtual int DrawTextLen( vgui::HFont font, PRINTF_FORMAT_STRING const char *fmt, ... );
  210. // Draws a panel in 3D space.
  211. virtual void DrawPanelIn3DSpace( vgui::VPANEL pRootPanel, const VMatrix &panelCenterToWorld, int pw, int ph, float sw, float sh );
  212. // Only visible within vguimatsurface
  213. void DrawSetTextureMaterial(int id, IMaterial *pMaterial);
  214. void ReferenceProceduralMaterial( int id, int referenceId, IMaterial *pMaterial );
  215. // new stuff for Alfreds VGUI2 port!!
  216. virtual bool InEngine() { return true; }
  217. void GetProportionalBase( int &width, int &height ) { width = BASE_WIDTH; height = BASE_HEIGHT; }
  218. virtual bool HasCursorPosFunctions() { return true; }
  219. virtual void SetModalPanel(VPANEL );
  220. virtual VPANEL GetModalPanel();
  221. virtual void UnlockCursor();
  222. virtual void LockCursor();
  223. virtual void SetTranslateExtendedKeys(bool state);
  224. virtual VPANEL GetTopmostPopup();
  225. virtual void GetAbsoluteWindowBounds(int &x, int &y, int &wide, int &tall);
  226. virtual void CalculateMouseVisible();
  227. virtual bool NeedKBInput();
  228. virtual void SurfaceGetCursorPos(int &x, int &y);
  229. virtual void SurfaceSetCursorPos(int x, int y);
  230. virtual void MovePopupToBack(VPANEL panel);
  231. virtual bool IsInThink( VPANEL panel);
  232. virtual bool DrawGetUnicodeCharRenderInfo( wchar_t ch, CharRenderInfo& info );
  233. virtual void DrawRenderCharFromInfo( const CharRenderInfo& info );
  234. // global alpha setting functions
  235. // affect all subsequent draw calls - shouldn't normally be used directly, only in Panel::PaintTraverse()
  236. virtual void DrawSetAlphaMultiplier( float alpha /* [0..1] */ );
  237. virtual float DrawGetAlphaMultiplier();
  238. // web browser
  239. virtual void SetAllowHTMLJavaScript( bool state );
  240. // video mode changing
  241. virtual void OnScreenSizeChanged( int nOldWidth, int nOldHeight );
  242. virtual vgui::HCursor CreateCursorFromFile( char const *curOrAniFile, char const *pPathID );
  243. virtual void PaintTraverseEx(VPANEL panel, bool paintPopups = false );
  244. virtual float GetZPos() const;
  245. virtual void SetPanelForInput( VPANEL vpanel );
  246. virtual vgui::IImage *GetIconImageForFullPath( char const *pFullPath );
  247. virtual void DestroyTextureID( int id );
  248. virtual const char *GetResolutionKey( void ) const;
  249. virtual bool ForceScreenSizeOverride( bool bState, int wide, int tall );
  250. // LocalToScreen, ParentLocalToScreen fixups for explicit PaintTraverse calls on Panels not at 0, 0 position
  251. virtual bool ForceScreenPosOffset( bool bState, int x, int y );
  252. virtual void OffsetAbsPos( int &x, int &y );
  253. virtual void GetKernedCharWidth( HFont font, wchar_t ch, wchar_t chBefore, wchar_t chAfter, float &wide, float &flabcA );
  254. virtual const char *GetWebkitHTMLUserAgentString() { return "Valve Client"; }
  255. virtual void *Deprecated_AccessChromeHTMLController() { return NULL; }
  256. virtual void SetFullscreenViewport( int x, int y, int w, int h ) OVERRIDE;
  257. virtual void SetFullscreenViewportAndRenderTarget( int x, int y, int w, int h, ITexture *pRenderTarget ) OVERRIDE;
  258. virtual void GetFullscreenViewportAndRenderTarget( int & x, int & y, int & w, int & h, ITexture **ppRenderTarget ) OVERRIDE;
  259. virtual void GetFullscreenViewport( int & x, int & y, int & w, int & h ) OVERRIDE;
  260. virtual void PushFullscreenViewport() OVERRIDE;
  261. virtual void PopFullscreenViewport() OVERRIDE;
  262. // support for software cursors
  263. virtual void SetSoftwareCursor( bool bUseSoftwareCursor ) OVERRIDE;
  264. virtual void PaintSoftwareCursor() OVERRIDE;
  265. // Methods of ILocalizeTextQuery
  266. public:
  267. //virtual int ComputeTextWidth( const wchar_t *pString );
  268. // Causes fonts to get reloaded, etc.
  269. virtual void ResetFontCaches();
  270. virtual bool IsScreenSizeOverrideActive( void );
  271. virtual bool IsScreenPosOverrideActive( void );
  272. virtual IMaterial *DrawGetTextureMaterial( int id );
  273. virtual int GetTextureNumFrames( int id );
  274. virtual void DrawSetTextureFrame( int id, int nFrame, unsigned int *pFrameCache );
  275. private:
  276. //void DrawRenderCharInternal( const FontCharRenderInfo& info );
  277. void DrawRenderCharInternal( const CharRenderInfo& info );
  278. private:
  279. enum { BASE_HEIGHT = 480, BASE_WIDTH = 640 };
  280. struct PaintState_t
  281. {
  282. vgui::VPANEL m_pPanel;
  283. int m_iTranslateX;
  284. int m_iTranslateY;
  285. int m_iScissorLeft;
  286. int m_iScissorRight;
  287. int m_iScissorTop;
  288. int m_iScissorBottom;
  289. };
  290. // material Setting method
  291. void InternalSetMaterial( IMaterial *material = NULL );
  292. // Draws the fullscreen buffer into the panel
  293. void DrawFullScreenBuffer( int nLeft, int nTop, int nRight, int nBottom );
  294. // Helper method to initialize vertices (transforms them into screen space too)
  295. void InitVertex( vgui::Vertex_t &vertex, int x, int y, float u, float v );
  296. // Draws a quad + quad array
  297. void DrawQuad( const vgui::Vertex_t &ul, const vgui::Vertex_t &lr, unsigned char *pColor );
  298. void DrawQuadArray( int numQuads, vgui::Vertex_t *pVerts, unsigned char *pColor, bool bShouldClip = true );
  299. // Necessary to wrap the rendering
  300. void StartDrawing( void );
  301. void StartDrawingIn3DSpace( const VMatrix &screenToWorld, int pw, int ph, float sw, float sh );
  302. void FinishDrawing( void );
  303. // Sets up a particular painting state...
  304. void SetupPaintState( const PaintState_t &paintState );
  305. void ResetPopupList();
  306. void AddPopup( vgui::VPANEL panel );
  307. void RemovePopup( vgui::VPANEL panel );
  308. void AddPopupsToList( vgui::VPANEL panel );
  309. // Helper for drawing colored text
  310. int DrawColoredText( vgui::HFont font, int x, int y, int r, int g, int b, int a, const char *fmt, va_list argptr );
  311. void SearchForWordBreak( vgui::HFont font, char *text, int& chars, int& pixels );
  312. void InternalThinkTraverse(VPANEL panel);
  313. void InternalSolveTraverse(VPANEL panel);
  314. void InternalSchemeSettingsTraverse(VPANEL panel, bool forceApplySchemeSettings);
  315. // handles mouse movement
  316. void SetCursorPos(int x, int y);
  317. void GetCursorPos(int &x, int &y);
  318. void DrawTexturedLineInternal( const Vertex_t &a, const Vertex_t &b );
  319. // Gets texture coordinates for drawing the full screen buffer
  320. void GetFullScreenTexCoords( int x, int y, int w, int h, float *pMinU, float *pMinV, float *pMaxU, float *pMaxV );
  321. // Is a panel under the restricted panel?
  322. bool IsPanelUnderRestrictedPanel( VPANEL panel );
  323. // Point Translation for current panel
  324. int m_nTranslateX;
  325. int m_nTranslateY;
  326. // alpha multiplier for current panel [0..1]
  327. float m_flAlphaMultiplier;
  328. // The size of the window to draw into
  329. int m_pSurfaceExtents[4];
  330. // Color for drawing all non-text things
  331. unsigned char m_DrawColor[4];
  332. // Color for drawing text
  333. unsigned char m_DrawTextColor[4];
  334. // Location of text rendering
  335. int m_pDrawTextPos[2];
  336. // Meshbuilder used for drawing
  337. IMesh* m_pMesh;
  338. CMeshBuilder meshBuilder;
  339. // White material used for drawing non-textured things
  340. CMaterialReference m_pWhite;
  341. // Used for 3D-rendered images
  342. CTextureReference m_FullScreenBuffer;
  343. CMaterialReference m_FullScreenBufferMaterial;
  344. int m_nFullScreenBufferMaterialId;
  345. CUtlString m_FullScreenBufferName;
  346. bool m_bUsingTempFullScreenBufferMaterial;
  347. // Root panel
  348. vgui::VPANEL m_pEmbeddedPanel;
  349. vgui::Panel *m_pDefaultEmbeddedPanel;
  350. vgui::VPANEL m_pRestrictedPanel;
  351. // List of pop-up panels based on the type enum above (draw order vs last clicked)
  352. CUtlVector<vgui::HPanel> m_PopupList;
  353. // Stack of paint state...
  354. CUtlVector< PaintState_t > m_PaintStateStack;
  355. vgui::HFont m_hCurrentFont;
  356. vgui::HCursor _currentCursor;
  357. bool m_cursorAlwaysVisible;
  358. // The currently bound texture
  359. int m_iBoundTexture;
  360. // font drawing batching code
  361. enum { MAX_BATCHED_CHAR_VERTS = 4096 };
  362. vgui::Vertex_t m_BatchedCharVerts[ MAX_BATCHED_CHAR_VERTS ];
  363. int m_nBatchedCharVertCount;
  364. // What's the rectangle we're drawing in 3D paint mode?
  365. int m_n3DLeft, m_n3DRight, m_n3DTop, m_n3DBottom;
  366. // Are we painting in 3D? (namely drawing 3D objects *inside* the vgui panel)
  367. bool m_bIn3DPaintMode : 1;
  368. // If we are in 3d Paint mode, are we rendering to a texture? (Or directly to the screen)
  369. bool m_b3DPaintRenderToTexture : 1;
  370. // Are we drawing the vgui panel in the 3D world somewhere?
  371. bool m_bDrawingIn3DWorld : 1;
  372. // Is the app gonna call HandleInputEvent?
  373. bool m_bAppDrivesInput : 1;
  374. // Are we currently in the think() loop
  375. bool m_bInThink : 1;
  376. bool m_bNeedsKeyboard : 1;
  377. bool m_bNeedsMouse : 1;
  378. bool m_bAllowJavaScript : 1;
  379. int m_nLastInputPollCount;
  380. VPANEL m_CurrentThinkPanel;
  381. // The attached HWND
  382. void *m_HWnd;
  383. // Installed function to play sounds
  384. PlaySoundFunc_t m_PlaySoundFunc;
  385. int m_WorkSpaceInsets[4];
  386. class TitleEntry
  387. {
  388. public:
  389. TitleEntry()
  390. {
  391. panel = NULL;
  392. title[0] = 0;
  393. }
  394. vgui::VPANEL panel;
  395. wchar_t title[128];
  396. };
  397. CUtlVector< TitleEntry > m_Titles;
  398. CUtlVector< CUtlSymbol > m_CustomFontFileNames;
  399. CUtlVector< CUtlSymbol > m_BitmapFontFileNames;
  400. CUtlDict< int, int > m_BitmapFontFileMapping;
  401. float m_flZPos;
  402. CUtlDict< vgui::IImage *, unsigned short > m_FileTypeImages;
  403. int GetTitleEntry( vgui::VPANEL panel );
  404. virtual void DrawSetTextureRGBAEx(int id, const unsigned char *rgba, int wide, int tall, ImageFormat format );
  405. struct ScreenOverride_t
  406. {
  407. ScreenOverride_t() : m_bActive( false )
  408. {
  409. m_nValue[ 0 ] = m_nValue[ 1 ] = 0;
  410. }
  411. bool m_bActive;
  412. int m_nValue[ 2 ];
  413. };
  414. ScreenOverride_t m_ScreenSizeOverride;
  415. ScreenOverride_t m_ScreenPosOverride;
  416. int m_nFullscreenViewportX;
  417. int m_nFullscreenViewportY;
  418. int m_nFullscreenViewportWidth;
  419. int m_nFullscreenViewportHeight;
  420. ITexture *m_pFullscreenRenderTarget;
  421. #ifdef LINUX
  422. struct font_entry
  423. {
  424. void *data;
  425. int size;
  426. };
  427. static CUtlDict< font_entry, unsigned short > m_FontData;
  428. static void *FontDataHelper( const char *pchFontName, int &size, const char *fontFileName );
  429. #endif
  430. };
  431. #if GLMDEBUG
  432. class MatSurfFuncLogger // rip off of GLMFuncLogger - figure out a way to reunify these soon
  433. {
  434. public:
  435. // simple function log
  436. MatSurfFuncLogger( char *funcName )
  437. {
  438. CMatRenderContextPtr prc( g_pMaterialSystem );
  439. m_funcName = funcName;
  440. m_earlyOut = false;
  441. prc->Printf( ">%s", m_funcName );
  442. };
  443. // more advanced version lets you pass args (i.e. called parameters or anything else of interest)
  444. // no macro for this one, since no easy way to pass through the args as well as the funcname
  445. MatSurfFuncLogger( char *funcName, PRINTF_FORMAT_STRING const char *fmt, ... )
  446. {
  447. CMatRenderContextPtr prc( g_pMaterialSystem );
  448. m_funcName = funcName;
  449. m_earlyOut = false;
  450. // this acts like GLMPrintf here
  451. // all the indent policy is down in GLMPrintfVA
  452. // which means we need to inject a ">" at the front of the format string to make this work... sigh.
  453. char modifiedFmt[2000];
  454. modifiedFmt[0] = '>';
  455. strcpy( modifiedFmt+1, fmt );
  456. va_list vargs;
  457. va_start(vargs, fmt);
  458. prc->PrintfVA( modifiedFmt, vargs );
  459. va_end( vargs );
  460. }
  461. ~MatSurfFuncLogger( )
  462. {
  463. CMatRenderContextPtr prc( g_pMaterialSystem );
  464. if (m_earlyOut)
  465. {
  466. prc->Printf( "<%s (early out)", m_funcName );
  467. }
  468. else
  469. {
  470. prc->Printf( "<%s", m_funcName );
  471. }
  472. };
  473. void EarlyOut( void )
  474. {
  475. m_earlyOut = true;
  476. };
  477. char *m_funcName; // set at construction time
  478. bool m_earlyOut;
  479. };
  480. // handy macro to go with the helper class
  481. #define MAT_FUNC MatSurfFuncLogger _logger_ ( __FUNCTION__ )
  482. #else
  483. #define MAT_FUNC
  484. #endif
  485. #endif // MATSYSTEMSURFACE_H