在ubuntu 14.10 64位下创建Opengl 3.3上下文时出错

时间:2015-04-05 02:21:08

标签: opengl x11

我需要一些帮助才能在Ubuntu 14.10 64位中运行此代码。我用ubuntu 14.04 32位编译了这段代码并且工作正常......但是如果我把它转换成64位(相同的PC,另一个分区)14.10,我就无法创建一个Opengl 3.3上下文。我不知道问题是什么。

这里是mi代码glxwindow.h

#ifndef GLXWINDOW_H_INCLUDED
#define GLXWINDOW_H_INCLUDED

#ifndef WIN32

#include "oslibraries.h"
#include <ctime>

#include "boglgpwindow.h"

namespace SGE3D
{
    class core; //Declara la clase principal del juego
}

namespace SGE3D
{

class SimpleGLXWindow : public BOGLGPWindow
{
public:
    SimpleGLXWindow(); //default constructor
    virtual ~SimpleGLXWindow();

    bool create(int width, int height, int bpp, bool fullscreen);
    void destroy();
    void processEvents();
    void attachExample(SGE3D::core* example);
    void setWindowTitle(char* wName);

    bool isRunning(); //Is the window running?

    void swapBuffers();

    float getElapsedSeconds();

    KeyboardInterface* getKeyboard() const { return m_keyboard; }
    MouseInterface* getMouse() const { return m_mouse; }
    void resizeOpenGLViewPortFull(float wRight, float wLeft);
    void resizeOpenGLViewPort(float x, float y, float wRight, float wLeft);
    int getViewPortWidth();
    int getViewPortHeight();
    int getWindowWidth();
    int getWindowHeight();
private:
    SGE3D::core* m_example; //manejador de la clase principal del juego
    bool m_isRunning; //Is the window still running?
    char* m_windowTitle;

    SGE3D::core* getAttachedExample() { return m_example; }

    unsigned int m_lastTime;

    Display* m_display;
    Window m_XWindow;
    GLXContext m_glContext;
    XF86VidModeModeInfo m_XF86DeskMode;
    XSetWindowAttributes m_XSetAttr;
    //agregado
    XWindowAttributes m_gwa;
    int m_screenID;

    bool m_isFullscreen;
    unsigned int m_width;
    unsigned int m_height;
    unsigned int m_bpp;

    bool m_GL3Supported;

    SGE3D::KeyboardInterface* m_keyboard;//manejador del teclado
    SGE3D::MouseInterface* m_mouse;//manejador del mouse

    //viewPort
    int viewPortWidth,viewPortHeight;
    int windowWidth,windowHeight;

    //cierra la ventana
    Atom WM_DELETE_WINDOW;
};
}
#endif //WIN32
#endif // GLXWINDOW_H_INCLUDED

这是glxwindow.cpp

#ifndef WIN32

#include <iostream>
#include <string>

#include <sys/time.h>

#include "opengl.h"
#include "glxwindow.h"
#include "core.h"
#include "xkeyboardinterface.h"
#include "xmouseinterface.h"

//SOLO DEBUG
#include "sysconfiguration.h"
#include "pcreport.h"
#include <iostream>
#include <stdio.h>
using std::cout;

using std::string;

typedef GLXContext (*glXCreateContextAttribsARBProc)(Display*, GLXFBConfig, GLXContext, Bool, const int*);

static bool isExtensionSupported(const char *extList, const char *extension)
{
  const char *start;
  const char *where, *terminator;

  /* Extension names should not have spaces. */
  where = strchr(extension, ' ');
  if (where || *extension == '\0')
    return false;

  /* It takes a bit of care to be fool-proof about parsing the
     OpenGL extensions string. Don't be fooled by sub-strings,
     etc. */
  for (start=extList;;) {
    where = strstr(start, extension);

    if (!where)
      break;

    terminator = where + strlen(extension);

    if ( where == start || *(where - 1) == ' ' )
      if ( *terminator == ' ' || *terminator == '\0' )
        return true;

    start = terminator;
  }

  return false;
}

unsigned int GetTickCount() {
    struct timeval t;
    gettimeofday(&t, NULL);

    unsigned long secs = t.tv_sec * 1000;
    secs += (t.tv_usec / 1000);
    return secs;
}

static bool ctxErrorOccurred = false;
static int ctxErrorHandler( Display *dpy, XErrorEvent *ev )
{
    ctxErrorOccurred = true;
    return 0;
}

namespace SGE3D
{

SimpleGLXWindow::SimpleGLXWindow():
m_example(NULL),
m_windowTitle("Skalium Graphic Engine 3D"),
m_isRunning(true),
m_lastTime(0),
m_display(NULL),
m_XWindow(0),
m_glContext(0),
m_screenID(0),
m_isFullscreen(false),
m_width(0),
m_height(0),
m_bpp(0),
m_GL3Supported(false),
m_keyboard(NULL),
m_mouse(NULL)
{
    m_keyboard = new XKeyboardInterface();//instancia el teclado
}

SimpleGLXWindow::~SimpleGLXWindow()
{
    delete m_keyboard;
    delete m_mouse;
}

void SimpleGLXWindow::resizeOpenGLViewPortFull(float wRight, float wLeft)
{
    glViewport(0, 0, wRight, wLeft);
    viewPortWidth = wRight;
    viewPortHeight = wLeft;
}

void SimpleGLXWindow::resizeOpenGLViewPort(float x, float y, float wRight, float wLeft)
{
    glViewport(x, y, wRight, wLeft);
    viewPortWidth = wRight;
    viewPortHeight = wLeft;
}

int SimpleGLXWindow::getViewPortWidth()
{
    return viewPortWidth;
}

int SimpleGLXWindow::getViewPortHeight()
{
    return viewPortHeight;
}

int SimpleGLXWindow::getWindowWidth()
{
    return windowWidth;
}

int SimpleGLXWindow::getWindowHeight()
{
    return windowHeight;
}

bool SimpleGLXWindow::create(int width, int height, int bpp, bool fullscreen)
{
    windowWidth = width;
    windowHeight = height;
    m_isFullscreen = fullscreen; //guarda el flag "fullscreen"

    m_display = XOpenDisplay(NULL);  //Open default display

    if (m_display == NULL)
    {
        std::cerr << "No se pudo abrir el display." << std::endl;
        return false;
    }


    int doubleBufferedAttribList [] = {
      GLX_X_RENDERABLE    , True,
      GLX_DRAWABLE_TYPE   , GLX_WINDOW_BIT,
      GLX_RENDER_TYPE     , GLX_RGBA_BIT,
      GLX_X_VISUAL_TYPE   , GLX_TRUE_COLOR,
      GLX_RED_SIZE        , 8,
      GLX_GREEN_SIZE      , 8,
      GLX_BLUE_SIZE       , 8,
      GLX_ALPHA_SIZE      , 8,
      GLX_DEPTH_SIZE      , 24,
      GLX_STENCIL_SIZE    , 8,
      GLX_DOUBLEBUFFER    , True,
      GLX_SAMPLE_BUFFERS  , 1,
      GLX_SAMPLES         , 4,
      None
    };


    int glx_major, glx_minor;

    // FBConfigs were added in GLX version 1.3.
    if ( !glXQueryVersion( m_display, &glx_major, &glx_minor ) || ( ( glx_major == 1 ) && ( glx_minor < 3 ) ) || ( glx_major < 1 ) )
    {
        cout << "Invalid GLX version\n";
        return false;
    }

//    XVisualInfo* vi = NULL;
    //Attempt to create a double buffered window
    int fbcount;
//    vi = glXChooseVisual(m_display, m_screenID, doubleBufferedAttribList,&fbcount);
    GLXFBConfig* fbc = glXChooseFBConfig(m_display, DefaultScreen(m_display), doubleBufferedAttribList,&fbcount);

    if (!fbc)
  {
    cout <<"Failed to retrieve a framebuffer config\n";
return false;
  }
  cout << "Found "<< fbcount<< " matching FB configs.\n";

  // Pick the FB config/visual with the most samples per pixel
 cout << "Getting XVisualInfos\n";
  int best_fbc = -1, worst_fbc = -1, best_num_samp = -1, worst_num_samp = 999;

  int i;
  for (i=0; i<fbcount; ++i)
  {
    XVisualInfo *vi = glXGetVisualFromFBConfig( m_display, fbc[i] );
    if ( vi )
    {
      int samp_buf, samples;
      glXGetFBConfigAttrib( m_display, fbc[i], GLX_SAMPLE_BUFFERS, &samp_buf );
      glXGetFBConfigAttrib( m_display, fbc[i], GLX_SAMPLES       , &samples  );

      cout << "Matching fbconfig " << i <<", visual ID "<< vi -> visualid <<": SAMPLE_BUFFERS = " << samp_buf << ", SAMPLES = "<< samples << "\n";

      if ( best_fbc < 0 || samp_buf && samples > best_num_samp )
        best_fbc = i, best_num_samp = samples;
      if ( worst_fbc < 0 || !samp_buf || samples < worst_num_samp )
        worst_fbc = i, worst_num_samp = samples;
    }
    XFree( vi );
  }

  GLXFBConfig bestFbc = fbc[ best_fbc ];

  // Be sure to free the FBConfig list allocated by glXChooseFBConfig()
  XFree( fbc );

  // Get a visual
  XVisualInfo *vi = glXGetVisualFromFBConfig( m_display, bestFbc );
  cout << "Chosen visual ID = " << vi->visualid << "\n";

  cout << "Creating colormap\n";
  XSetWindowAttributes swa;
  Colormap cmap;
  swa.colormap = cmap = XCreateColormap( m_display,
                                         RootWindow( m_display, vi->screen ),
                                         vi->visual, AllocNone );
  swa.background_pixmap = None ;
  swa.border_pixel      = 0;
  swa.event_mask        = ExposureMask | KeyPressMask | ButtonPress |
                          StructureNotifyMask | ButtonReleaseMask |
                          KeyReleaseMask | EnterWindowMask | LeaveWindowMask |
                          PointerMotionMask | Button1MotionMask | VisibilityChangeMask |
                          ColormapChangeMask;

  cout << "Creating window\n";
  m_XWindow = XCreateWindow( m_display, RootWindow( m_display, vi->screen ),
                              0, 0, windowWidth, windowHeight, 0, vi->depth, InputOutput,
                              vi->visual,
                              CWBorderPixel | CWColormap | CWEventMask | CWOverrideRedirect | CWCursor, &swa );
  if ( !m_XWindow )
  {
    cout << "Failed to create window.\n";
    return false;
  }

  // Done with the visual info data
  XFree( vi );

  XStoreName( m_display, m_XWindow, m_windowTitle );

  cout <<"Mapping window\n";
  XMapWindow( m_display, m_XWindow );

  // Get the default screen's GLX extension list
  const char *glxExts = glXQueryExtensionsString( m_display,
                                                  DefaultScreen( m_display ) );

  // NOTE: It is not necessary to create or make current to a context before
  // calling glXGetProcAddressARB
  glXCreateContextAttribsARBProc glXCreateContextAttribsARB = 0;
  glXCreateContextAttribsARB = (glXCreateContextAttribsARBProc)
           glXGetProcAddressARB( (const GLubyte *) "glXCreateContextAttribsARB" );

  GLXContext ctx = 0;

  // Install an X error handler so the application won't exit if GL 3.0
  // context allocation fails.
  //
  // Note this error handler is global.  All display connections in all threads
  // of a process use the same error handler, so be sure to guard against other
  // threads issuing X commands while this code is running.
  ctxErrorOccurred = false;
  int (*oldHandler)(Display*, XErrorEvent*) =
      XSetErrorHandler(&ctxErrorHandler);

  // Check for the GLX_ARB_create_context extension string and the function.
  // If either is not present, use GLX 1.3 context creation method.
  if ( !isExtensionSupported( glxExts, "GLX_ARB_create_context" ) ||
       !glXCreateContextAttribsARB )
  {
    printf( "glXCreateContextAttribsARB() not found"
            " ... using old-style GLX context\n" );
    ctx = glXCreateNewContext( m_display, bestFbc, GLX_RGBA_TYPE, 0, True );
  }

   //If it does, try to get a GL 3.0 context!
  else
  {
    int context_attribs[] =
      {
        GLX_CONTEXT_MAJOR_VERSION_ARB, 3,
        GLX_CONTEXT_MINOR_VERSION_ARB, 3,
        GLX_CONTEXT_PROFILE_MASK_ARB , GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB,
        //GLX_CONTEXT_FLAGS_ARB        , GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB,
        None
      };

    cout << "Creating context\n";
    ctx = glXCreateContextAttribsARB( m_display, bestFbc, 0,
                                      True, context_attribs );

    // Sync to ensure any errors generated are processed.
    XSync( m_display, False );
    if ( !ctxErrorOccurred && ctx )
      cout << "Created GL 3.0 context\n";
    else
    {
      // Couldn't create GL 3.0 context.  Fall back to old-style 2.x context.
      // When a context version below 3.0 is requested, implementations will
      // return the newest context version compatible with OpenGL versions less
      // than version 3.0.
      // GLX_CONTEXT_MAJOR_VERSION_ARB = 1
      context_attribs[1] = 1;
      // GLX_CONTEXT_MINOR_VERSION_ARB = 0
      context_attribs[3] = 0;

      ctxErrorOccurred = false;

      cout << "Failed to create GL 3.3 context ... using old-style GLX context\n";
      ctx = glXCreateContextAttribsARB( m_display, bestFbc, 0,
                                        True, context_attribs );
    }
  }

  // Sync to ensure any errors generated are processed.
  XSync( m_display, False );

  // Restore the original error handler
  XSetErrorHandler( oldHandler );

  if ( ctxErrorOccurred || !ctx )
  {
    cout <<"Failed to create an OpenGL context\n";
    return false;
  }

  // Verifying that context is a direct context
  if ( ! glXIsDirect ( m_display, ctx ) )
  {
    cout << "Indirect GLX rendering context obtained\n";
  }
  else
  {
    cout << "Direct GLX rendering context obtained\n";
  }

  cout <<"Making context current\n" ;
  glXMakeCurrent( m_display, m_XWindow, ctx );

  m_GL3Supported = true;

    //para correcto cerrado de la ventana
    WM_DELETE_WINDOW = XInternAtom(m_display, "WM_DELETE_WINDOW", False);
    XSetWMProtocols(m_display, m_XWindow, &WM_DELETE_WINDOW, 1);

    m_mouse = new XMouseInterface(&m_XWindow);
    m_mouse->showCursor(true);
//    //Make the new context current
//    glXMakeCurrent(m_display, m_XWindow, m_glContext);
////
////    int posx = 0;
////    int posy = 0;
////    Window winDummy;
//    unsigned int borderDummy;
//
    m_width = (unsigned) width;
    m_height = (unsigned) height;
//    m_bpp = (unsigned) bpp;
//
//    XGetGeometry(m_display, m_XWindow, &winDummy,
//                 &posx, &posy, &m_width, &m_height,
//                 &borderDummy, &m_bpp);

    m_lastTime = GetTickCount(); //Initialize the time

    if(m_GL3Supported)
    {
        cout << "inicializando glew...\n";
        glewExperimental = GL_TRUE;
        //inicializando glew
        GLenum error = glewInit(); // Enable GLEW
        if (error != GLEW_OK) // If GLEW fails
        {
            cout << "Error al iniciar la librería GLEW: " << glewGetErrorString(error) << ".\nNo es posible continuar con la ejecución de Skalium Graphic Engine 3D.";
            return false;
        }
    }

    return m_GL3Supported;
}

void SimpleGLXWindow::destroy()
{
    m_mouse->showCursor(true);
    if (m_glContext)
    {
        glXMakeCurrent(m_display, None, NULL);
        glXDestroyContext(m_display, m_glContext);
        m_glContext = NULL;
    }

    if (m_isFullscreen)
    {
        XF86VidModeSwitchToMode(m_display, m_screenID, &m_XF86DeskMode);
        XF86VidModeSetViewPort(m_display, m_screenID, 0, 0);
    }
    XDestroyWindow(m_display, m_XWindow);
    XCloseDisplay(m_display);
}


void SimpleGLXWindow::setWindowTitle(char* wName)
{
    m_windowTitle = wName;
}

void SimpleGLXWindow::swapBuffers() { glXSwapBuffers(m_display, m_XWindow); }

void SimpleGLXWindow::processEvents()
{

    m_keyboard->update();
    m_mouse->update();

    XEvent event;
    while (XPending(m_display))
    {
        XNextEvent(m_display, &event);
        switch (event.type)
        {
            case Expose:
            {
                if (event.xexpose.count != 0)
                    break;

                break;
            }

            case ConfigureNotify:
            {
                windowWidth = event.xconfigure.width;
                windowHeight = event.xconfigure.height;
                getAttachedExample()->onResize(windowWidth, windowHeight);
            }
            case MotionNotify:
            {
                //on mouse move
                m_mouse->changeMouseMoveState();
                break;
            }

            case ButtonRelease:
            {
            //Eventos del Mouse
                switch (event.xbutton.button)
                {
                    case 1:
                    {
                        //click izquierdo
    //                    t_prev=t_new;
    //                    printf("Click Occured      : [%d, %d]\n",
    //                           xevent.xbutton.x_root,
    //                           xevent.xbutton.y_root);
                        m_mouse->changeMouseButtonState(0,false);
                        break;
                    }

                    case 2:
                    {
                        //click central
                        m_mouse->changeMouseButtonState(2,false);
                        break;
                    }

                    case 3:
                    {
                        //click derecho
                        m_mouse->changeMouseButtonState(1,false);
                        break;
                    }

                    case 4:
                    {
                        //scroll up
                        break;
                    }

                    case 5:
                    {
                        //scroll down
                        break;
                    }
                    //en el default entra si no se toco ningún botón, por lo tanto hace que todos
                    //vuelvan al estado false.
                    default:
                    {
                        break;
                    }
                }
                break;

            }

            case ButtonPress:
            {
                //Eventos del Mouse
                switch (event.xbutton.button)
                {
                    case 1:
                    {
                        //click izquierdo
    //                    t_prev=t_new;
    //                    printf("Click Occured      : [%d, %d]\n",
    //                           xevent.xbutton.x_root,
    //                           xevent.xbutton.y_root);
                        m_mouse->changeMouseButtonState(0,true);
                        break;
                    }
                    case 2:
                    {
                        //click central
                        m_mouse->changeMouseButtonState(2,true);
                        break;
                    }
                    case 3:
                    {
                        //click derecho
                        m_mouse->changeMouseButtonState(1,true);
                        break;
                    }
                    case 4:
                    {
                        //scroll up
                        break;
                    }
                    case 5:
                    {
                        //scroll down
                        break;
                    }
                    //en el default entra si no se toco ningún botón, por lo tanto hace que todos
                    //vuelvan al estado false.
                    default:
                    {
                        break;
                    }
                }
                break;
            }



            case KeyPress:
            {
                if (XLookupKeysym(&event.xkey,0) == XK_Escape) {
                    m_isRunning = false;
                }

                //Register the key press with the keyboard interface
                m_keyboard->handleKeyDown(m_keyboard->translateKey(XLookupKeysym(&event.xkey,0)));
                break;
            }

            case KeyRelease:
            {
                BOGLGPKeyCode code = m_keyboard->translateKey(XLookupKeysym(&event.xkey,0));
                m_keyboard->handleKeyUp(code);
                break;
            }

            case ClientMessage:
            {
//                if (string(XGetAtomName(m_display, event.xclient.message_type)) == string("WM_PROTOCOLS"))
//                {
//                    m_isRunning = false;
//                }

                if((static_cast<unsigned int>(event.xclient.data.l[0]) == WM_DELETE_WINDOW))
                {
                    m_isRunning = false;
                }
                break;
            }


            default:
            {
                break;
            }

        }

    }

}

bool SimpleGLXWindow::isRunning()
{
    return m_isRunning;
}

void SimpleGLXWindow::attachExample(SGE3D::core* example)
{
    m_example = example;
}


float SimpleGLXWindow::getElapsedSeconds()
{
    unsigned int currentTime = GetTickCount();
    unsigned int diff = currentTime - m_lastTime;
    m_lastTime = currentTime;
    return float(diff) / 1000.0f;
}
}
#endif //WIN32

当我调用SimpleGLXWindow :: create()函数时,我收到此错误(在我的调试消息之间):

iniciando ventana linux
Found 2 matching FB configs.
Getting XVisualInfos
Matching fbconfig 0, visual ID 163: SAMPLE_BUFFERS = 1, SAMPLES = 4
Matching fbconfig 1, visual ID 164: SAMPLE_BUFFERS = 1, SAMPLES = 8
Chosen visual ID = 164
Creating colormap
Creating window
Mapping window
Creating context
Failed to create GL 3.3 context ... using old-style GLX context
Direct GLX rendering context obtained
Making context current
X Error of failed request:  BadDrawable (invalid Pixmap or Window parameter)
  Major opcode of failed request:  154 (DRI2)
  Minor opcode of failed request:  3 (DRI2CreateDrawable)
  Resource id in failed request:  0x4200002
  Serial number of failed request:  40
  Current serial number in output stream:  42

我使用CodeBlocks IDE,我的链接库是:

-L libs -Wl,-rpath libs
-Wl,-Bstatic
/home/fabian/Proyectos/SGE3D/libs/SOIL/lib/libSOIL.a
/home/fabian/libreriasDeDesarrollo/minGW/lib/libglu32.a
/home/fabian/libreriasDeDesarrollo/minGW/lib/libfreeglut.a
-Wl,-Bdynamic
libs/libGlew-1-10-sge3d.so
/usr/lib/x86_64-linux-gnu/libX11.so
/usr/lib/x86_64-linux-gnu/mesa/libGL.so
/usr/lib/x86_64-linux-gnu/libXxf86vm.so
libs/libfreetype-6-11-1-sge3d.so
libs/libfreeimage-3-sge3d.so
libs/libassimp-3-sge3d.so

-sge3d.so是使用不同名称复制/粘贴的系统库(/ usr / lib /),以避免用户需要安装它(这在32位工作正常)。

我查看ldd输出,看起来是正确的:

linux-vdso.so.1 =>  (0x00007fff3f3ad000)
    libGLEW.so.1.10 => /usr/lib/x86_64-linux-gnu/libGLEW.so.1.10 (0x00007f70b6530000)
    libX11.so.6 => /usr/lib/x86_64-linux-gnu/libX11.so.6 (0x00007f70b61f7000)
    libGL.so.1 => /usr/lib/x86_64-linux-gnu/mesa/libGL.so.1 (0x00007f70b5f5a000)
    libXxf86vm.so.1 => /usr/lib/x86_64-linux-gnu/libXxf86vm.so.1 (0x00007f70b5d54000)
    libfreetype.so.6 => /usr/lib/x86_64-linux-gnu/libfreetype.so.6 (0x00007f70b5aac000)
    libfreeimage.so.3 => /usr/lib/libfreeimage.so.3 (0x00007f70b5803000)
    libassimp.so.3 => /usr/lib/libassimp.so.3 (0x00007f70b4f8d000)
    libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f70b4c7e000)
    libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f70b4977000)
    libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f70b4760000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f70b439c000)
    libxcb.so.1 => /usr/lib/x86_64-linux-gnu/libxcb.so.1 (0x00007f70b417c000)
    libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f70b3f78000)
    libexpat.so.1 => /lib/x86_64-linux-gnu/libexpat.so.1 (0x00007f70b3d4f000)
    libglapi.so.0 => /usr/lib/x86_64-linux-gnu/libglapi.so.0 (0x00007f70b3b22000)
    libXext.so.6 => /usr/lib/x86_64-linux-gnu/libXext.so.6 (0x00007f70b3910000)
    libXdamage.so.1 => /usr/lib/x86_64-linux-gnu/libXdamage.so.1 (0x00007f70b370d000)
    libXfixes.so.3 => /usr/lib/x86_64-linux-gnu/libXfixes.so.3 (0x00007f70b3506000)
    libX11-xcb.so.1 => /usr/lib/x86_64-linux-gnu/libX11-xcb.so.1 (0x00007f70b3304000)
    libxcb-glx.so.0 => /usr/lib/x86_64-linux-gnu/libxcb-glx.so.0 (0x00007f70b30ed000)
    libxcb-dri2.so.0 => /usr/lib/x86_64-linux-gnu/libxcb-dri2.so.0 (0x00007f70b2ee7000)
    libxcb-dri3.so.0 => /usr/lib/x86_64-linux-gnu/libxcb-dri3.so.0 (0x00007f70b2ce4000)
    libxcb-present.so.0 => /usr/lib/x86_64-linux-gnu/libxcb-present.so.0 (0x00007f70b2ae1000)
    libxcb-sync.so.1 => /usr/lib/x86_64-linux-gnu/libxcb-sync.so.1 (0x00007f70b28da000)
    libxshmfence.so.1 => /usr/lib/x86_64-linux-gnu/libxshmfence.so.1 (0x00007f70b26d8000)
    libdrm.so.2 => /usr/lib/x86_64-linux-gnu/libdrm.so.2 (0x00007f70b24cb000)
    libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f70b22ac000)
    libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f70b2093000)
    libpng12.so.0 => /lib/x86_64-linux-gnu/libpng12.so.0 (0x00007f70b1e6c000)
    libjpeg.so.8 => /usr/lib/x86_64-linux-gnu/libjpeg.so.8 (0x00007f70b1c17000)
    libopenjpeg.so.5 => /usr/lib/x86_64-linux-gnu/libopenjpeg.so.5 (0x00007f70b19f4000)
    libIlmImf.so.6 => /usr/lib/x86_64-linux-gnu/libIlmImf.so.6 (0x00007f70b1744000)
    libHalf.so.6 => /usr/lib/x86_64-linux-gnu/libHalf.so.6 (0x00007f70b1501000)
    libIex.so.6 => /usr/lib/x86_64-linux-gnu/libIex.so.6 (0x00007f70b12e3000)
    libraw.so.10 => /usr/lib/x86_64-linux-gnu/libraw.so.10 (0x00007f70b103d000)
    libtiff.so.5 => /usr/lib/x86_64-linux-gnu/libtiff.so.5 (0x00007f70b0dc9000)
    /lib64/ld-linux-x86-64.so.2 (0x00007f70b67d7000)
    libXau.so.6 => /usr/lib/x86_64-linux-gnu/libXau.so.6 (0x00007f70b0bc4000)
    libXdmcp.so.6 => /usr/lib/x86_64-linux-gnu/libXdmcp.so.6 (0x00007f70b09be000)
    libIlmThread.so.6 => /usr/lib/x86_64-linux-gnu/libIlmThread.so.6 (0x00007f70b07b6000)
    libjasper.so.1 => /usr/lib/x86_64-linux-gnu/libjasper.so.1 (0x00007f70b055f000)
    liblcms2.so.2 => /usr/lib/x86_64-linux-gnu/liblcms2.so.2 (0x00007f70b0308000)
    libgomp.so.1 => /usr/lib/x86_64-linux-gnu/libgomp.so.1 (0x00007f70b00f1000)
    liblzma.so.5 => /lib/x86_64-linux-gnu/liblzma.so.5 (0x00007f70afecf000)
    libjbig.so.0 => /usr/lib/x86_64-linux-gnu/libjbig.so.0 (0x00007f70afcc1000)

但是......我没有看到我的&#34; sge3d&#34;链接的图书馆。

这是glxinfo报告(好像一切都好):

fabian@fabian-ThinkPad-L440:~$ glxinfo | grep "OpenGL"
OpenGL vendor string: Intel Open Source Technology Center
OpenGL renderer string: Mesa DRI Intel(R) Haswell Mobile 
OpenGL core profile version string: 3.3 (Core Profile) Mesa 10.6.0-devel (git-ba35393 2015-04-04 utopic-oibaf-ppa)
OpenGL core profile shading language version string: 3.30
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile
OpenGL core profile extensions:
OpenGL version string: 3.0 Mesa 10.6.0-devel (git-ba35393 2015-04-04 utopic-oibaf-ppa)
OpenGL shading language version string: 1.30
OpenGL context flags: (none)
OpenGL extensions:
OpenGL ES profile version string: OpenGL ES 3.0 Mesa 10.6.0-devel (git-ba35393 2015-04-04 utopic-oibaf-ppa)
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.00
OpenGL ES profile extensions:

1 个答案:

答案 0 :(得分:2)

您在此处请求3.3 兼容性个人资料:

int context_attribs[] =
  {
    GLX_CONTEXT_MAJOR_VERSION_ARB, 3,
    GLX_CONTEXT_MINOR_VERSION_ARB, 3,
    GLX_CONTEXT_PROFILE_MASK_ARB , GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB,
    //GLX_CONTEXT_FLAGS_ARB        , GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB,
    None
  };

Mesa does not support the compatibility profile:

  

OpenGL核心和兼容性上下文支持

     

只有Core支持OpenGL 3.1及更高版本   轮廓。没有计划支持GL_ARB_compatibility。最后   支持所有弃用功能的OpenGL版本为3.0。一些   后面的GL功能在3.0上下文中作为扩展名公开。

(请注意,OpenGL 3.1核心配置文件甚至不存在,Mesa就是这样。在GL 3.2中引入了配置文件。)

这正是glxinfo告诉你的:

OpenGL core profile version string: 3.3 (Core Profile) Mesa 10.6.0-devel (git-ba35393 2015-04-04 utopic-oibaf-ppa)
OpenGL version string: 3.0 Mesa 10.6.0-devel (git-ba35393 2015-04-04 utopic-oibaf-ppa)