Question

I'm trying to get an gl context, bind a PixelBuffer draw things in it. I can verify that calls such as glClearColor works however I'm not able to generate any gl lists. I'm out of ideas, here's the code:

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);
Was it helpful?

Solution

You are requesting a 4.2 core context, so there are no display lists. They were deprecated since GL 3.0.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top