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.

302 lines
7.3 KiB

  1. /******************************Module*Header*******************************\
  2. * Module Name: mtk.h
  3. *
  4. * Defines and externals for m toolkit
  5. *
  6. * Copyright (c) 1997 Microsoft Corporation
  7. *
  8. \**************************************************************************/
  9. #ifndef __mtk_h__
  10. #define __mtk_h__
  11. #include <windows.h>
  12. #include <assert.h>
  13. #include "tk.h"
  14. #ifdef __cplusplus
  15. extern "C" {
  16. #endif
  17. #include "mtkdebug.h"
  18. #include "trackbal.h"
  19. #define FAILURE 0
  20. #define SUCCESS 1
  21. // Maximum texture bitmap dimensions.
  22. #define TEX_WIDTH_MAX 1280
  23. #define TEX_HEIGHT_MAX 1024
  24. #define PI 3.14159265358979323846f
  25. // double version of PI
  26. #define PI_D 3.14159265358979323846264338327950288419716939937510
  27. #define ONE_OVER_PI (1.0f / PI)
  28. #define ROOT_TWO 1.414213562373f
  29. #define GEN_STRING_SIZE 64
  30. // texture quality level
  31. enum {
  32. TEXQUAL_DEFAULT = 0,
  33. TEXQUAL_HIGH
  34. };
  35. typedef struct _point2d {
  36. GLfloat x;
  37. GLfloat y;
  38. } POINT2D;
  39. typedef struct _ipoint2d {
  40. int x;
  41. int y;
  42. } IPOINT2D;
  43. typedef struct _point3d {
  44. GLfloat x;
  45. GLfloat y;
  46. GLfloat z;
  47. } POINT3D;
  48. typedef struct _dpoint3d {
  49. GLdouble x;
  50. GLdouble y;
  51. GLdouble z;
  52. } DPOINT3D;
  53. typedef struct _ipoint3d {
  54. int x;
  55. int y;
  56. int z;
  57. } IPOINT3D;
  58. typedef struct _texpoint2d {
  59. GLfloat s;
  60. GLfloat t;
  61. } TEX_POINT2D;
  62. typedef struct _isize {
  63. int width;
  64. int height;
  65. } ISIZE;
  66. typedef struct _fsize {
  67. GLfloat width;
  68. GLfloat height;
  69. } FSIZE;
  70. typedef struct _glrect {
  71. float x, y;
  72. float width, height;
  73. } GLRECT;
  74. typedef struct _glirect {
  75. int x, y;
  76. int width, height;
  77. } GLIRECT;
  78. #ifndef GL_EXT_paletted_texture
  79. #define GL_COLOR_INDEX1_EXT 0x80E2
  80. #define GL_COLOR_INDEX2_EXT 0x80E3
  81. #define GL_COLOR_INDEX4_EXT 0x80E4
  82. #define GL_COLOR_INDEX8_EXT 0x80E5
  83. #define GL_COLOR_INDEX12_EXT 0x80E6
  84. #define GL_COLOR_INDEX16_EXT 0x80E7
  85. typedef void (APIENTRY * PFNGLCOLORTABLEEXTPROC)
  86. (GLenum target, GLenum internalFormat, GLsizei width, GLenum format,
  87. GLenum type, const GLvoid *data);
  88. typedef void (APIENTRY * PFNGLCOLORSUBTABLEEXTPROC)
  89. (GLenum target, GLsizei start, GLsizei count, GLenum format,
  90. GLenum type, GLvoid *data);
  91. #endif
  92. // texture resource
  93. #define RT_RGB 99
  94. #define RT_MYBMP 100
  95. #define RT_A8 101
  96. // texture resource types
  97. enum {
  98. TEX_UNKNOWN = 0,
  99. TEX_RGB,
  100. TEX_BMP,
  101. TEX_A8
  102. };
  103. typedef struct {
  104. int type;
  105. int name;
  106. } TEX_RES;
  107. typedef struct _MATRIX {
  108. GLfloat M[4][4];
  109. } MATRIX;
  110. typedef struct strRGBA {
  111. GLfloat r;
  112. GLfloat g;
  113. GLfloat b;
  114. GLfloat a;
  115. } RGBA;
  116. typedef struct {
  117. BYTE r;
  118. BYTE g;
  119. BYTE b;
  120. } RGB8;
  121. typedef struct {
  122. BYTE r;
  123. BYTE g;
  124. BYTE b;
  125. BYTE a;
  126. } RGBA8;
  127. // Defines for pixel format (internal use)
  128. #define SS_DOUBLEBUF_BIT (1 << 0)
  129. #define SS_DEPTH16_BIT (1 << 1)
  130. #define SS_DEPTH32_BIT (1 << 2)
  131. #define SS_ALPHA_BIT (1 << 3)
  132. #define SS_BITMAP_BIT (1 << 4)
  133. #define SS_NO_SYSTEM_PALETTE_BIT (1 << 5)
  134. #define SS_GENERIC_UNACCELERATED_BIT (1 << 6)
  135. #define SS_HAS_DOUBLEBUF(x) ((x) & SS_DOUBLEBUF_BIT)
  136. #define SS_HAS_DEPTH16(x) ((x) & SS_DEPTH16_BIT)
  137. #define SS_HAS_DEPTH32(x) ((x) & SS_DEPTH32_BIT)
  138. #define SS_HAS_ALPHA(x) ((x) & SS_ALPHA_BIT)
  139. #define SS_HAS_BITMAP(x) ((x) & SS_BITMAP_BIT)
  140. typedef struct _MATERIAL {
  141. RGBA ka;
  142. RGBA kd;
  143. RGBA ks;
  144. GLfloat specExp;
  145. } MATERIAL;
  146. // texture file info
  147. //mf: !!!, uhhh not yet
  148. #if 1
  149. typedef struct {
  150. int nOffset; // filename offset into pathname
  151. TCHAR szPathName[MAX_PATH]; // texture pathname
  152. } TEXFILE;
  153. #else
  154. typedef struct {
  155. int nOffset; // filename offset into pathname
  156. LPTSTR szPathName;
  157. } TEXFILE;
  158. #endif
  159. // Useful macros
  160. #define SS_MAX( a, b ) \
  161. ( a > b ? a : b )
  162. #define SS_MIN( a, b ) \
  163. ( a < b ? a : b )
  164. // macro to round up floating values
  165. #define SS_ROUND_UP( fval ) \
  166. ( (((fval) - (FLOAT)(int)(fval)) > 0.0f) ? (int) ((fval)+1.0f) : (int) (fval) )
  167. // macros to clamp a value within a range
  168. #define SS_CLAMP_TO_RANGE( a, lo, hi ) ( (a < lo) ? lo : ((a > hi) ? hi : a) )
  169. #define SS_CLAMP_TO_RANGE2( a, lo, hi ) \
  170. ( a = (a < lo) ? lo : ((a > hi) ? hi : a) )
  171. // degree<->radian macros
  172. #define ONE_OVER_180 (1.0f / 180.0f)
  173. #define SS_DEG_TO_RAD( a ) ( (a*PI) * ONE_OVER_180 )
  174. #define SS_RAD_TO_DEG( a ) ( (a*180.0f) * ONE_OVER_PI )
  175. // window related
  176. extern void mtkQuit(); // Harsh way to kill the app
  177. //extern int mtk_Exec(); // like tkExec()
  178. // pixel forat
  179. extern BOOL SSU_SetupPixelFormat( HDC hdc, int flags, PIXELFORMATDESCRIPTOR *ppfd );
  180. extern BOOL SSU_bNeedPalette( PIXELFORMATDESCRIPTOR *ppfd );
  181. extern int SSU_PixelFormatDescriptorFromDc( HDC Dc, PIXELFORMATDESCRIPTOR *Pfd );
  182. // material processing
  183. extern void ss_InitTeaMaterials();
  184. extern void ss_InitTexMaterials();
  185. extern void ss_InitMaterials();
  186. extern void ss_SetMaterial( MATERIAL *pMat );
  187. extern void ss_SetMaterialIndex( int index );
  188. extern MATERIAL *ss_RandomTeaMaterial( BOOL bSet );
  189. extern int ss_RandomTeaMaterialIndex( BOOL bSet );
  190. extern MATERIAL *ss_RandomTexMaterial( BOOL bSet );
  191. extern int ss_RandomTexMaterialIndex( BOOL bSet );
  192. extern void ss_CreateMaterialGradient( MATERIAL *matInc, MATERIAL *startMat,
  193. MATERIAL *endMat, int transCount );
  194. extern void ss_TransitionMaterial( MATERIAL *transMat, MATERIAL *transMatInc );
  195. // color
  196. extern void ss_HsvToRgb(float h, float s, float v, RGBA *color );
  197. // clear
  198. extern int mtk_RectWipeClear( int width, int height, int repCount );
  199. extern int mtk_DigitalDissolveClear( int width, int height, int size );
  200. // utility
  201. extern void ss_RandInit( void );
  202. extern int ss_iRand( int max );
  203. extern int ss_iRand2( int min, int max );
  204. extern FLOAT ss_fRand( FLOAT min, FLOAT max );
  205. extern BOOL mtk_ChangeDisplaySettings( int width, int height, int bitDepth );
  206. extern void mtk_RestoreDisplaySettings();
  207. extern void ss_QueryDisplaySettings( void );
  208. extern void mtk_QueryGLVersion( void );
  209. extern BOOL mtk_fOnWin95( void );
  210. extern BOOL mtk_fOnNT35( void );
  211. extern BOOL mtk_fOnGL11( void );
  212. extern BOOL mtk_bAddSwapHintRect();
  213. extern HBITMAP
  214. SSDIB_CreateCompatibleDIB(HDC hdc, HPALETTE hpal, ULONG ulWidth, ULONG ulHeight,
  215. PVOID *ppvBits);
  216. extern BOOL APIENTRY SSDIB_UpdateColorTable(HDC hdcMem, HDC hdc, HPALETTE hpal);
  217. // texture file processing
  218. extern BOOL mtk_VerifyTextureFilePath( TEXFILE *ptf );
  219. extern BOOL mtk_VerifyTextureFileData( TEXFILE *ptf );
  220. extern void mtk_InitAutoTexture( TEX_POINT2D *pTexRep );
  221. // texture objects
  222. extern BOOL mtk_TextureObjectsEnabled( void );
  223. // Paletted texture support
  224. extern BOOL mtk_PalettedTextureEnabled(void);
  225. extern BOOL mtk_QueryPalettedTextureEXT(void);
  226. // math functions
  227. extern POINT3D ss_ptZero;
  228. extern void ss_xformPoint(POINT3D *ptOut, POINT3D *ptIn, MATRIX *);
  229. extern void ss_xformNorm(POINT3D *ptOut, POINT3D *ptIn, MATRIX *);
  230. extern void ss_matrixIdent(MATRIX *);
  231. extern void ss_matrixRotate(MATRIX *m, double xTheta, double yTheta, double zTheta);
  232. extern void ss_matrixTranslate(MATRIX *, double xTrans, double yTrans, double zTrans);
  233. extern void ss_matrixMult( MATRIX *m1, MATRIX *m2, MATRIX *m3 );
  234. extern void ss_calcNorm(POINT3D *norm, POINT3D *p1, POINT3D *p2, POINT3D *p3);
  235. extern void mtk_NormalizePoints(POINT3D *, ULONG);
  236. #ifdef __cplusplus
  237. }
  238. #endif
  239. #endif // __mtk_h__