Header glx/glxext.h prevents the use of GLX_CONTEXT_RELEASE_BEHAVIOR_ARB
I am trying to setup a OpenGL GLX context using the library GLFW
and using it against a Xvfb
virtual framebuffer (I am using xserver 1.19.6
obtained from Ubuntu package xserver-xorg-core
)
When I create the context I need to specify specific window hints as follows
void error_callback(int, const char* err_str)
{
std::cout << "GLFW Error: " << err_str << std::endl;
}
int main(int argc, char** argv)
{
glfwSetErrorCallback(error_callback);
/* Initialize GLFW. */
if (glfwInit() == GL_FALSE)
{
std::cerr << "Failed to initialize GLFW." << std::endl;
return false;
}
/* Set context properties by "hinting" specific (property, value) pairs. */
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
glfwWindowHint(GLFW_RESIZABLE, GL_FALSE);
glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE);
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
glfwWindowHint(GLFW_CONTEXT_RELEASE_BEHAVIOR, GLFW_RELEASE_BEHAVIOR_NONE);
/* Create window to create context and enquire OpenGL for the maximum size of the renderbuffer */
GLFWwindow* window_ = glfwCreateWindow(1, 1, "OpenGL window", nullptr, nullptr);
if (window_ == nullptr)
{
std::cerr << "Failed to create GLFW window." << std::endl;;
glfwTerminate();
return false;
}
return EXIT_SUCCESS;
}
However, using the hint glfwWindowHint(GLFW_CONTEXT_RELEASE_BEHAVIOR, GLFW_RELEASE_BEHAVIOR_NONE);
causes the application to fail with the following error
Error: GLX: Failed to create context: BadValue (integer parameter out of range for operation).
In particular this problem is happening due to the following lines of codes in glx/createcontext.c
#ifdef GLX_CONTEXT_RELEASE_BEHAVIOR_ARB
case GLX_CONTEXT_RELEASE_BEHAVIOR_ARB:
flush = attribs[2 * i + 1];
if (flush != GLX_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB
&& flush != GLX_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB)
return BadValue;
break;
#endif
default:
return BadValue;
}
}
where the part of code between #ifdef GLX_CONTEXT_RELEASE_BEHAVIOR_ARB
and #endif
is never compiled and the default return BadValue
is fired. Compilation does not happen since GLX_CONTEXT_RELEASE_BEHAVIOR_ARB
is defined in <GL/glxext.h>
but this header is not included as can be seen in glx/glxext.h
/* doing #include <GL/glx.h> & #include <GL/glxext.h> could cause problems
* with overlapping definitions, so let's use the easy way
*/
#ifndef GLX_RGBA_FLOAT_BIT_ARB
#define GLX_RGBA_FLOAT_BIT_ARB 0x00000004
#endif
#ifndef GLX_RGBA_FLOAT_TYPE_ARB
#define GLX_RGBA_FLOAT_TYPE_ARB 0x20B9
#endif
#ifndef GLX_RGBA_UNSIGNED_FLOAT_BIT_EXT
#define GLX_RGBA_UNSIGNED_FLOAT_BIT_EXT 0x00000008
#endif
#ifndef GLX_RGBA_UNSIGNED_FLOAT_TYPE_EXT
#define GLX_RGBA_UNSIGNED_FLOAT_TYPE_EXT 0x20B1
#endif
Unfortunately, by not including <GL/glxext.h>
the defines GLX_CONTEXT_RELEASE_BEHAVIOR_ARB
, GLX_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB
and GLX_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB
are not present causing the issue described above.
Is there any specific reason behind this choice?