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
3.5 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================
  6. #include "stdafx.h"
  7. #pragma warning(push, 1)
  8. #pragma warning(disable:4701 4702 4530)
  9. #include <fstream>
  10. #pragma warning(pop)
  11. #include "hammer.h"
  12. #include "lprvwindow.h"
  13. #include "TextureBrowser.h"
  14. #include "CustomMessages.h"
  15. #include "IEditorTexture.h"
  16. #include "GameConfig.h"
  17. #include "GlobalFunctions.h"
  18. #include "TextureSystem.h"
  19. #include "materialsystem/imaterial.h"
  20. #include "materialsystem/imaterialsystem.h"
  21. #include "lpreview_thread.h"
  22. #include "MainFrm.h"
  23. // memdbgon must be the last include file in a .cpp file!!!
  24. #include <tier0/memdbgon.h>
  25. BEGIN_MESSAGE_MAP(CLightingPreviewResultsWindow, CWnd)
  26. //{{AFX_MSG_MAP(CTextureWindow)
  27. ON_WM_PAINT()
  28. ON_WM_CLOSE()
  29. //}}AFX_MSG_MAP
  30. END_MESSAGE_MAP()
  31. //-----------------------------------------------------------------------------
  32. // Purpose: Constructor. Initializes data members.
  33. //-----------------------------------------------------------------------------
  34. CLightingPreviewResultsWindow::CLightingPreviewResultsWindow(void)
  35. {
  36. }
  37. //-----------------------------------------------------------------------------
  38. // Purpose: Destructor.
  39. //-----------------------------------------------------------------------------
  40. CLightingPreviewResultsWindow::~CLightingPreviewResultsWindow(void)
  41. {
  42. }
  43. //-----------------------------------------------------------------------------
  44. // Purpose:
  45. // Input : *pParentWnd -
  46. // rect -
  47. //-----------------------------------------------------------------------------
  48. void CLightingPreviewResultsWindow::Create(CWnd *pParentWnd )
  49. {
  50. static CString LPreviewWndClassName;
  51. if(LPreviewWndClassName.IsEmpty())
  52. {
  53. // create class
  54. LPreviewWndClassName = AfxRegisterWndClass(
  55. CS_DBLCLKS | CS_HREDRAW |
  56. CS_VREDRAW, LoadCursor(NULL, IDC_ARROW),
  57. (HBRUSH) GetStockObject(BLACK_BRUSH), NULL);
  58. }
  59. RECT rect;
  60. rect.left = 500; rect.right = 600;
  61. rect.top = 500; rect.bottom = 600;
  62. CWnd::CreateEx(0,LPreviewWndClassName, "LightingPreviewWindow",
  63. WS_OVERLAPPEDWINDOW|WS_SIZEBOX,
  64. rect, NULL, NULL,NULL);
  65. }
  66. //-----------------------------------------------------------------------------
  67. // Purpose:
  68. //-----------------------------------------------------------------------------
  69. void CLightingPreviewResultsWindow::OnClose()
  70. {
  71. GetMainWnd()->GlobalNotify(LPRV_WINDOWCLOSED);
  72. CWnd::OnClose();
  73. }
  74. //-----------------------------------------------------------------------------
  75. // Purpose:
  76. //-----------------------------------------------------------------------------
  77. void CLightingPreviewResultsWindow::OnPaint(void)
  78. {
  79. CPaintDC dc(this); // device context for painting
  80. CRect clientrect;
  81. GetClientRect(clientrect);
  82. if ( g_pLPreviewOutputBitmap)
  83. {
  84. // blit it
  85. BITMAPINFOHEADER mybmh;
  86. mybmh.biHeight=-g_pLPreviewOutputBitmap->Height();
  87. mybmh.biSize=sizeof(BITMAPINFOHEADER);
  88. // now, set up bitmapheader struct for StretchDIB
  89. mybmh.biWidth=g_pLPreviewOutputBitmap->Width();
  90. mybmh.biPlanes=1;
  91. mybmh.biBitCount=32;
  92. mybmh.biCompression=BI_RGB;
  93. mybmh.biSizeImage=g_pLPreviewOutputBitmap->Width()*g_pLPreviewOutputBitmap->Height();
  94. StretchDIBits(
  95. dc.GetSafeHdc(),clientrect.left,clientrect.top,1+(clientrect.right-clientrect.left),
  96. 1+(clientrect.bottom-clientrect.top),
  97. 0,0,g_pLPreviewOutputBitmap->Width(), g_pLPreviewOutputBitmap->Height(),
  98. g_pLPreviewOutputBitmap->GetBits(), (BITMAPINFO *) &mybmh,
  99. DIB_RGB_COLORS, SRCCOPY);
  100. }
  101. }