Use QOpenGLFunctions_4_5_Core functions in an external file without declare a class
-
Hello,
I would like to know if is it possibile to use OpenGL functions outside my glWidget class.
For example if I have an external header file like this://shader.hpp #ifndef SHADER_HPP #define SHADER_HPP #include <QOpenGLWidget> #include <QOpenGLFunctions> #include <QOpenGLFunctions_4_5_Core> GLuint MyShaders(const char * vertex_file_path, const char * fragment_file_path); #endif
why I can`t use in cpp that:
#include "shader.hpp" GLuint MyShaders(const char * vertex_file_path, const char * fragment_file_path){ // Create the shaders GLuint VertexShaderID = glCreateShader(GL_VERTEX_SHADER); GLuint FragmentShaderID = glCreateShader(GL_FRAGMENT_SHADER); ......................... ......................
Visual Studio told me that glCreateShader identifier not found.
Thank you
-
Hi,
QOpenGLFunctions_4_5_Core is a class not just a bunch of function to use. You have to inherit from it to use the functions it provides.
Note, I haven't used them outside QOpenGLWidget/Window.
-
Your function must be integrated in a class that derives from QOpenGLFunctions_4_5_Core. Don't forget to handle the context properly.