Commit bf9456c5a2d8dfe9a35a2175186630cb426858ad
- Diff rendering mode:
- inline
- side by side
src/opengl/qgl.cpp
(24 / 23)
|   | |||
| 4822 | 4822 | ||
| 4823 | 4823 | void QGLExtensions::init_extensions() | |
| 4824 | 4824 | { | |
| 4825 | QList<QByteArray> extensions = QByteArray(reinterpret_cast<const char *>(glGetString(GL_EXTENSIONS))).split(' '); | ||
| 4826 | if (extensions.contains("GL_ARB_texture_rectangle")) | ||
| 4825 | QGLExtensionMatcher extensions(reinterpret_cast<const char *>(glGetString(GL_EXTENSIONS))); | ||
| 4826 | |||
| 4827 | if (extensions.match("GL_ARB_texture_rectangle")) | ||
| 4827 | 4828 | glExtensions |= TextureRectangle; | |
| 4828 | if (extensions.contains("GL_ARB_multisample")) | ||
| 4829 | if (extensions.match("GL_ARB_multisample")) | ||
| 4829 | 4830 | glExtensions |= SampleBuffers; | |
| 4830 | if (extensions.contains("GL_SGIS_generate_mipmap")) | ||
| 4831 | if (extensions.match("GL_SGIS_generate_mipmap")) | ||
| 4831 | 4832 | glExtensions |= GenerateMipmap; | |
| 4832 | if (extensions.contains("GL_ARB_texture_compression")) | ||
| 4833 | if (extensions.match("GL_ARB_texture_compression")) | ||
| 4833 | 4834 | glExtensions |= TextureCompression; | |
| 4834 | if (extensions.contains("GL_EXT_texture_compression_s3tc")) | ||
| 4835 | if (extensions.match("GL_EXT_texture_compression_s3tc")) | ||
| 4835 | 4836 | glExtensions |= DDSTextureCompression; | |
| 4836 | if (extensions.contains("GL_OES_compressed_ETC1_RGB8_texture")) | ||
| 4837 | if (extensions.match("GL_OES_compressed_ETC1_RGB8_texture")) | ||
| 4837 | 4838 | glExtensions |= ETC1TextureCompression; | |
| 4838 | if (extensions.contains("GL_IMG_texture_compression_pvrtc")) | ||
| 4839 | if (extensions.match("GL_IMG_texture_compression_pvrtc")) | ||
| 4839 | 4840 | glExtensions |= PVRTCTextureCompression; | |
| 4840 | if (extensions.contains("GL_ARB_fragment_program")) | ||
| 4841 | if (extensions.match("GL_ARB_fragment_program")) | ||
| 4841 | 4842 | glExtensions |= FragmentProgram; | |
| 4842 | if (extensions.contains("GL_ARB_fragment_shader")) | ||
| 4843 | if (extensions.match("GL_ARB_fragment_shader")) | ||
| 4843 | 4844 | glExtensions |= FragmentShader; | |
| 4844 | if (extensions.contains("GL_ARB_texture_mirrored_repeat")) | ||
| 4845 | if (extensions.match("GL_ARB_texture_mirrored_repeat")) | ||
| 4845 | 4846 | glExtensions |= MirroredRepeat; | |
| 4846 | if (extensions.contains("GL_EXT_framebuffer_object")) | ||
| 4847 | if (extensions.match("GL_EXT_framebuffer_object")) | ||
| 4847 | 4848 | glExtensions |= FramebufferObject; | |
| 4848 | if (extensions.contains("GL_EXT_stencil_two_side")) | ||
| 4849 | if (extensions.match("GL_EXT_stencil_two_side")) | ||
| 4849 | 4850 | glExtensions |= StencilTwoSide; | |
| 4850 | if (extensions.contains("GL_EXT_stencil_wrap")) | ||
| 4851 | if (extensions.match("GL_EXT_stencil_wrap")) | ||
| 4851 | 4852 | glExtensions |= StencilWrap; | |
| 4852 | if (extensions.contains("GL_EXT_packed_depth_stencil")) | ||
| 4853 | if (extensions.match("GL_EXT_packed_depth_stencil")) | ||
| 4853 | 4854 | glExtensions |= PackedDepthStencil; | |
| 4854 | if (extensions.contains("GL_NV_float_buffer")) | ||
| 4855 | if (extensions.match("GL_NV_float_buffer")) | ||
| 4855 | 4856 | glExtensions |= NVFloatBuffer; | |
| 4856 | if (extensions.contains("GL_ARB_pixel_buffer_object")) | ||
| 4857 | if (extensions.match("GL_ARB_pixel_buffer_object")) | ||
| 4857 | 4858 | glExtensions |= PixelBufferObject; | |
| 4858 | 4859 | #if defined(QT_OPENGL_ES_2) | |
| 4859 | 4860 | glExtensions |= FramebufferObject; | |
| … | … | ||
| 4862 | 4862 | glExtensions |= FragmentShader; | |
| 4863 | 4863 | #endif | |
| 4864 | 4864 | #if defined(QT_OPENGL_ES_1) || defined(QT_OPENGL_ES_1_CL) | |
| 4865 | if (extensions.contains("GL_OES_framebuffer_object")) | ||
| 4865 | if (extensions.match("GL_OES_framebuffer_object")) | ||
| 4866 | 4866 | glExtensions |= FramebufferObject; | |
| 4867 | 4867 | #endif | |
| 4868 | 4868 | #if defined(QT_OPENGL_ES) | |
| 4869 | if (extensions.contains("GL_OES_packed_depth_stencil")) | ||
| 4869 | if (extensions.match("GL_OES_packed_depth_stencil")) | ||
| 4870 | 4870 | glExtensions |= PackedDepthStencil; | |
| 4871 | 4871 | #endif | |
| 4872 | if (extensions.contains("GL_ARB_framebuffer_object")) { | ||
| 4872 | if (extensions.match("GL_ARB_framebuffer_object")) { | ||
| 4873 | 4873 | // ARB_framebuffer_object also includes EXT_framebuffer_blit. | |
| 4874 | 4874 | glExtensions |= FramebufferObject; | |
| 4875 | 4875 | glExtensions |= FramebufferBlit; | |
| 4876 | 4876 | } | |
| 4877 | 4877 | ||
| 4878 | if (extensions.contains("GL_EXT_framebuffer_blit")) | ||
| 4878 | if (extensions.match("GL_EXT_framebuffer_blit")) | ||
| 4879 | 4879 | glExtensions |= FramebufferBlit; | |
| 4880 | 4880 | ||
| 4881 | if (extensions.contains("GL_ARB_texture_non_power_of_two")) | ||
| 4881 | if (extensions.match("GL_ARB_texture_non_power_of_two")) | ||
| 4882 | 4882 | glExtensions |= NPOTTextures; | |
| 4883 | 4883 | ||
| 4884 | if (extensions.contains("GL_EXT_bgra")) | ||
| 4884 | if (extensions.match("GL_EXT_bgra")) | ||
| 4885 | 4885 | glExtensions |= BGRATextureFormat; | |
| 4886 | 4886 | } | |
| 4887 | 4887 |
src/opengl/qgl_p.h
(43 / 0)
|   | |||
| 610 | 610 | friend class QGLContextGroup; | |
| 611 | 611 | }; | |
| 612 | 612 | ||
| 613 | |||
| 614 | // This class can be used to match GL extensions with doing any mallocs. The | ||
| 615 | // class assumes that the GL extension string ends with a space character, | ||
| 616 | // which it should do on all conformant platforms. Create the object and pass | ||
| 617 | // in a pointer to the extension string, then call match() on each extension | ||
| 618 | // that should be matched. The match() function takes the extension name | ||
| 619 | // *without* the terminating space character as input. | ||
| 620 | |||
| 621 | class QGLExtensionMatcher | ||
| 622 | { | ||
| 623 | public: | ||
| 624 | QGLExtensionMatcher(const char *str) | ||
| 625 | : gl_extensions(str), gl_extensions_length(qstrlen(str)) | ||
| 626 | {} | ||
| 627 | |||
| 628 | bool match(const char *str) { | ||
| 629 | int str_length = qstrlen(str); | ||
| 630 | const char *extensions = gl_extensions; | ||
| 631 | int extensions_length = gl_extensions_length; | ||
| 632 | |||
| 633 | while (1) { | ||
| 634 | // the total length that needs to be matched is the str_length + | ||
| 635 | // the space character that terminates the extension name | ||
| 636 | if (extensions_length < str_length + 1) | ||
| 637 | return false; | ||
| 638 | if (qstrncmp(extensions, str, str_length) == 0 && extensions[str_length] == ' ') | ||
| 639 | return true; | ||
| 640 | |||
| 641 | int split_pos = 0; | ||
| 642 | while (split_pos < extensions_length && extensions[split_pos] != ' ') | ||
| 643 | ++split_pos; | ||
| 644 | ++split_pos; // added for the terminating space character | ||
| 645 | extensions += split_pos; | ||
| 646 | extensions_length -= split_pos; | ||
| 647 | } | ||
| 648 | return false; | ||
| 649 | } | ||
| 650 | |||
| 651 | private: | ||
| 652 | const char *gl_extensions; | ||
| 653 | int gl_extensions_length; | ||
| 654 | }; | ||
| 655 | |||
| 613 | 656 | QT_END_NAMESPACE | |
| 614 | 657 | ||
| 615 | 658 | #endif // QGL_P_H |
src/opengl/qgl_x11.cpp
(12 / 12)
|   | |||
| 343 | 343 | static bool triedResolvingGlxGetProcAddress = false; | |
| 344 | 344 | if (!triedResolvingGlxGetProcAddress) { | |
| 345 | 345 | triedResolvingGlxGetProcAddress = true; | |
| 346 | QList<QByteArray> glxExt = QByteArray(glXGetClientString(QX11Info::display(), GLX_EXTENSIONS)).split(' '); | ||
| 347 | if (glxExt.contains("GLX_ARB_get_proc_address")) { | ||
| 346 | QGLExtensionMatcher extensions(glXGetClientString(QX11Info::display(), GLX_EXTENSIONS)); | ||
| 347 | if (extensions.match("GLX_ARB_get_proc_address")) { | ||
| 348 | 348 | #if defined(Q_OS_LINUX) || defined(Q_OS_BSD4) | |
| 349 | 349 | void *handle = dlopen(NULL, RTLD_LAZY); | |
| 350 | 350 | if (handle) { | |
| … | … | ||
| 523 | 523 | if (!d->gpm) | |
| 524 | 524 | return false; | |
| 525 | 525 | } | |
| 526 | QList<QByteArray> glxExt = QByteArray(glXQueryExtensionsString(xinfo->display(), xinfo->screen())).split(' '); | ||
| 527 | if (glxExt.contains("GLX_SGI_video_sync")) { | ||
| 526 | QGLExtensionMatcher extensions(glXQueryExtensionsString(xinfo->display(), xinfo->screen())); | ||
| 527 | if (extensions.match("GLX_SGI_video_sync")) { | ||
| 528 | 528 | if (d->glFormat.swapInterval() == -1) | |
| 529 | 529 | d->glFormat.setSwapInterval(0); | |
| 530 | 530 | } else { | |
| … | … | ||
| 630 | 630 | static bool useTranspExt = false; | |
| 631 | 631 | static bool useTranspExtChecked = false; | |
| 632 | 632 | if (f.plane() && !useTranspExtChecked && d->paintDevice) { | |
| 633 | QByteArray estr(glXQueryExtensionsString(xinfo->display(), xinfo->screen())); | ||
| 634 | useTranspExt = estr.contains("GLX_EXT_visual_info"); | ||
| 633 | QGLExtensionMatcher extensions(glXQueryExtensionsString(xinfo->display(), xinfo->screen())); | ||
| 634 | useTranspExt = extensions.match("GLX_EXT_visual_info"); | ||
| 635 | 635 | //# (A bit simplistic; that could theoretically be a substring) | |
| 636 | 636 | if (useTranspExt) { | |
| 637 | 637 | QByteArray cstr(glXGetClientString(xinfo->display(), GLX_VENDOR)); | |
| … | … | ||
| 875 | 875 | static bool resolved = false; | |
| 876 | 876 | if (!resolved) { | |
| 877 | 877 | const QX11Info *xinfo = qt_x11Info(d->paintDevice); | |
| 878 | QList<QByteArray> glxExt = QByteArray(glXQueryExtensionsString(xinfo->display(), xinfo->screen())).split(' '); | ||
| 879 | if (glxExt.contains("GLX_SGI_video_sync")) { | ||
| 878 | QGLExtensionMatcher extensions(glXQueryExtensionsString(xinfo->display(), xinfo->screen())); | ||
| 879 | if (extensions.match("GLX_SGI_video_sync")) { | ||
| 880 | 880 | glXGetVideoSyncSGI = (qt_glXGetVideoSyncSGI)qglx_getProcAddress("glXGetVideoSyncSGI"); | |
| 881 | 881 | glXWaitVideoSyncSGI = (qt_glXWaitVideoSyncSGI)qglx_getProcAddress("glXWaitVideoSyncSGI"); | |
| 882 | 882 | } | |
| … | … | ||
| 1107 | 1107 | if (resolved && !glXGetProcAddressARB) | |
| 1108 | 1108 | return 0; | |
| 1109 | 1109 | if (!glXGetProcAddressARB) { | |
| 1110 | QList<QByteArray> glxExt = QByteArray(glXGetClientString(QX11Info::display(), GLX_EXTENSIONS)).split(' '); | ||
| 1111 | if (glxExt.contains("GLX_ARB_get_proc_address")) { | ||
| 1110 | QGLExtensionMatcher extensions(glXGetClientString(QX11Info::display(), GLX_EXTENSIONS)); | ||
| 1111 | if (extensions.match("GLX_ARB_get_proc_address")) { | ||
| 1112 | 1112 | #if defined(Q_OS_LINUX) || defined(Q_OS_BSD4) | |
| 1113 | 1113 | void *handle = dlopen(NULL, RTLD_LAZY); | |
| 1114 | 1114 | if (handle) { | |
| … | … | ||
| 1609 | 1609 | return false; // Can't use TFP without NPOT | |
| 1610 | 1610 | } | |
| 1611 | 1611 | const QX11Info *xinfo = qt_x11Info(paintDevice); | |
| 1612 | QList<QByteArray> glxExt = QByteArray(glXQueryExtensionsString(xinfo->display(), xinfo->screen())).split(' '); | ||
| 1613 | if (glxExt.contains("GLX_EXT_texture_from_pixmap")) { | ||
| 1612 | QGLExtensionMatcher extensions(glXQueryExtensionsString(xinfo->display(), xinfo->screen())); | ||
| 1613 | if (extensions.match("GLX_EXT_texture_from_pixmap")) { | ||
| 1614 | 1614 | glXBindTexImageEXT = (qt_glXBindTexImageEXT) qglx_getProcAddress("glXBindTexImageEXT"); | |
| 1615 | 1615 | glXReleaseTexImageEXT = (qt_glXReleaseTexImageEXT) qglx_getProcAddress("glXReleaseTexImageEXT"); | |
| 1616 | 1616 | } |

