/* * This file is part of Bino, a 3D video player. * * Copyright (C) 2022, 2023, 2024, 2025 * Martin Lambers * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include #include #include #include #include "tools.hpp" OpenGL_Type OpenGLType; void initializeOpenGLType(const QSurfaceFormat& format) { #ifdef Q_OS_WASM OpenGLType = OpenGL_Type_WebGL; #else OpenGLType = (QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGLES || format.renderableType() == QSurfaceFormat::OpenGLES) ? OpenGL_Type_OpenGLES : OpenGL_Type_Desktop; #endif } QString readFile(const char* fileName) { QString s; QFile f(fileName); bool ok = f.open(QIODevice::ReadOnly); if (ok) { QTextStream in(&f); s = in.readAll(); } return s; } bool checkTextureAnisotropicFilterAvailability() { return QOpenGLContext::currentContext()->hasExtension("GL_ARB_texture_filter_anisotropic") || QOpenGLContext::currentContext()->hasExtension("GL_EXT_texture_filter_anisotropic"); } const char* getOpenGLString(QOpenGLExtraFunctions* gl, GLenum p) { return reinterpret_cast(gl->glGetString(p)); } QString getExtension(const QString& fileName) { QString extension; int lastDot = fileName.lastIndexOf('.'); if (lastDot > 0) extension = (fileName.right(fileName.length() - lastDot - 1)).toLower(); return extension; } QString getExtension(const QUrl& url) { return getExtension(url.fileName()); }