commit 93430ae
Devine Lu Linvega
·
2024-01-15 18:54:58 +0000 UTC
parent 148549b
Faster screen initialization
1 files changed,
+5,
-6
+5,
-6
1@@ -79,7 +79,7 @@ emu_resize(int w, int h)
2 static Visual *visual;
3 if(window) {
4 visual = DefaultVisual(display, 0);
5- ximage = XCreateImage(display, visual, DefaultDepth(display, DefaultScreen(display)), ZPixmap, 0, (char *)uxn_screen.pixels, uxn_screen.width * s, uxn_screen.height * s, 32, 0);
6+ ximage = XCreateImage(display, visual, DefaultDepth(display, DefaultScreen(display)), ZPixmap, 0, (char *)uxn_screen.pixels, w * s, h * s, 32, 0);
7 XResizeWindow(display, window, w * s, h * s);
8 XMapWindow(display, window);
9 }
10@@ -192,7 +192,6 @@ emu_event(Uxn *u)
11 static int
12 display_init(void)
13 {
14- int s = uxn_screen.scale;
15 Atom wmDelete;
16 static Visual *visual;
17 XColor black = {0};
18@@ -202,9 +201,10 @@ display_init(void)
19 display = XOpenDisplay(NULL);
20 if(!display)
21 return system_error("init", "Display failed");
22- /* display */
23+ /* default size */
24+ screen_resize(WIDTH, HEIGHT, 1);
25 visual = DefaultVisual(display, 0);
26- window = XCreateSimpleWindow(display, RootWindow(display, 0), 0, 0, uxn_screen.width * s + PAD * 2, uxn_screen.height * s + PAD * 2, 1, 0, 0);
27+ window = XCreateSimpleWindow(display, RootWindow(display, 0), 0, 0, uxn_screen.width + PAD * 2, uxn_screen.height + PAD * 2, 1, 0, 0);
28 if(visual->class != TrueColor)
29 return system_error("init", "True-color visual failed");
30 XSelectInput(display, window, ButtonPressMask | ButtonReleaseMask | PointerMotionMask | ExposureMask | KeyPressMask | KeyReleaseMask);
31@@ -212,7 +212,7 @@ display_init(void)
32 XSetWMProtocols(display, window, &wmDelete, 1);
33 XStoreName(display, window, boot_rom);
34 XMapWindow(display, window);
35- ximage = XCreateImage(display, visual, DefaultDepth(display, DefaultScreen(display)), ZPixmap, 0, (char *)uxn_screen.pixels, uxn_screen.width * s, uxn_screen.height * s, 32, 0);
36+ ximage = XCreateImage(display, visual, DefaultDepth(display, DefaultScreen(display)), ZPixmap, 0, (char *)uxn_screen.pixels, uxn_screen.width, uxn_screen.height, 32, 0);
37 /* hide cursor */
38 bitmap = XCreateBitmapFromData(display, window, empty, 1, 1);
39 blank = XCreatePixmapCursor(display, bitmap, bitmap, &black, &black, 0, 0);
40@@ -284,7 +284,6 @@ main(int argc, char **argv)
41 return 0;
42 }
43 /* Game Loop */
44- screen_resize(WIDTH, HEIGHT, 1);
45 u.dev[0x17] = argc - i;
46 if(uxn_eval(&u, PAGE_PROGRAM)) {
47 console_listen(&u, i, argc, argv);