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.

138 lines
4.2 KiB

  1. //-----------------------------------------------------------------------------
  2. // File: state.h
  3. //
  4. // Desc: STATE
  5. //
  6. // Copyright (c) 1994-2000 Microsoft Corporation
  7. //-----------------------------------------------------------------------------
  8. #ifndef __state_h__
  9. #define __state_h__
  10. #define MAX_DRAW_THREADS 4
  11. #define MAX_TESS 3
  12. // type(s) of pipes that are drawn
  13. enum
  14. {
  15. DRAW_NORMAL,
  16. DRAW_FLEX,
  17. DRAW_BOTH // not currently used
  18. };
  19. // Reset status
  20. #define RESET_STARTUP_BIT (1L << 0)
  21. #define RESET_NORMAL_BIT (1L << 1)
  22. #define RESET_RESIZE_BIT (1L << 2)
  23. #define RESET_REPAINT_BIT (1L << 3)
  24. // Frame draw schemes
  25. enum
  26. {
  27. FRAME_SCHEME_RANDOM, // pipes draw randomly
  28. FRAME_SCHEME_CHASE, // pipes chase a lead pipe
  29. };
  30. //-----------------------------------------------------------------------------
  31. // Name:
  32. // Desc:
  33. //-----------------------------------------------------------------------------
  34. class DRAW_THREAD
  35. {
  36. private:
  37. public:
  38. TEXTUREINFO* m_pTextureInfo;
  39. IDirect3DDevice8* m_pd3dDevice;
  40. PIPE* m_pPipe; // generic pipe ptr
  41. int m_priority;
  42. DRAW_THREAD();
  43. ~DRAW_THREAD();
  44. HRESULT InitDeviceObjects( IDirect3DDevice8* pd3dDevice );
  45. HRESULT RestoreDeviceObjects();
  46. HRESULT InvalidateDeviceObjects();
  47. HRESULT DeleteDeviceObjects();
  48. HRESULT Render();
  49. HRESULT FrameMove( FLOAT fElapsedTime );
  50. void SetTexture( TEXTUREINFO* pTextureInfo );
  51. void SetPipe( PIPE* pPipe );
  52. BOOL StartPipe();
  53. void KillPipe();
  54. };
  55. // Program existence instance
  56. class NORMAL_STATE;
  57. class FLEX_STATE;
  58. struct CONFIG;
  59. //-----------------------------------------------------------------------------
  60. // Name:
  61. // Desc:
  62. //-----------------------------------------------------------------------------
  63. class STATE
  64. {
  65. public:
  66. CONFIG* m_pConfig;
  67. BOOL m_bUseTexture; // global texture enable
  68. TEXTUREINFO m_textureInfo[MAX_TEXTURES];
  69. int m_nTextures;
  70. IDirect3DDevice8* m_pd3dDevice;
  71. ID3DXMatrixStack* m_pWorldMatrixStack;
  72. D3DLIGHT8 m_light;
  73. FLOAT m_fLastTime;
  74. PIPE* m_pLeadPipe; // lead pipe for chase scenarios
  75. int m_nSlices; // reference # of slices around a pipe
  76. IPOINT2D m_texRep[MAX_TEXTURES];
  77. VIEW m_view; // viewing parameters
  78. float m_radius; // 'reference' pipe radius value
  79. NODE_ARRAY* m_nodes; // for keeping track of draw space
  80. NORMAL_STATE* m_pNState;
  81. FLEX_STATE* m_pFState;
  82. LPDIRECT3DVERTEXBUFFER8 m_pClearVB;
  83. STATE( CONFIG* pConfig );
  84. ~STATE();
  85. void Reshape( int width, int height );
  86. void Repaint();
  87. HRESULT InitDeviceObjects( IDirect3DDevice8* pd3dDevice );
  88. HRESULT RestoreDeviceObjects();
  89. HRESULT InvalidateDeviceObjects();
  90. HRESULT DeleteDeviceObjects();
  91. HRESULT Render();
  92. HRESULT FrameMove( FLOAT fElapsedTime );
  93. private:
  94. int m_drawMode; // drawing mode (flex or normal for now)
  95. int m_drawScheme; // random or chase
  96. int m_maxPipesPerFrame; // max number of separate pipes/frame
  97. int m_nPipesDrawn; // number of pipes drawn or drawing in frame
  98. int m_maxDrawThreads; // max number of concurrently drawing pipes
  99. int m_nDrawThreads; // number of live threads
  100. DRAW_THREAD m_drawThreads[MAX_DRAW_THREADS];
  101. int m_resetStatus;
  102. HRESULT LoadTextureFiles( int nTextures, TCHAR strTextureFileNames[MAX_PATH][MAX_TEXTURES], int* anDefaultTextureResource );
  103. int PickRandomTexture( int iThread, int nTextures );
  104. BOOL Clear();
  105. void ChooseNewLeadPipe();
  106. void CompactThreadList();
  107. void GLInit();
  108. void DrawValidate(); // validation to do before each Draw
  109. void ResetView();
  110. BOOL FrameReset();
  111. void CalcTexRepFactors();
  112. int CalcMaxPipesPerFrame();
  113. };
  114. #endif // __state_h__