I am writing a game. I use ArchLinux most of time but I have tried to run my game on the Ubuntu 16.04 recently. On Ubuntu 16.04 there is a strange error: 1280. It is too difficult to find what causes the error so I wanted to see opengl's debug output but I don't see it too. I noticed one thing during shader validation - validation seems to be unsuccessful but the log is empty:
GLint status;
glValidateProgram(program_);
glGetProgramiv(program_, GL_VALIDATE_STATUS, &status);
if (status == GL_TRUE) {
return;
}
// Store log and return false
int length = 0;
glGetProgramiv(program_, GL_INFO_LOG_LENGTH, &length);
if (length > 0) {
GLchar infoLog[512];
glGetProgramInfoLog(program_, 512, nullptr, infoLog);
throw std::runtime_error(std::string("Program failed to validate:") + infoLog);
} else {
throw std::runtime_error(std::string("Program failed to validate. Unknown error"));
}
This gives me Unknown error
. Also the opengl's debug output can't be seen, however, user messages are written there successfully. Here is the code:
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 4);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 4);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
int contextFlags = 0;
SDL_GL_GetAttribute(SDL_GL_CONTEXT_FLAGS, &contextFlags);
contextFlags |= SDL_GL_CONTEXT_DEBUG_FLAG;
SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, contextFlags);
sdlWindow_ = SDL_CreateWindow(title.c_str(),
SDL_WINDOWPOS_UNDEFINED,
SDL_WINDOWPOS_UNDEFINED,
0,
0,
SDL_WINDOW_OPENGL
| SDL_WINDOW_SHOWN
| SDL_WINDOW_FULLSCREEN_DESKTOP
| SDL_WINDOW_INPUT_GRABBED);
if (!sdlWindow_) {
throw std::runtime_error("Unable to create window");
}
SDL_Log("Window created");
glContext_ = SDL_GL_CreateContext(sdlWindow_);
if (!glContext_) {
throw std::runtime_error("Failed to init OpenGL");
}
SDL_Log("GL context created");
{
glewExperimental = GL_TRUE;
GLenum err = glewInit();
if (err != GLEW_OK) {
throw std::runtime_error(std::string("GLEW Error: ") + reinterpret_cast<const char*>(glewGetErrorString(err)));
}
}
if (glDebugMessageCallbackARB != nullptr) {
SDL_Log("GL debug is available.\n");
// Enable the debug callback
glEnable(GL_DEBUG_OUTPUT);
glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
glDebugMessageCallback(_openglDebugCallbackFunction, nullptr);
glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, nullptr, GL_TRUE);
glDebugMessageInsert(GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_MARKER, 0,
GL_DEBUG_SEVERITY_NOTIFICATION, -1 , "Started debugging");
} else {
SDL_Log("GL debug is not available.\n");
}
So the main question here is why I can't see the opengl's debug output. And, if it is possible, as an additional question, why does the shader validation fail without a log?