win32

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit f1bc01c09fd6d0c9224b58ff7dc53bb3d50b803c
parent d62afb6f23a6e22c3a3293c6b24756ba8ba08f0f
Author: Matsuda Kenji <info@mtkn.jp>
Date:   Wed, 17 Dec 2025 17:58:16 +0900

use 2 pictures

Diffstat:
Mwin32.c | 37++++++++++++++++++++-----------------
1 file changed, 20 insertions(+), 17 deletions(-)

diff --git a/win32.c b/win32.c @@ -18,8 +18,9 @@ int main(void) { .event_mask = KeyPressMask | ExposureMask, }; + int width = 800, height = 600; Window window = XCreateWindow(display, DefaultRootWindow(display), - 0, 0, 800, 600, 0, + 0, 0, width, height, 0, DefaultDepth(display, screen), InputOutput, DefaultVisual(display, screen), @@ -47,7 +48,7 @@ int main(void) { Picture picture = XRenderCreatePicture(display, window, &pictformat, 0, NULL); XRenderColor color = { .red = 0xffff, .green = 0xffff, .blue = 0xeaea, .alpha = 0xffff }; - XRectangle rectangle = { .x = 0, .y = 0, .width = 800, .height = 600 }; + XRectangle rectangle = { .x = 0, .y = 0, .width = width, .height = height }; XRenderFillRectangles(display, PictOpSrc, picture, &color, &rectangle, 1); XVisualInfo vi32; @@ -66,33 +67,35 @@ int main(void) { vi32.visual, CWBorderPixel|CWColormap, &attr32); - Pixmap pixmap32 = XCreatePixmap(display, window32, 800, 600, 32); - Picture picture32 = XRenderCreatePicture(display, pixmap32, &pictformat32, 0, NULL); - XRenderColor colors[2] = { - { .red = 0xffff, .alpha = 0x0fff }, - { .green = 0xffff, .alpha = 0x0fff }, - }; - XRectangle rectangles[2] = { - { .x = 100, .y = 100, .width = 300, .height = 400 }, - { .x = 200, .y = 200, .width = 300, .height = 200 }, - }; - XRenderFillRectangles(display, PictOpSrc, picture32, &color, &rectangle, 1); - XRenderFillRectangles(display, PictOpOver, picture32, &colors[0], &rectangles[0], 1); - XRenderFillRectangles(display, PictOpOver, picture32, &colors[1], &rectangles[1], 1); + + int width1 = 300, height1 = 300; + Pixmap pixmap32_1 = XCreatePixmap(display, window32, width1, height1, 32); + Picture picture32_1 = XRenderCreatePicture(display, pixmap32_1, &pictformat32, 0, NULL); + XRenderColor color1 = { .red = 0xffff, .green = 0, .blue = 0, .alpha = 0x3fff }; + XRectangle rectangle1 = { .x = 0, .y = 0, .width = width1, .height = height1 }; + XRenderFillRectangles(display, PictOpSrc, picture32_1, &color1, &rectangle1, 1); + + int width2 = 300, height2 = 100; + Pixmap pixmap32_2 = XCreatePixmap(display, window32, width2, height2, 32); + Picture picture32_2 = XRenderCreatePicture(display, pixmap32_2, &pictformat32, 0, NULL); + XRenderColor color2 = { .red = 0, .green = 0xffff, .blue = 0, .alpha = 0x3fff }; + XRectangle rectangle2 = { .x = 0, .y = 0, .width = width2, .height = height2 }; + XRenderFillRectangles(display, PictOpSrc, picture32_2, &color2, &rectangle2, 1); XSync(display, 0); int quit = 0; XEvent event; while (!quit) { XRenderFillRectangles(display, PictOpSrc, picture, &color, &rectangle, 1); - XRenderComposite(display, PictOpOver, picture32, 0, picture, 0, 0, 0, 0, 0, 0, 800, 600); + XRenderComposite(display, PictOpOver, picture32_1, 0, picture, 0, 0, 0, 0, 100, 100, width1, height1); + XRenderComposite(display, PictOpOver, picture32_2, 0, picture, 0, 0, 0, 0, 200, 200, width2, height2); XNextEvent(display, &event); if (event.type == KeyPress && event.xkey.keycode == 49) { quit = 1; } } - XFreePixmap(display, pixmap32); + XFreePixmap(display, pixmap32_1); XRenderFreePicture(display, picture); XCloseDisplay(display); }