Changeset View
Changeset View
Standalone View
Standalone View
libkwineffects/kwinglutils.cpp
Show First 20 Lines • Show All 58 Lines • ▼ Show 20 Line(s) | |||||
59 | #else | 59 | #else | ||
60 | # define likely(x) (x) | 60 | # define likely(x) (x) | ||
61 | # define unlikely(x) (x) | 61 | # define unlikely(x) (x) | ||
62 | #endif | 62 | #endif | ||
63 | 63 | | |||
64 | namespace KWin | 64 | namespace KWin | ||
65 | { | 65 | { | ||
66 | // Variables | 66 | // Variables | ||
67 | // GLX version, use MAKE_GL_VERSION() macro for comparing with a specific version | | |||
68 | static int glXVersion; | | |||
69 | // EGL version, use MAKE_GL_VERSION() macro for comparing with a specific version | 67 | // EGL version, use MAKE_GL_VERSION() macro for comparing with a specific version | ||
70 | static int eglVersion; | 68 | static int eglVersion; | ||
71 | // List of all supported GL, EGL and GLX extensions | 69 | // List of all supported GL, EGL and GLX extensions | ||
72 | static QList<QByteArray> glExtensions; | 70 | static QList<QByteArray> glExtensions; | ||
73 | static QList<QByteArray> s_glxExtensions; | 71 | static QList<QByteArray> s_glxExtensions; | ||
74 | static QList<QByteArray> s_eglExtensions; | 72 | static QList<QByteArray> s_eglExtensions; | ||
75 | 73 | | |||
76 | int glTextureUnitsCount; | 74 | int glTextureUnitsCount; | ||
77 | 75 | | |||
78 | 76 | | |||
79 | // Functions | 77 | // Functions | ||
80 | void initGLX() | 78 | void initGLX() | ||
81 | { | 79 | { | ||
82 | #if HAVE_EPOXY_GLX | 80 | #if HAVE_EPOXY_GLX | ||
83 | // Get GLX version | | |||
84 | int major, minor; | | |||
85 | glXQueryVersion(display(), &major, &minor); | | |||
86 | glXVersion = MAKE_GL_VERSION(major, minor, 0); | | |||
87 | // Get list of supported GLX extensions | 81 | // Get list of supported GLX extensions | ||
88 | const QByteArray string = (const char *) glXQueryExtensionsString(display(), QX11Info::appScreen()); | 82 | const QByteArray string = (const char *) glXQueryExtensionsString(display(), QX11Info::appScreen()); | ||
89 | s_glxExtensions = string.split(' '); | 83 | s_glxExtensions = string.split(' '); | ||
90 | glxResolveFunctions(); | 84 | glxResolveFunctions(); | ||
91 | #endif | 85 | #endif | ||
92 | } | 86 | } | ||
93 | 87 | | |||
94 | void initEGL() | 88 | void initEGL() | ||
Show All 38 Lines | 124 | { | |||
133 | GLRenderTarget::cleanup(); | 127 | GLRenderTarget::cleanup(); | ||
134 | GLVertexBuffer::cleanup(); | 128 | GLVertexBuffer::cleanup(); | ||
135 | GLPlatform::cleanup(); | 129 | GLPlatform::cleanup(); | ||
136 | 130 | | |||
137 | glExtensions.clear(); | 131 | glExtensions.clear(); | ||
138 | s_glxExtensions.clear(); | 132 | s_glxExtensions.clear(); | ||
139 | s_eglExtensions.clear(); | 133 | s_eglExtensions.clear(); | ||
140 | 134 | | |||
141 | glXVersion = 0; | | |||
142 | eglVersion = 0; | 135 | eglVersion = 0; | ||
143 | glTextureUnitsCount = 0; | 136 | glTextureUnitsCount = 0; | ||
144 | } | 137 | } | ||
145 | 138 | | |||
146 | bool hasGLVersion(int major, int minor, int release) | 139 | bool hasGLVersion(int major, int minor, int release) | ||
147 | { | 140 | { | ||
148 | return GLPlatform::instance()->glVersion() >= kVersionNumber(major, minor, release); | 141 | return GLPlatform::instance()->glVersion() >= kVersionNumber(major, minor, release); | ||
149 | } | 142 | } | ||
150 | 143 | | |||
151 | bool hasGLXVersion(int major, int minor, int release) | | |||
152 | { | | |||
153 | return glXVersion >= MAKE_GL_VERSION(major, minor, release); | | |||
154 | } | | |||
155 | | ||||
156 | bool hasEGLVersion(int major, int minor, int release) | 144 | bool hasEGLVersion(int major, int minor, int release) | ||
157 | { | 145 | { | ||
158 | return eglVersion >= MAKE_GL_VERSION(major, minor, release); | 146 | return eglVersion >= MAKE_GL_VERSION(major, minor, release); | ||
159 | } | 147 | } | ||
160 | 148 | | |||
161 | bool hasGLExtension(const QByteArray &extension) | 149 | bool hasGLExtension(const QByteArray &extension) | ||
162 | { | 150 | { | ||
163 | return glExtensions.contains(extension) || s_glxExtensions.contains(extension) || s_eglExtensions.contains(extension); | 151 | return glExtensions.contains(extension) || s_glxExtensions.contains(extension) || s_eglExtensions.contains(extension); | ||
▲ Show 20 Lines • Show All 2175 Lines • Show Last 20 Lines |