| Jamie Madill | ba319ba | 2018-12-29 15:29:33 | [diff] [blame] | 1 | // |
| 2 | // Copyright 2018 The ANGLE Project Authors. All rights reserved. |
| 3 | // Use of this source code is governed by a BSD-style license that can be |
| 4 | // found in the LICENSE file. |
| 5 | // |
| 6 | // util_gl.h: Includes the right GL/EGL headers for static/shared link. |
| 7 | |
| 8 | #ifndef UTIL_GL_H_ |
| 9 | #define UTIL_GL_H_ |
| 10 | |
| Tom Sepez | 3d8dff0 | 2025-08-26 20:23:21 | [diff] [blame] | 11 | #ifdef UNSAFE_BUFFERS_BUILD |
| 12 | # pragma allow_unsafe_buffers |
| 13 | #endif |
| 14 | |
| Yuly Novikov | 5fe7c5b | 2019-01-17 17:16:34 | [diff] [blame] | 15 | #include "common/platform.h" |
| 16 | |
| Jamie Madill | ba319ba | 2018-12-29 15:29:33 | [diff] [blame] | 17 | #if defined(ANGLE_USE_UTIL_LOADER) |
| 18 | # include "util/egl_loader_autogen.h" |
| 19 | # include "util/gles_loader_autogen.h" |
| Austin Kinross | 11dc163 | 2019-09-18 21:46:23 | [diff] [blame] | 20 | # if defined(ANGLE_PLATFORM_WINDOWS) && !defined(ANGLE_ENABLE_WINDOWS_UWP) |
| Jamie Madill | 624ce6a | 2019-01-04 19:17:24 | [diff] [blame] | 21 | # include "util/windows/wgl_loader_autogen.h" |
| Austin Kinross | 11dc163 | 2019-09-18 21:46:23 | [diff] [blame] | 22 | # endif // defined(ANGLE_PLATFORM_WINDOWS) && !defined(ANGLE_ENABLE_WINDOWS_UWP) |
| Jamie Madill | ba319ba | 2018-12-29 15:29:33 | [diff] [blame] | 23 | #else |
| 24 | |
| 25 | # if !defined(GL_GLES_PROTOTYPES) |
| 26 | # error Config error. Should either be using the ANGLE GL loader or header prototypes. |
| 27 | # endif // !defined(GL_GLES_PROTOTYPES) |
| 28 | |
| 29 | # include <EGL/egl.h> |
| 30 | # include <EGL/eglext.h> |
| 31 | # include "angle_gl.h" |
| Jamie Madill | 624ce6a | 2019-01-04 19:17:24 | [diff] [blame] | 32 | #endif // defined(ANGLE_USE_UTIL_LOADER) |
| Jamie Madill | ba319ba | 2018-12-29 15:29:33 | [diff] [blame] | 33 | |
| Sungyong Choi | df13b2b | 2025-08-13 07:04:28 | [diff] [blame] | 34 | #include <cstring> |
| Manh Nguyen | dce37b7 | 2020-06-22 02:27:06 | [diff] [blame] | 35 | #include <string> |
| Takuto Ikuta | 7432138 | 2025-07-03 05:36:54 | [diff] [blame] | 36 | #include <utility> |
| Manh Nguyen | dce37b7 | 2020-06-22 02:27:06 | [diff] [blame] | 37 | |
| Jamie Madill | 5df2c9e | 2020-03-15 21:28:43 | [diff] [blame] | 38 | namespace angle |
| 39 | { |
| 40 | inline bool CheckExtensionExists(const char *allExtensions, const std::string &extName) |
| 41 | { |
| 42 | const std::string paddedExtensions = std::string(" ") + allExtensions + std::string(" "); |
| 43 | return paddedExtensions.find(std::string(" ") + extName + std::string(" ")) != |
| 44 | std::string::npos; |
| 45 | } |
| Tim Van Patten | 4e0537c | 2025-06-13 17:23:58 | [diff] [blame] | 46 | |
| 47 | inline std::pair<EGLint, EGLint> GetCurrentContextVersion() |
| 48 | { |
| 49 | const char *versionString = reinterpret_cast<const char *>(glGetString(GL_VERSION)); |
| Sungyong Choi | df13b2b | 2025-08-13 07:04:28 | [diff] [blame] | 50 | if ((versionString == nullptr) || std::strstr(versionString, "OpenGL ES") == nullptr) |
| Tim Van Patten | 4e0537c | 2025-06-13 17:23:58 | [diff] [blame] | 51 | { |
| 52 | return {0, 0}; |
| 53 | } |
| 54 | |
| 55 | return {versionString[10] - '0', versionString[12] - '0'}; |
| 56 | } |
| Jamie Madill | 5df2c9e | 2020-03-15 21:28:43 | [diff] [blame] | 57 | } // namespace angle |
| Jamie Madill | ba319ba | 2018-12-29 15:29:33 | [diff] [blame] | 58 | #endif // UTIL_GL_H_ |