2013-10-03 26 views
1

我想獲得一個gl上下文,綁定一個PixelBuffer在其中繪製事物。我可以驗證調用,如glClearColor工作,但我無法生成任何GL列表。我不知道,這是代碼:glGenLists返回0,一個有效的GLX上下文

typedef GLXContext (*glXCreateContextAttribsARBProc)(Display*, GLXFBConfig, GLXContext, Bool, const int*); 
typedef Bool (*glXMakeContextCurrentARBProc)(Display*, GLXDrawable, GLXDrawable, GLXContext); 
static glXCreateContextAttribsARBProc glXCreateContextAttribsARB = NULL; 
static glXMakeContextCurrentARBProc glXMakeContextCurrentARB = NULL; 

glXCreateContextAttribsARB = (glXCreateContextAttribsARBProc) glXGetProcAddressARB((const GLubyte *) "glXCreateContextAttribsARB"); 
glXMakeContextCurrentARB = (glXMakeContextCurrentARBProc) glXGetProcAddressARB((const GLubyte *) "glXMakeContextCurrent"  ); 

const char *displayName = NULL; 
Display* display = XOpenDisplay(displayName); 

static int visualAttribs[] = { None }; 

int numberOfFramebufferConfigurations = 0; 
GLXFBConfig* fbConfigs = glXChooseFBConfig(display, DefaultScreen(display), visualAttribs, &numberOfFramebufferConfigurations); 

if (!fbConfigs) 
{ 
    fprintf(stderr, "The OpenGL on this system does not support glXCreateContextAttribsARB or glXMakeContextCurrent."); 
    return; 
} 

int context_attribs[] = { 
    GLX_CONTEXT_MAJOR_VERSION_ARB, 4, 
    GLX_CONTEXT_MINOR_VERSION_ARB, 2, 
    GLX_CONTEXT_FLAGS_ARB, GLX_CONTEXT_DEBUG_BIT_ARB, 
    GLX_CONTEXT_PROFILE_MASK_ARB, GLX_CONTEXT_CORE_PROFILE_BIT_ARB, 
    None 
}; 

GLXContext openGLContext = glXCreateContextAttribsARB(display, fbConfigs[0], 0, True, context_attribs); 


int pbufferAttribs[] = { 
    GLX_PBUFFER_WIDTH, cols, 
    GLX_PBUFFER_HEIGHT, rows, 
    None 
}; 

GLXPbuffer pbuffer = glXCreatePbuffer(display, fbConfigs[0], pbufferAttribs); 

// clean up: 
XFree(fbConfigs); 
XSync(display, False); 

if (glXMakeContextCurrent(display, pbuffer, pbuffer, openGLContext)) 
{ 

    if (openGLContext) 
      fprintf(stdout, "Got context \n"); 
    GLuint list = glGenLists(1); 
    fprintf(stdout, "Got list %d\n", list); // This is always zero. 
    glNewList(list, GL_COMPILE); 
    glEndList(); 

    glClearColor(0, 1, 0, 0); 

回答

3

您正在請求4.2核心上下文,所以沒有顯示列表。自GL 3.0以來,它們已被棄用。

相關問題