Team Fortress 2 Source Code as on 22/4/2020
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.

201 lines
7.1 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. // TOGL CODE LICENSE
  3. //
  4. // Copyright 2011-2014 Valve Corporation
  5. // All Rights Reserved.
  6. //
  7. // Permission is hereby granted, free of charge, to any person obtaining a copy
  8. // of this software and associated documentation files (the "Software"), to deal
  9. // in the Software without restriction, including without limitation the rights
  10. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  11. // copies of the Software, and to permit persons to whom the Software is
  12. // furnished to do so, subject to the following conditions:
  13. //
  14. // The above copyright notice and this permission notice shall be included in
  15. // all copies or substantial portions of the Software.
  16. //
  17. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  18. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  19. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  20. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  21. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  22. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  23. // THE SOFTWARE.
  24. //
  25. // glmdisplay.h
  26. // display related stuff - used by both GLMgr and the CocoaMgr
  27. //
  28. //===============================================================================
  29. #ifndef GLMDISPLAY_H
  30. #define GLMDISPLAY_H
  31. #pragma once
  32. #ifdef USE_SDL
  33. #include "SDL_opengl.h"
  34. #endif
  35. #ifdef OSX
  36. #include <OpenGL/OpenGL.h>
  37. #include <OpenGL/gl.h>
  38. #include <OpenGL/CGLTypes.h>
  39. #include <OpenGL/CGLRenderers.h>
  40. #include <OpenGL/CGLCurrent.h>
  41. #endif
  42. #ifdef MAC_OS_X_VERSION_10_9
  43. typedef uint32_t CGDirectDisplayID;
  44. typedef uint32_t CGOpenGLDisplayMask;
  45. typedef double CGRefreshRate;
  46. #endif
  47. typedef void _PseudoNSGLContext; // aka NSOpenGLContext
  48. typedef _PseudoNSGLContext *PseudoNSGLContextPtr;
  49. struct GLMDisplayModeInfoFields
  50. {
  51. uint m_modePixelWidth;
  52. uint m_modePixelHeight;
  53. uint m_modeRefreshHz;
  54. // are we even going to talk about bit depth... not yet
  55. };
  56. struct GLMDisplayInfoFields
  57. {
  58. #ifdef OSX
  59. CGDirectDisplayID m_cgDisplayID;
  60. CGOpenGLDisplayMask m_glDisplayMask; // result of CGDisplayIDToOpenGLDisplayMask on the cg_displayID.
  61. #endif
  62. uint m_displayPixelWidth;
  63. uint m_displayPixelHeight;
  64. };
  65. struct GLMRendererInfoFields
  66. {
  67. /*properties of interest and their desired values.
  68. kCGLRPFullScreen = 54, true
  69. kCGLRPAccelerated = 73, true
  70. kCGLRPWindow = 80, true
  71. kCGLRPRendererID = 70, informational
  72. kCGLRPDisplayMask = 84, informational
  73. kCGLRPBufferModes = 100, informational
  74. kCGLRPColorModes = 103, informational
  75. kCGLRPAccumModes = 104, informational
  76. kCGLRPDepthModes = 105, informational
  77. kCGLRPStencilModes = 106, informational
  78. kCGLRPMaxAuxBuffers = 107, informational
  79. kCGLRPMaxSampleBuffers = 108, informational
  80. kCGLRPMaxSamples = 109, informational
  81. kCGLRPSampleModes = 110, informational
  82. kCGLRPSampleAlpha = 111, informational
  83. kCGLRPVideoMemory = 120, informational
  84. kCGLRPTextureMemory = 121, informational
  85. kCGLRPRendererCount = 128 number of renderers in the CGLRendererInfoObj under examination
  86. kCGLRPOffScreen = 53, D/C
  87. kCGLRPRobust = 75, FALSE or D/C - aka we're asking for no-fallback
  88. kCGLRPBackingStore = 76, D/C
  89. kCGLRPMPSafe = 78, D/C
  90. kCGLRPMultiScreen = 81, D/C
  91. kCGLRPCompliant = 83, D/C
  92. */
  93. //--------------------------- info we have from CGL renderer queries, IOKit, Gestalt
  94. //--------------------------- these are set up in the displayDB by CocoaMgr
  95. GLint m_fullscreen;
  96. GLint m_accelerated;
  97. GLint m_windowed;
  98. GLint m_rendererID;
  99. GLint m_displayMask;
  100. GLint m_bufferModes;
  101. GLint m_colorModes;
  102. GLint m_accumModes;
  103. GLint m_depthModes;
  104. GLint m_stencilModes;
  105. GLint m_maxAuxBuffers;
  106. GLint m_maxSampleBuffers;
  107. GLint m_maxSamples;
  108. GLint m_sampleModes;
  109. GLint m_sampleAlpha;
  110. GLint m_vidMemory;
  111. GLint m_texMemory;
  112. uint m_pciVendorID;
  113. uint m_pciDeviceID;
  114. char m_pciModelString[64];
  115. char m_driverInfoString[64];
  116. //--------------------------- OS version related - set up by CocoaMgr
  117. // OS version found
  118. uint m_osComboVersion; // 0x00XXYYZZ : XX major, YY minor, ZZ minor minor : 10.6.3 --> 0x000A0603. 10.5.8 --> 0x000A0508.
  119. //--------------------------- shorthands - also set up by CocoaMgr - driven by vendorid / deviceid
  120. bool m_ati;
  121. bool m_atiR5xx;
  122. bool m_atiR6xx;
  123. bool m_atiR7xx;
  124. bool m_atiR8xx;
  125. bool m_atiNewer;
  126. bool m_intel;
  127. bool m_intel95x;
  128. bool m_intel3100;
  129. bool m_intelHD4000;
  130. bool m_nv;
  131. bool m_nvG7x;
  132. bool m_nvG8x;
  133. bool m_nvNewer;
  134. //--------------------------- context query results - left blank in the display DB - but valid in a GLMContext (call ctx->Caps() to get a const ref)
  135. // booleans
  136. bool m_hasGammaWrites; // aka glGetBooleanv(GL_FRAMEBUFFER_SRGB_CAPABLE_EXT) / glEnable(GL_FRAMEBUFFER_SRGB_EXT)
  137. bool m_hasMixedAttachmentSizes; // aka ARB_fbo in 10.6.3 - test for min OS vers, then exported ext string
  138. bool m_hasBGRA; // aka GL_BGRA vertex attribs in 10.6.3 - - test for min OS vers, then exported ext string
  139. bool m_hasNewFullscreenMode; // aka 10.6.x "big window" fullscreen mode
  140. bool m_hasNativeClipVertexMode; // aka GLSL gl_ClipVertex does not fall back to SW- OS version and folklore-based
  141. bool m_hasOcclusionQuery; // occlusion query: do you speak it ?!
  142. bool m_hasFramebufferBlit; // framebuffer blit: know what I'm sayin?!
  143. bool m_hasPerfPackage1; // means new MTGL, fast OQ, fast uniform upload, NV can resolve flipped (late summer 2010 post 10.6.4 update)
  144. // counts
  145. int m_maxAniso; // aniso limit - context query
  146. // other exts
  147. bool m_hasBindableUniforms;
  148. int m_maxVertexBindableUniforms;
  149. int m_maxFragmentBindableUniforms;
  150. int m_maxBindableUniformSize;
  151. bool m_hasUniformBuffers;
  152. // runtime options that aren't negotiable once set
  153. bool m_hasDualShaders; // must supply CLI arg "-glmdualshaders" or we go GLSL only
  154. //--------------------------- " can'ts " - specific problems that need to be worked around
  155. bool m_cantBlitReliably; // Intel chipsets have problems blitting sRGB sometimes
  156. bool m_cantAttachSRGB; // NV G8x on 10.5.8 can't have srgb tex on FBO color - separate issue from hasGammaWrites
  157. bool m_cantResolveFlipped; // happens on NV in 10.6.4 and prior - console variable "gl_can_resolve_flipped" can overrule
  158. bool m_cantResolveScaled; // happens everywhere per GL spec but may be relaxed some day - console variable "gl_can_resolve_scaled" can overrule
  159. bool m_costlyGammaFlips; // this means that sRGB sampling state affects shader code gen, resulting in state-dependent code regen
  160. //--------------------------- " bads " - known bad drivers
  161. bool m_badDriver1064NV; // this is the bad NVIDIA driver on 10.6.4 - stutter, tex corruption, black screen issues
  162. bool m_badDriver108Intel; // this is the bad Intel HD4000 driver on 10.8 - intermittent crash on GLSL compilation.
  163. };
  164. #endif