Sorry if this question's title was phrased poorly, but I have a class with a member function that in turn calls a couple of OpenGL functions:
class StateSet
{
public:
StateSet();
// ...
inline void SetVertexAttributeEnabled(GLuint location,bool enabled)
{
if(m_GL_VERTEX_ATTRIB_ARRAY_ENABLED[location] == enabled) {
return;
}
m_GL_VERTEX_ATTRIB_ARRAY_ENABLED[location] = enabled;
if(enabled) {
glEnableVertexAttribArray(location);
}
else {
glDisableVertexAttribArray(location);
}
}
// ...
When trying to compile this, I get
'glEnableVertexAttribArray' was not declared in this scope
'glDisableVertexAttribArray' was not declared in this scope
If I don't make the function inline (take out the 'inline' keyword) and define the function in the corresponding source file, it works fine. The source file doesn't have any additional includes, it just includes the header file, which in turn includes:
#define GL_GLEXT_PROTOTYPES
#include <GL/gl.h>
#include <GL/glext.h>
So why would inlining make the compiler unable to 'see' the OpenGL function calls?
This doesn't happen for all OpenGL functions either -- I can compile if I try calling glDrawArrays, glGet[], etc.
More information:
All the includes for the header and source file in question are:
#include <vector>
#include <cassert>
#include <sstream>
#include <iostream>
#define GL_GLEXT_PROTOTYPES
#include <GL/gl.h>
#include <GL/glext.h>
OpenGL and its context and everything should be set up by Qt; this class is being used in a Qt application where I can already call the functions (glEnable/DisableVertexAttribArray) and everything seems to be set up ok.