CmGLXUtils.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /*
  2. -----------------------------------------------------------------------------
  3. This source file is part of OGRE
  4. (Object-oriented Graphics Rendering Engine)
  5. For the latest info, see http://www.ogre3d.org/
  6. Copyright (c) 2000-2011 Torus Knot Software Ltd
  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. The above copyright notice and this permission notice shall be included in
  14. all copies or substantial portions of the Software.
  15. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  21. THE SOFTWARE.
  22. -----------------------------------------------------------------------------
  23. */
  24. #pragma once
  25. #include "CmPrerequisites.h"
  26. #include <GL/glew.h>
  27. #include <GL/glxew.h>
  28. namespace CamelotEngine
  29. {
  30. class GLXUtils
  31. {
  32. public:
  33. // Portable replacements for some GLX 1.3 function pointers
  34. static PFNGLXCHOOSEFBCONFIGPROC chooseFBConfig;
  35. static PFNGLXCREATENEWCONTEXTPROC createNewContext;
  36. static PFNGLXGETFBCONFIGATTRIBPROC getFBConfigAttrib;
  37. static PFNGLXGETVISUALFROMFBCONFIGPROC getVisualFromFBConfig;
  38. /**
  39. * Get the GLXFBConfig used to create a ::GLXContext
  40. *
  41. * @param display X Display
  42. * @param drawable GLXContext
  43. * @returns GLXFBConfig used to create the context
  44. */
  45. static GLXFBConfig getFBConfigFromContext (Display *display, ::GLXContext context);
  46. /**
  47. * Get the GLXFBConfig used to create a GLXDrawable.
  48. * Caveat: GLX version 1.3 is needed when the drawable is a GLXPixmap
  49. *
  50. * @param display X Display
  51. * @param drawable GLXDrawable
  52. * @param width Receiver for the drawable width
  53. * @param height Receiver for the drawable height
  54. * @returns GLXFBConfig used to create the drawable
  55. */
  56. static GLXFBConfig getFBConfigFromDrawable (Display *display, GLXDrawable drawable,
  57. unsigned int *width, unsigned int *height);
  58. /**
  59. * Initialise the parts of GLXEW needed to create a GL Context
  60. *
  61. * @param display X Display
  62. */
  63. static void initialiseGLXEW (Display *display);
  64. /**
  65. * Select an FBConfig given a list of required and a list of desired properties
  66. *
  67. * @param display X Display
  68. * @param minAttribs FBConfig attributes that must be provided with minimum values
  69. * @param maxAttribs FBConfig attributes that are preferred with maximum values
  70. * @returns GLXFBConfig with attributes or 0 when unsupported.
  71. */
  72. static GLXFBConfig selectFBConfig(Display *display, const int *minAttribs, const int *maxAttribs);
  73. /**
  74. * Loads an icon from an Ogre resource into the X Server. This currently only
  75. * works for 24 and 32 bit displays. The image must be findable by the Ogre
  76. * resource system, and of format PF_A8R8G8B8.
  77. *
  78. * @param display X display
  79. * @param name Name of image to load
  80. * @param pix Receiver for the output pixmap
  81. * @param mask Receiver for the output mask (alpha bitmap)
  82. * @returns true on success
  83. */
  84. static bool loadIcon(Display *display, const std::string &name, Pixmap *pix, Pixmap *mask);
  85. };
  86. };