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.

106 lines
2.8 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: interface to asynchronous lighting preview creator
  4. //
  5. //===========================================================================//
  6. #ifndef LPREVIEW_THREAD_H
  7. #define LPREVIEW_THREAD_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "tier0/threadtools.h"
  12. #include "bitmap/bitmap.h"
  13. #include "bitmap/float_bm.h"
  14. #include "tier1/utlvector.h"
  15. #include "mathlib/lightdesc.h"
  16. class CLightingPreviewLightDescription : public LightDesc_t
  17. {
  18. public:
  19. int m_nObjectID;
  20. class CIncrementalLightInfo *m_pIncrementalInfo;
  21. void Init( int obj_id )
  22. {
  23. m_pIncrementalInfo = NULL;
  24. m_nObjectID = obj_id;
  25. }
  26. };
  27. enum HammerToLightingPreviewMessageType
  28. {
  29. // messages from hammer to preview task
  30. LPREVIEW_MSG_STOP, // no lighting previews open - stop working
  31. LPREVIEW_MSG_EXIT, // we're exiting program - shut down
  32. LPREVIEW_MSG_GEOM_DATA, // we have new shadow geometry data
  33. LPREVIEW_MSG_G_BUFFERS, // we have new g buffer data from the renderer
  34. LPREVIEW_MSG_LIGHT_DATA, // new light data in m_pLightList
  35. };
  36. enum LightingPreviewToHammerMessageType
  37. {
  38. // messages from preview task to hammer
  39. LPREVIEW_MSG_DISPLAY_RESULT, // we have a result image
  40. };
  41. struct MessageToLPreview
  42. {
  43. HammerToLightingPreviewMessageType m_MsgType;
  44. MessageToLPreview( HammerToLightingPreviewMessageType mtype)
  45. {
  46. m_MsgType = mtype;
  47. }
  48. MessageToLPreview( void)
  49. {
  50. }
  51. // this structure uses a fat format for the args instead of separate classes for each
  52. // message. the messages are small anyway, since pointers are used for anything of size.
  53. FloatBitMap_t *m_pDefferedRenderingBMs[4]; // if LPREVIEW_MSG_G_BUFFERS
  54. CUtlVector<CLightingPreviewLightDescription> *m_pLightList; // if LPREVIEW_MSG_LIGHT_DATA
  55. Vector m_EyePosition; // for LPREVIEW_MSG_LIGHT_DATA & G_BUFFERS
  56. CUtlVector<Vector> *m_pShadowTriangleList; // for LPREVIEW_MSG_GEOM_DATA
  57. int m_nBitmapGenerationCounter; // for LPREVIEW_MSG_G_BUFFERS
  58. };
  59. struct MessageFromLPreview
  60. {
  61. LightingPreviewToHammerMessageType m_MsgType;
  62. Bitmap_t *m_pBitmapToDisplay; // for LPREVIEW_MSG_DISPLAY_RESULT
  63. int m_nBitmapGenerationCounter; // for LPREVIEW_MSG_DISPLAY_RESULT
  64. MessageFromLPreview( LightingPreviewToHammerMessageType msgtype )
  65. {
  66. m_MsgType = msgtype;
  67. }
  68. MessageFromLPreview( void )
  69. {
  70. }
  71. };
  72. extern CMessageQueue<MessageToLPreview> g_HammerToLPreviewMsgQueue;
  73. extern CMessageQueue<MessageFromLPreview> g_LPreviewToHammerMsgQueue;
  74. extern ThreadHandle_t g_LPreviewThread;
  75. extern CInterlockedInt n_gbufs_queued;
  76. extern CInterlockedInt n_result_bms_queued;
  77. extern Bitmap_t *g_pLPreviewOutputBitmap;
  78. // the lighting preview thread entry point
  79. unsigned LightingPreviewThreadFN( void *thread_start_arg );
  80. // the lighting preview handler. call often
  81. void HandleLightingPreview( void );
  82. #endif