I have no idea what it going on.
I spent around 3 hours trying to fix it, but no luck. My code is: `
temp->wA.border_pixel = BlackPixel(temp->d, temp->sID);
temp->wA.background_pixel = WhitePixel(temp->d, temp->sID);
temp->wA.override_redirect = true;
temp->wA.colormap = XCreateColormap(temp->d, RootWindow(temp->d, temp->sID), temp->vI->visual, AllocNone);
temp->wA.event_mask = ExposureMask;
The whole code of the function is this:
window *createWindow(int height, int width, const char *name)
{
window *temp = (window *)malloc(sizeof(window));
temp->d = XOpenDisplay(NULL);
temp->s = DefaultScreenOfDisplay(temp->d);
temp->sID = DefaultScreen(temp->d);
int tempattribs[] = {
GLX_RGBA,
GLX_DOUBLEBUFFER,
GLX_DEPTH_SIZE, 24,
GLX_STENCIL_SIZE, 8,
GLX_RED_SIZE, 8,
GLX_GREEN_SIZE, 8,
GLX_BLUE_SIZE, 8,
GLX_SAMPLE_BUFFERS, 0,
GLX_SAMPLES, 0,
None};
memcpy(temp->attribs, tempattribs, sizeof(tempattribs));
temp->vI = glXChooseVisual(temp->d, temp->sID, temp->attribs);
if (temp->vI == NULL)
{
perror("ERROR: GLXCHOOSEVISUAL FAILED!\n");
return NULL;
}
temp->wA.border_pixel = BlackPixel(temp->d, temp->sID);
temp->wA.background_pixel = WhitePixel(temp->d, temp->sID);
temp->wA.override_redirect = true;
temp->wA.colormap = XCreateColormap(temp->d, RootWindow(temp->d, temp->sID), temp->vI->visual, AllocNone);
temp->wA.event_mask = ExposureMask;
temp->w = XCreateWindow(temp->d, RootWindow(temp->d, temp->sID), 0, 0, height, width, 0, temp->vI->depth, InputOutput, temp->vI->visual, CWBackPixel | CWColormap | CWBorderPixel | CWEventMask, &temp->wA);
temp->c = glXCreateContext(temp->d, temp->vI, NULL, 1);
glXMakeCurrent(temp->d, temp->w, temp->c);
return temp;
}
In case you are wondering what is going on, I have a struct containing all the elements; the code above initialises the elements. Here is the struct:
typedef struct window
{
Window w;
Display *d;
Screen *s;
XEvent e;
int sID;
bool running;
XVisualInfo *vI;
GLXContext c;
XSetWindowAttributes wA;
int attribs[];
} window;
`
I ran a debugger on it and got this result:
typ
Thread 1 "main" received signal SIGSEGV, Segmentation fault.
0x0000007ff7e10754 in _XcmsAddCmapRec () from /lib/aarch64-linux-gnu/libX11.so.6e here
I finally got it finished, by creating another colormap and assigning the original colormap to the new one.