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.

229 lines
5.8 KiB

  1. #include <windows.h>
  2. #include <GL\gl.h>
  3. #include <GL\glu.h>
  4. #include <GL\glaux.h>
  5. #include "viewerres.h"
  6. #include "trackbal.h"
  7. #include "pmesh.h"
  8. #include <objbase.h>
  9. #include <initguid.h>
  10. /************************************************************************/
  11. /******************* Macros *********************************************/
  12. /************************************************************************/
  13. #define SCROLLBAR_PAGE 100
  14. #define SCROLLBAR_MIN 0
  15. #define SCROLLBAR_MAX 1000+(SCROLLBAR_PAGE-1)
  16. #define WIN_WIDTH 500
  17. #define WIN_HEIGHT 500
  18. #define WIN_X 10
  19. #define WIN_Y 10
  20. #define DEFHITHER 1 //0.1
  21. #define DEFYONDER 10 //1e30;
  22. #ifdef DEBUGGING
  23. char szDebugBuffer[80];
  24. #define DEBUG(parm1,parm2)\
  25. {\
  26. wsprintf(szDebugBuffer,parm1,parm2);\
  27. OutputDebugString(szDebugBuffer);\
  28. }
  29. #else
  30. #define DEBUG(parm1,parm2)
  31. #endif
  32. /************************************************************************/
  33. /******************* Enums **********************************************/
  34. /************************************************************************/
  35. /**** Enums ****/
  36. enum NormalMode {PER_VERTEX, PER_FACET, PER_OBJECT};
  37. enum TransformType {ORTHO_PROJECTION, PERSP_PROJECTION};
  38. /************************************************************************/
  39. /******************* Structs ********************************************/
  40. /************************************************************************/
  41. /**** Structs ****/
  42. typedef struct _ostate
  43. {
  44. } GLSTATE, *LPGLSTATE;
  45. typedef struct _Scene
  46. {
  47. GLfloat hither;
  48. GLfloat yon;
  49. GLfloat scale;
  50. GLfloat angle;
  51. int scroll_pos;
  52. GLfloat trans[3];
  53. GLfloat from[3];
  54. GLfloat to[3];
  55. GLfloat up[3];
  56. GLfloat aspect_ratio;
  57. GLfloat fov;
  58. GLfloat zoom;
  59. GLfloat max_vert[3];
  60. GLfloat min_vert[3];
  61. } SCENE, *LPSCENE;
  62. typedef struct _WInf
  63. {
  64. HWND hWnd;
  65. HMENU hMenu;
  66. POINT wPosition;
  67. POINT wCenter;
  68. SIZE wSize;
  69. HPALETTE hPalette;
  70. HPALETTE hOldPalette;
  71. HGLRC hRc;
  72. LONG rmouseX;
  73. LONG rmouseY;
  74. BOOL rmouse_down;
  75. LONG lmouseX;
  76. LONG lmouseY;
  77. BOOL lmouse_down;
  78. } WININFO, *LPWININFO;
  79. /************************************************************************/
  80. /******************* Windows Globals ************************************/
  81. /************************************************************************/
  82. /**** Externs ****/
  83. extern WININFO g_wi;
  84. extern SCENE g_s;
  85. /************************************************************************/
  86. /******************* Function Prototypes ********************************/
  87. /************************************************************************/
  88. /******** viewer.cxx *************/
  89. extern void CleanUpAndQuit (void);
  90. extern BOOL InitMainWindow (HINSTANCE, HINSTANCE, LPSTR, int);
  91. extern LONG APIENTRY GLWndProc(HWND, UINT, UINT, LONG);
  92. /******** glstuff.cxx ************/
  93. extern void Reshape (GLsizei, GLsizei);
  94. extern void SetViewWrap (GLsizei, GLsizei);
  95. extern void InitGL(void);
  96. extern void InitDrawing ();
  97. extern void CALLBACK DoGlStuff(void);
  98. extern void spin( HWND, HDC );
  99. extern void CleanupGL(HGLRC);
  100. extern void UpdateWinTitle (HWND);
  101. extern void spin(void);
  102. extern void ForceRedraw(HWND);
  103. extern char* OpenPMFile(HWND, const char *, int);
  104. extern void EnableLighting (void);
  105. extern void DisableLighting (void);
  106. extern void Key_up (void);
  107. extern void Key_down (void);
  108. extern void Key_i (void);
  109. extern void Key_z (void);
  110. extern void Key_Z (void);
  111. extern void Key_y (void);
  112. extern void Key_Y (void);
  113. extern void Key_x (void);
  114. extern void Key_X (void);
  115. extern BOOL FindPixelFormat(HDC);
  116. extern HPALETTE CreateRGBPalette( HDC hdc );
  117. /******** pm.cxx *****************/
  118. extern long RealizePaletteNow( HDC, HPALETTE, BOOL);
  119. extern int PixelFormatDescriptorFromDc( HDC, PIXELFORMATDESCRIPTOR * );
  120. /************************************************************************/
  121. /******************* OpenGL State ***************************************/
  122. /************************************************************************/
  123. /********** OpenGL State *************/
  124. extern BOOL renderDoubleBuffer;
  125. extern int colormode;
  126. extern enum NormalMode normal_mode;
  127. extern BOOL linesmooth_enable;
  128. extern BOOL polysmooth_enable;
  129. extern GLenum cull_face;
  130. extern GLenum front_face;
  131. extern BOOL cull_enable;
  132. extern BOOL depth_mode;
  133. extern BOOL fog_enable;
  134. extern BOOL clip_enable;
  135. extern GLenum shade_model;
  136. extern BOOL polystipple_enable;
  137. extern BOOL linestipple_enable;
  138. extern int matrixmode;
  139. extern enum TransformType tx_type;
  140. extern BOOL dither_enable;
  141. extern BOOL blend_enable;
  142. extern GLenum sblendfunc;
  143. extern GLenum dblendfunc;
  144. extern BOOL filled_mode;
  145. extern BOOL edge_mode;
  146. extern BOOL displaylist_mode;
  147. extern GLfloat linewidth;
  148. extern GLfloat hither;
  149. extern GLfloat yon;
  150. extern GLenum polymodefront;
  151. extern GLenum polymodeback;
  152. extern BOOL mblur_enable;
  153. extern GLfloat blur_amount;
  154. extern int fsantimode;
  155. extern int fsaredraw;
  156. extern GLfloat fsajitter;
  157. extern int cmface;
  158. extern int cmmode;
  159. extern int cmenable;
  160. extern BOOL tex_enable;
  161. extern BOOL texgen_enable;
  162. extern GLenum texenvmode;
  163. extern long tex_pack;
  164. extern int tex_row;
  165. extern int tex_col;
  166. extern int tex_index;
  167. extern int tex_xpix;
  168. extern int tex_ypix;
  169. extern int tex_numpix;
  170. extern int tex_numcomp;
  171. extern GLfloat tex_minfilter;
  172. extern GLfloat tex_magfilter;
  173. extern unsigned char *Image;
  174. extern unsigned char *TextureImage;
  175. extern BOOL light_enable;
  176. extern int numInfLights;
  177. extern int numLocalLights;
  178. extern BOOL lighttwoside;
  179. extern GLfloat localviewmode;
  180. extern float curquat[4];
  181. extern float lastquat[4];
  182. /************** PM related stuff **********/
  183. extern float pm_lod_level;
  184. extern float old_lod;
  185. extern BOOL pm_ready;
  186. extern LPPMESH pPMesh;
  187. extern LPPMESHGL pPMeshGL;