1 /* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; -*- */ 2 /* ***** BEGIN LICENSE BLOCK ***** 3 * This file is part of openfx-supportext <https://github.com/devernay/openfx-supportext>, 4 * Copyright (C) 2013-2018 INRIA 5 * 6 * openfx-supportext is free software: you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * 11 * openfx-supportext is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with openfx-supportext. If not, see <http://www.gnu.org/licenses/gpl-2.0.html> 18 * ***** END LICENSE BLOCK ***** */ 19 20 #ifndef openfx_supportext_ofxsOGLUtilities_h 21 #define openfx_supportext_ofxsOGLUtilities_h 22 23 namespace OFX { 24 /** 25 * @brief Loads OpenGL functions using GLAD so that they are available if using glad.h or ofxsOGLFunctions.h 26 * Note: this function will loads them once only, subsequent calls to this function do nothing. 27 * This is thread-safe (protected by a mutex). 28 * An OpenGL context MUST be bound when calling this function. A good place to call it is in the 29 * draw function of an interact (if you only use interacts) or in the contextAttached action of your 30 * plug-in if you support OpenGL rendering. 31 * Note that the OpenGL version loaded is the one specified when generating glad.h 32 * @returns true if OpenGL was load successfully, false otherwise. 33 * Reasons for failure might be: 34 * - opengl32.dll was not found, or libGL.so was not found or OpenGL.framework was not found 35 * - glGetString does not return a valid version 36 * Note: It does NOT check that required extensions and functions have actually been found, 37 * nor that the OpenGL version of the driver matches the version at which glad was generated. 38 * Use functions below for that. 39 **/ 40 bool ofxsLoadOpenGLOnce(); 41 42 /** 43 * @brief Returns the OpenGL major version loaded by GLAD. This is the version of the client driver 44 * and may differ from the version for which GLAD was generated. 45 * Note: ofxsLoadOpenGLOnce() must have been called at least once prior to calling this function. 46 **/ 47 int getOpenGLMajorVersion(); 48 49 /** 50 * @brief Returns the OpenGL minor version loaded by GLAD. This is the version of the client driver 51 * and may differ from the version for which GLAD was generated. 52 * Note: ofxsLoadOpenGLOnce() must have been called at least once prior to calling this function. 53 **/ 54 int getOpenGLMinorVersion(); 55 56 /** 57 * @brief Returns whether the OpenGL driver of the client support the GL_ARB_texture_float extension. 58 * Note: ofxsLoadOpenGLOnce() must have been called at least once prior to calling this function. 59 **/ 60 bool getOpenGLSupportsTextureFloat(); 61 62 /** 63 * @brief Returns whether the OpenGL driver of the client support the GL_ARB_framebuffer_object extension. 64 * Note that if it is unsupported but GL_EXT_framebuffer_object is supported this function will return true 65 * and all functions of the GL_ARB_framebuffer_object extension will be in fact using the functions of 66 * GL_EXT_framebuffer_object. 67 * Note: ofxsLoadOpenGLOnce() must have been called at least once prior to calling this function. 68 **/ 69 bool getOpenGLSupportFramebuffer(); 70 71 /** 72 * @brief Returns whether the OpenGL driver of the client support the GL_ARB_pixel_buffer_object extension. 73 * Note that if it is unsupported but GLAD_GL_APPLE_vertex_array_object is supported this function will return true 74 * and all functions of the GLAD_GL_ARB_vertex_array_object extension will be in fact using the functions of 75 * GLAD_GL_APPLE_vertex_array_object. 76 * Note: ofxsLoadOpenGLOnce() must have been called at least once prior to calling this function. 77 **/ 78 bool getOpenGLSupportPixelbuffer(); 79 80 /** 81 * @brief Returns whether the OpenGL driver of the client support the GL_ARB_vertex_array_object extension. 82 * Note: ofxsLoadOpenGLOnce() must have been called at least once prior to calling this function. 83 **/ 84 bool getOpenGLSupportVertexArray(); 85 } // namespace OFX 86 87 #endif /* defined(openfx_supportext_ofxsOGLDebug_h) */ 88