Source code of Windows XP (NT5)
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.

115 lines
4.7 KiB

  1. #if _MSC_VER > 1000
  2. #pragma once
  3. #endif
  4. #ifndef _DXSVR_LIB_H
  5. #define _DXSVR_LIB_H
  6. #include <d3dx.h>
  7. //***************************************************************************************
  8. // Forces the correct version of the library to be included
  9. /*
  10. #ifndef BUILDING_DXSVR_LIB
  11. #ifdef _DEBUG
  12. #pragma comment(lib,"dxsvrd.lib")
  13. #else
  14. #pragma comment(lib,"dxsvr.lib")
  15. #endif
  16. #endif
  17. */
  18. //***************************************************************************************
  19. // These functions must be exported by the screensaver app
  20. extern "C" LRESULT WINAPI ScreenSaverProc(HWND , UINT , WPARAM , LPARAM);
  21. extern "C" BOOL ScreenSaverInit();
  22. extern "C" void ScreenSaverShutdown();
  23. extern "C" void ScreenSaverDrawFrame();
  24. extern "C" int ScreenSaverDoConfig();
  25. //***************************************************************************************
  26. // Principal functions exported by DXSave.lib
  27. // WinMain replacement
  28. extern "C" int DXSvrMain(HINSTANCE instance , HINSTANCE , LPSTR cmd , int);
  29. // Window procedure
  30. extern "C" LONG DefDXScreenSaverProc(HWND hWnd , UINT message , WPARAM wParam , LPARAM lParam);
  31. // Flip procedure. Must call this instead of just doing g_pXContext->UpdateFrame(0) to get preview window correct
  32. extern "C" void Flip();
  33. // Handy methods for reading and writing the registry. Use for storing settings. Note that DXSave.lib
  34. // already reads and writes device and display mode settings
  35. extern "C"
  36. {
  37. GUID GetRegistryGUID(LPCSTR szName , const GUID& guidDefault);
  38. void SetRegistryGUID(LPCSTR szName , const GUID& guidValue);
  39. int GetRegistryInt(LPCSTR szName , int iDefault);
  40. void SetRegistryInt(LPCSTR szName , int iValue);
  41. void GetRegistryString(LPCSTR szName , LPSTR szBuffer , DWORD dwBufferLength , LPCSTR szDefault);
  42. void SetRegistryString(LPCTSTR szName , LPCTSTR szValue);
  43. };
  44. //***************************************************************************************
  45. // Global variables exported by DXSave.lib
  46. extern "C" HINSTANCE g_hMainInstance; // Main instance handle
  47. extern "C" ID3DXContext* g_pXContext; // X-Library context
  48. extern "C" IDirect3DDevice7* g_pDevice; // D3D Device
  49. extern "C" BOOL g_bIsTest; // Is in test mode?
  50. extern "C" BOOL g_bIsPreview; // Is in preview (mini-window) mode?
  51. extern "C" HWND g_hWnd; // Handle of the rendering window
  52. extern "C" HWND g_hRefWindow; // Reference window (for preview mode)
  53. //***************************************************************************************
  54. // These variables must be present in the screen saver application
  55. // The name of the registry key to use, e.g. "Software\\MyCompany\\MyScreenSaver"
  56. extern const char* g_szKeyname;
  57. //***************************************************************************************
  58. // Utility functions exported by DXSave.lib. Most of these are straight from d3dutil in d3dframe
  59. #if 0
  60. // Fill out an identity matrix
  61. extern "C" void D3DUtil_SetIdentityMatrix(D3DMATRIX& mat);
  62. // Fill out a translation matrix
  63. extern "C" void D3DUtil_SetTranslationMatrix(D3DMATRIX& mat , const D3DVECTOR& vTrans);
  64. // Fill out a view matrix - can fail if vAt and vFrom are too close together (or identical)
  65. extern "C" HRESULT D3DUtil_SetViewMatrix(D3DMATRIX& mat, D3DVECTOR& vFrom,
  66. D3DVECTOR& vAt, D3DVECTOR& vWorldUp);
  67. // Fill out a projection matrix - can fail if far and near planes are too close together (or identical)
  68. extern "C" HRESULT D3DUtil_SetProjectionMatrix(D3DMATRIX& mat, FLOAT fFOV, FLOAT fAspect,
  69. FLOAT fNearPlane, FLOAT fFarPlane);
  70. // Fill out rotation matrix about principle axis
  71. extern "C" void D3DUtil_SetRotateXMatrix(D3DMATRIX& mat, FLOAT fRads);
  72. extern "C" void D3DUtil_SetRotateYMatrix(D3DMATRIX& mat, FLOAT fRads);
  73. extern "C" void D3DUtil_SetRotateZMatrix(D3DMATRIX& mat, FLOAT fRads);
  74. // Fill out rotation matrix about arbitrary axis vDir
  75. extern "C" void D3DUtil_SetRotationMatrix(D3DMATRIX& mat, D3DVECTOR& vDir, FLOAT fRads);
  76. #endif
  77. //***************************************************************************************
  78. // Useful TRACE debugging macro. Compiles out in release builds, otherwise can be used to output
  79. // formatted text to the debugging stream. e.g. TRACE("Foo = %d. Bar = %s\n" , dwFoo , szBar);
  80. #ifndef TRACE
  81. extern "C" void __TraceOutput(LPCTSTR pszFormat, ...);
  82. #ifdef _DEBUG
  83. #define TRACE __TraceOutput
  84. #else
  85. #define TRACE sizeof
  86. #endif
  87. #endif
  88. //***************************************************************************************
  89. #endif