File indexing completed on 2024-11-10 04:55:54
0001 /* 0002 KWin - the KDE window manager 0003 This file is part of the KDE project. 0004 0005 SPDX-FileCopyrightText: 2016 Martin Gräßlin <mgraesslin@kde.org> 0006 0007 SPDX-License-Identifier: GPL-2.0-or-later 0008 */ 0009 #include "mock_gl.h" 0010 #include <epoxy/gl.h> 0011 0012 MockGL *s_gl = nullptr; 0013 0014 static const GLubyte *mock_glGetString(GLenum name) 0015 { 0016 if (!s_gl) { 0017 return nullptr; 0018 } 0019 switch (name) { 0020 case GL_VENDOR: 0021 return (const GLubyte *)s_gl->getString.vendor.constData(); 0022 case GL_RENDERER: 0023 return (const GLubyte *)s_gl->getString.renderer.constData(); 0024 case GL_VERSION: 0025 return (const GLubyte *)s_gl->getString.version.constData(); 0026 case GL_EXTENSIONS: 0027 return (const GLubyte *)s_gl->getString.extensionsString.constData(); 0028 case GL_SHADING_LANGUAGE_VERSION: 0029 return (const GLubyte *)s_gl->getString.shadingLanguageVersion.constData(); 0030 default: 0031 return nullptr; 0032 } 0033 } 0034 0035 static const GLubyte *mock_glGetStringi(GLenum name, GLuint index) 0036 { 0037 if (!s_gl) { 0038 return nullptr; 0039 } 0040 if (name == GL_EXTENSIONS && index < uint(s_gl->getString.extensions.count())) { 0041 return (const GLubyte *)s_gl->getString.extensions.at(index).constData(); 0042 } 0043 return nullptr; 0044 } 0045 0046 static void mock_glGetIntegerv(GLenum pname, GLint *data) 0047 { 0048 if (pname == GL_NUM_EXTENSIONS) { 0049 if (data && s_gl) { 0050 *data = s_gl->getString.extensions.count(); 0051 } 0052 } 0053 } 0054 0055 PFNGLGETSTRINGPROC epoxy_glGetString = mock_glGetString; 0056 PFNGLGETSTRINGIPROC epoxy_glGetStringi = mock_glGetStringi; 0057 PFNGLGETINTEGERVPROC epoxy_glGetIntegerv = mock_glGetIntegerv;