Hi there,
I am trying to create a shaped SDL window using the X11 shape extension.
So far nothing happens … maybe someone has an idea what I am missing.
The code follows the xeyes demo that is part of the XFree sources.
Below is the code that I am using to enable the shape extension. The
input is a 8bit mask surface in black and white.
Ciao
Andreas----
void SetWindowShape (SDL_Surface *mask)
{
int x,y;
Uint8 *curpos;
GC shapeGC;
Pixmap shape_mask;
SDL_SysWMinfo wmi;
Display *display;
Window window;
XGCValues xgcv;
/* Get the X window handle */
SDL_VERSION(&wmi.version);
if (!SDL_GetWMInfo(&wmi)) {
return;
} else {
display=wmi.info.x11.display;
window=wmi.info.x11.window;
}
/* Create shape pixmap */
shape_mask = XCreatePixmap (display, window, mask->w, mask->h, 1);
shapeGC = XCreateGC (display, shape_mask, 0, &xgcv);
XSetForeground (display, shapeGC, 0);
XFillRectangle (display, shape_mask, shapeGC, 0, 0, mask->w, mask->h);
XSetForeground (display, shapeGC, 1);
/* Scan through the mask surface to create shape pixmap */
curpos=(Uint8 *)mask->pixels;
for (y=0; yh; y++) {
for (x=0; xw; x++) {
if (curpos!=0) {
XDrawPoint(display, shape_mask, shapeGC, x, y);
}
curpos++;
}
/ Apply pixmap */
XShapeCombineMask (display, window, ShapeBounding, 0, 0, shape_mask,
ShapeSet);
XFreePixmap (display, shape_mask);
}
–
| Andreas Schiffler aschiffler at home.com |
| Senior Systems Engineer - Deskplayer Inc., Buffalo |
| 4707 Eastwood Cres., Niagara Falls, Ont L2E 1B4, Canada |
| +1-905-371-3652 (private) - +1-905-371-8834 (work/fax) |