Leaked source code of windows server 2003
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.

153 lines
3.9 KiB

  1. //-----------------------------------------------------------------------------
  2. // File: FlowerBox.h
  3. //
  4. // Desc:
  5. //
  6. // Copyright (c) 2000-2001 Microsoft Corporation. All rights reserved.
  7. //-----------------------------------------------------------------------------
  8. #ifndef _FLOWERBOX_H
  9. #define _FLOWERBOX_H
  10. //-----------------------------------------------------------------------------
  11. // Name: struct MYVERTEX
  12. // Desc: D3D vertex type for this app
  13. //-----------------------------------------------------------------------------
  14. struct MYVERTEX
  15. {
  16. D3DXVECTOR3 p; // Position
  17. D3DXVECTOR3 n; // Normal
  18. };
  19. #define D3DFVF_MYVERTEX ( D3DFVF_XYZ | D3DFVF_NORMAL )
  20. //-----------------------------------------------------------------------------
  21. // Name: struct FLOATRECT
  22. // Desc: Floating viewport rect
  23. //-----------------------------------------------------------------------------
  24. struct FLOATRECT
  25. {
  26. FLOAT xMin;
  27. FLOAT yMin;
  28. FLOAT xSize;
  29. FLOAT ySize;
  30. FLOAT xVel;
  31. FLOAT yVel;
  32. };
  33. // Minimum and maximum number of side subdivisions
  34. #define MINSUBDIV 3
  35. #define MAXSUBDIV 10
  36. // Maximum values allowed
  37. #define MAXSIDES 8
  38. #define MAXSPTS ((MAXSUBDIV+1)*(MAXSUBDIV+1))
  39. #define MAXPTS (MAXSIDES*MAXSPTS)
  40. #define MAXSFACES (MAXSUBDIV*MAXSUBDIV)
  41. #define MAXFACES (MAXSIDES*MAXSFACES)
  42. #define MAXFPTS 4
  43. // Number of colors used in checkerboarding
  44. #define NCCOLS 2
  45. // Configurable options
  46. struct CONFIG
  47. {
  48. BOOL smooth_colors;
  49. BOOL triangle_colors;
  50. BOOL cycle_colors;
  51. BOOL spin;
  52. BOOL bloom;
  53. INT subdiv;
  54. INT color_pick;
  55. INT image_size;
  56. INT geom;
  57. INT two_sided;
  58. };
  59. extern CONFIG config;
  60. extern FLOAT checker_cols[MAXSIDES][NCCOLS][4];
  61. extern FLOAT side_cols[MAXSIDES][4];
  62. extern FLOAT solid_cols[4];
  63. // A side of a shape
  64. struct SIDE
  65. {
  66. INT nstrips; // Number of triangle strips in this side
  67. INT *strip_size; // Number of vertices per strip
  68. unsigned short *strip_index; // Indices for each point in the triangle strips
  69. };
  70. // Geometry of a shape
  71. struct GEOMETRY
  72. {
  73. VOID (*init)(GEOMETRY *geom);
  74. INT nsides; // Number of sides
  75. SIDE sides[MAXSIDES]; // Sides
  76. // Data for each vertex in the shape
  77. D3DXVECTOR3 *pts, *npts;
  78. D3DXVECTOR3 *normals;
  79. MYVERTEX* pVertices;
  80. INT total_pts; // Total number of vertices
  81. // Scaling control
  82. FLOAT min_sf, max_sf, sf_inc;
  83. FLOAT init_sf; // Initial scale factor setup control
  84. };
  85. #define GEOM_CUBE 0
  86. #define GEOM_TETRA 1
  87. #define GEOM_PYRAMIDS 2
  88. class CFlowerBoxScreensaver : public CD3DScreensaver
  89. {
  90. protected:
  91. FLOATRECT m_floatrect;
  92. // Spin rotations
  93. FLOAT m_xr;
  94. FLOAT m_yr;
  95. FLOAT m_zr;
  96. // Scale factor and increment
  97. FLOAT m_sf;
  98. FLOAT m_sfi;
  99. // Color cycling hue phase
  100. FLOAT m_phase;
  101. GEOMETRY *m_pGeomCur;
  102. protected:
  103. virtual HRESULT RegisterSoftwareDevice();
  104. virtual VOID DoConfig();
  105. virtual VOID ReadSettings();
  106. virtual HRESULT Render();
  107. virtual HRESULT FrameMove();
  108. virtual HRESULT RestoreDeviceObjects();
  109. virtual HRESULT InvalidateDeviceObjects();
  110. VOID ss_ReadSettings();
  111. BOOL ss_RegistrySetup( int section, int file );
  112. int ss_GetRegistryInt( int name, int iDefault );
  113. VOID ss_GetRegistryString( int name, LPTSTR lpDefault, LPTSTR lpDest, int bufSize );
  114. VOID NewConfig(CONFIG *cnf);
  115. VOID UpdatePts(GEOMETRY *geom, FLOAT sf);
  116. VOID InitVlen(GEOMETRY *geom, INT npts, D3DXVECTOR3 *pts);
  117. VOID DrawGeom(GEOMETRY *geom);
  118. VOID ComputeHsvColors(VOID);
  119. HRESULT SetMaterialColor(FLOAT* pfColors);
  120. static INT_PTR CALLBACK ScreenSaverConfigureDialog(HWND hdlg, UINT msg,
  121. WPARAM wpm, LPARAM lpm);
  122. public:
  123. CFlowerBoxScreensaver();
  124. };
  125. #endif