WINGs: Remove #ifdef OLD_CODE
[wmaker-crm.git] / wrlib / tests / testrot.c
blob093d09041e377f2232524be78b40feaa85883013
2 #include <X11/Xlib.h>
3 #include "wraster.h"
4 #include <stdlib.h>
5 #include <stdio.h>
6 #include <unistd.h>
7 #include "tile.xpm"
8 Display *dpy;
9 Window win;
10 RContext *ctx;
11 RImage *img;
12 Pixmap pix;
14 #define MAX(a,b) (a)>(b) ? (a) : (b)
16 int main(int argc, char **argv)
18 RContextAttributes attr;
19 float a;
21 dpy = XOpenDisplay("");
22 if (!dpy) {
23 puts("cant open display");
24 exit(1);
27 attr.flags = RC_RenderMode | RC_ColorsPerChannel;
28 attr.render_mode = RDitheredRendering;
29 attr.colors_per_channel = 4;
30 ctx = RCreateContext(dpy, DefaultScreen(dpy), &attr);
32 if (argc < 2)
33 img = RGetImageFromXPMData(ctx, image_name);
34 else
35 img = RLoadImage(ctx, argv[1], 0);
37 if (!img) {
38 puts(RMessageForError(RErrorCode));
39 exit(1);
41 win = XCreateSimpleWindow(dpy, DefaultRootWindow(dpy), 10, 10,
42 MAX(img->width, img->height), MAX(img->height, img->width), 0, 0, 0);
43 XMapRaised(dpy, win);
44 XFlush(dpy);
46 a = 0;
47 while (1) {
48 RImage *tmp;
50 a = a + 1.0;
52 tmp = RRotateImage(img, a);
53 if (!RConvertImage(ctx, tmp, &pix)) {
54 puts(RMessageForError(RErrorCode));
55 exit(1);
57 RReleaseImage(tmp);
59 XSetWindowBackgroundPixmap(dpy, win, pix);
60 XFreePixmap(dpy, pix);
61 XClearWindow(dpy, win);
62 XSync(dpy, 0);
63 usleep(50000);
65 exit(0);