Hi there,
I have the following code to run some simple OpenGL applications from an ARM Cortex A9 running Ubuntu 12.04 LTS.
When I compile and run the code I get the following GLX error:
Code :X Error of failed request: BadRequest (Invalid request code or no such operation) Major opcode of failed request: 153 (GLX) Minor opcode of failed request: 34 () Serial number of failed request: 36 Current serial number in output stream: 35
Running this with debug symbols on only adds the following line `[Inferior 1 (process 1569) exited with code 01]` which is not really helpful.
Code for Main loop:
Code :#include "CubeTexture.h" #ifdef _WIN32 #include <BasicEngine\Engine.h> #elif __linux__ #include "../BasicEngine/Engine.h" #include <pthread.h> #endif using namespace BasicEngine; #ifdef __linux__ void junk() { int i; i = pthread_getconcurrency(); } #endif int main(int argc, char **argv) { Engine* engine = new Engine(); engine->Init(); engine->GetShader_Manager()->CreateProgram("cubeShader", "./Shaders/Cube_Vertex_Shader.glsl", "./Shaders/Cube_Fragment_Shader.glsl"); CubeTexture* cube = new CubeTexture(); int program = engine->GetShader_Manager()->GetShader("cubeShader"); if (program != 0) { cube->SetProgram(program); cube->Create(); } else { std::cout << "invalid program..."; std::cin.get(); } unsigned int texture = engine->GetTexture_Loader()->LoadTexture("./Textures/Crate.bmp", 256, 256); cube->SetTexture("Create", texture); engine->GetModels_Manager()->SetModel("cube", cube); engine->Run(); delete engine; return (0); }
Code to initialise GLUT and X Windows environment
Code :#include "../Init/Init_GLUT.h" using namespace BasicEngine; using namespace Core::Init; Core::IListener* Init_GLUT::listener = NULL; Core::WindowInfo Init_GLUT::windowInformation; #ifdef __linux__ Display *dpy; Window root; GLint att[] = { GLX_RGBA, GLX_DEPTH_SIZE, 24, GLX_DOUBLEBUFFER, None }; XVisualInfo *vi; Colormap cmap; XSetWindowAttributes swa; Window win; GLXContext glc; XWindowAttributes gwa; XEvent xev; void Init_GLUT::linuxinit() { std::cout << "Linux detected" << std::endl; dpy = XOpenDisplay(NULL); if (dpy == NULL) { std::cout << "\n\tcannont connect to X server\n\n" << std::endl; exit(0); } root = DefaultRootWindow(dpy); vi = glXChooseVisual(dpy, 0, att); if (vi == NULL) { std::cout << "\n\tno appropriate visual found\n\n" << std::endl; exit(0); } else { std::cout << "\n\tvisual %p selected\n" << (void*)vi->visualid << std::endl; //%p creates a hexadecimal output like in glxinfo } cmap = XCreateColormap(dpy, root, vi->visual, AllocNone); swa.colormap = cmap; swa.event_mask = ExposureMask | KeyPressMask; std::cout << "end of Linux compiler directives" << std::endl; } #endif void Init_GLUT::init(const Core::WindowInfo& windowInfo, const Core::ContextInfo& contextInfo, const Core::FramebufferInfo& framebufferInfo) { windowInformation = windowInfo; //i need some fake things here int fakeargc = 1; char* fakeargv[] = { "fake", NULL }; glutInit(&fakeargc, fakeargv); if (contextInfo.core) { glutInitContextVersion(contextInfo.major_version, contextInfo.minor_version); glutInitContextProfile(GLUT_CORE_PROFILE); } else { //doesn't matter in compatibility mode glutInitContextProfile(GLUT_COMPATIBILITY_PROFILE); } //old functions from main.cpp now using info from the structures glutInitDisplayMode(framebufferInfo.flags); glutInitWindowPosition(windowInfo.position_x, windowInfo.position_y); glutInitWindowSize(windowInfo.width, windowInfo.height); glutCreateWindow(windowInfo.name.c_str()); std::cout << "GLUT:initialised" << std::endl; #ifdef _WIN32 //Lets add some debug capability glEnable(GL_DEBUG_OUTPUT); #endif Core::Init::Init_GLEW::Init(); #ifdef _WIN32 glDebugMessageCallback(DebugOutput::myCallback, NULL); glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, NULL, TRUE); #endif //these call backs are used for rendering glutIdleFunc(idleCallback); glutCloseFunc(closeCallback); glutDisplayFunc(displayCallback); glutReshapeFunc(reshapeCallback); //init GLEW (can be called in main.cpp) //clean up glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_GLUTMAINLOOP_RETURNS); //our method to display some info. Needs contextInfo and windowinfo printOpenGLInfo(windowInfo, contextInfo); } //starts the rendering loop void Init_GLUT::run() { std::cout << "GLUT:\t Start Running" << std::endl; glutMainLoop(); } void Init_GLUT::close() { std::cout << "GLUT:\t Finished" << std::endl; glutLeaveMainLoop; } void Init_GLUT::idleCallback(void) { //do nothing, just redisplay glutPostRedisplay(); } void Init_GLUT::displayCallback() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glClearColor(0.0, 0.0, 0.0, 1); glutSwapBuffers; if (listener) { listener->notifyBeginFrame(); listener->notifyDisplayFrame(); glutSwapBuffers(); listener->notifyEndFrame(); } } void Init_GLUT::reshapeCallback(int width, int height) { if (windowInformation.isReshapable == true) { if (listener) { listener->notifyReshape(width, height, windowInformation.width, windowInformation.height); } windowInformation.width = width; windowInformation.height = height; } } void Init_GLUT::closeCallback() { close(); } void Init_GLUT::enterFullscreen() { glutFullScreen(); } void Init_GLUT::exitFullscreen() { glutLeaveFullScreen(); } void Init_GLUT::setListener(Core::IListener* iListener) { listener = iListener; } void Init_GLUT::printOpenGLInfo(const Core::WindowInfo& windowInfo, const Core::ContextInfo& contextInfo) { const unsigned char* renderer = glGetString(GL_RENDERER); const unsigned char* vendor = glGetString(GL_VENDOR); const unsigned char* version = glGetString(GL_VERSION); std::cout << "*******************************************************************************" << std::endl; std::cout << "GLUT:\tVendor : " << vendor << std::endl; std::cout << "GLUT:\tRenderer : " << renderer << std::endl; std::cout << "GLUT:\tOpenGl version: " << version << std::endl; std::cout << "GLUT:\tInitial window is '" << windowInfo.name << "', with dimensions (" << windowInfo.width << "X" << windowInfo.height; std::cout << ") starts at (" << windowInfo.position_x << "X" << windowInfo.position_y; std::cout << ") and " << ((windowInfo.isReshapable) ? "is" : "is not ") << " redimensionable" << std::endl; std::cout << "GLUT:\tInitial Framebuffer contains double buffers for" << std::endl; std::cout << "GLUT:\t OpenGL context is " << contextInfo.major_version << "." << contextInfo.minor_version; std::cout << " and profile is " << ((contextInfo.core) ? "core" : "compatibility") << std::endl; std::cout << "*****************************************************************" << std::endl; }
Does anybody know what is causing the error? Or indeed what BadRequest, Major Opcode 153 (GLX) actually refers to?
Cheers