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.

143 lines
3.4 KiB

  1. /******************************Module*Header*******************************\
  2. * Module Name: glutil.cxx
  3. *
  4. * Misc. utility functions
  5. *
  6. * Copyright (c) 1996 Microsoft Corporation
  7. *
  8. \**************************************************************************/
  9. #include <stdio.h>
  10. #include <string.h>
  11. #include <stdlib.h>
  12. #include <windows.h>
  13. #include <GL/gl.h>
  14. #include <sys/types.h>
  15. #include <math.h>
  16. #include "mtk.h"
  17. #include "glutil.hxx"
  18. MTK_OS_INFO gOSInfo;
  19. MTK_GL_CAPS gGLCaps; // this should be per context, eventually
  20. void (__stdcall *glAddSwapHintRect)(GLint, GLint, GLint, GLint);
  21. /******************************Public*Routine******************************\
  22. * ss_fOnGL11
  23. *
  24. * True if running on OpenGL v.1.1x
  25. *
  26. \**************************************************************************/
  27. BOOL
  28. mtk_fOnGL11( void )
  29. {
  30. return gGLCaps.bGLv1_1;
  31. }
  32. /******************************Public*Routine******************************\
  33. * ss_fOnNT35
  34. *
  35. * True if running on NT version 3.51 or less
  36. *
  37. \**************************************************************************/
  38. BOOL
  39. mtk_fOnNT35( void )
  40. {
  41. return gOSInfo.fOnNT35;
  42. }
  43. /******************************Public*Routine******************************\
  44. * ss_fOnWin95
  45. *
  46. * True if running on Windows 95
  47. *
  48. \**************************************************************************/
  49. BOOL
  50. mtk_fOnWin95( void )
  51. {
  52. return gOSInfo.fOnWin95;
  53. }
  54. /******************************Public*Routine******************************\
  55. * MyAddSwapHintRect
  56. *
  57. \**************************************************************************/
  58. static void _stdcall
  59. MyAddSwapHintRect(GLint xs, GLint ys, GLint xe, GLint ye)
  60. {
  61. return;
  62. }
  63. /******************************Public*Routine******************************\
  64. * QueryAddSwapHintRectWIN
  65. *
  66. \**************************************************************************/
  67. //mf: again, per context problem
  68. BOOL
  69. mtk_QueryAddSwapHintRect()
  70. {
  71. glAddSwapHintRect = (PFNGLADDSWAPHINTRECTWINPROC)
  72. wglGetProcAddress("glAddSwapHintRectWIN");
  73. if (glAddSwapHintRect == NULL) {
  74. glAddSwapHintRect = MyAddSwapHintRect;
  75. return FALSE;
  76. }
  77. return TRUE;
  78. }
  79. /******************************Public*Routine******************************\
  80. * mtk_bAddSwapHintRect()
  81. *
  82. \**************************************************************************/
  83. BOOL
  84. mtk_bAddSwapHintRect()
  85. {
  86. return gGLCaps.bAddSwapHintRect;
  87. }
  88. /******************************Public*Routine******************************\
  89. \**************************************************************************/
  90. MTK_OS_INFO::MTK_OS_INFO()
  91. {
  92. osvi.dwOSVersionInfoSize = sizeof(osvi);
  93. GetVersionEx(&osvi);
  94. fOnWin95 = (osvi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS);
  95. fOnNT35 =
  96. (
  97. (osvi.dwPlatformId == VER_PLATFORM_WIN32_NT) &&
  98. (osvi.dwMajorVersion == 3 && osvi.dwMinorVersion <= 51)
  99. );
  100. }
  101. /******************************Public*Routine******************************\
  102. \**************************************************************************/
  103. MTK_GL_CAPS::MTK_GL_CAPS()
  104. {
  105. bGLv1_1 = FALSE;
  106. bTextureObjects = FALSE;
  107. bAddSwapHintRect = FALSE;
  108. bPalettedTexture = FALSE;
  109. }
  110. void
  111. MTK_GL_CAPS::Query()
  112. {
  113. bGLv1_1 = (BOOL) strstr( (char *) glGetString(GL_VERSION), "1.1" );
  114. if( bGLv1_1 )
  115. bTextureObjects = TRUE;
  116. if( !bTextureObjects )
  117. SS_DBGINFO( "MTK_GL_CAPS: Texture Objects disabled\n" );
  118. bAddSwapHintRect = mtk_QueryAddSwapHintRect();
  119. bPalettedTexture = mtk_QueryPalettedTextureEXT();
  120. }