I am trying to create a game loop for an xlib window, but I cannot manage to paint the window correctly. Right now I am creating a window with XCreateSimpleWindow(...), and
The reason you are not seeing anything is because you are neglecting the X event loop. All you do is sending data to the X server, but there is no way for the X server to communicate back.
You must set up a loop where XEvents are read from the queue and dispatched c.q. processed. Something like:
XEvent event;
while (XPending (m_display))
{
XNextEvent (m_display, &event);
if (XFilterEvent (&event, None))
{
continue;
}
switch (event.type)
{
case KeyPress:
..
case ButtonPress:
..
case Expose:
..
case MapNotify:
..
// etc
}
}
This can be combined with your endless loop, though.
But yes, painting pixel by pixel is extremely slow. I don't even want to calculate the protocol overhead... :P