Faster screen initialization

This commit is contained in:
Devine Lu Linvega 2024-01-15 10:54:58 -08:00
parent 148549bae2
commit 93430aebf0
1 changed files with 5 additions and 6 deletions

View File

@ -79,7 +79,7 @@ emu_resize(int w, int h)
static Visual *visual; static Visual *visual;
if(window) { if(window) {
visual = DefaultVisual(display, 0); visual = DefaultVisual(display, 0);
ximage = XCreateImage(display, visual, DefaultDepth(display, DefaultScreen(display)), ZPixmap, 0, (char *)uxn_screen.pixels, uxn_screen.width * s, uxn_screen.height * s, 32, 0); ximage = XCreateImage(display, visual, DefaultDepth(display, DefaultScreen(display)), ZPixmap, 0, (char *)uxn_screen.pixels, w * s, h * s, 32, 0);
XResizeWindow(display, window, w * s, h * s); XResizeWindow(display, window, w * s, h * s);
XMapWindow(display, window); XMapWindow(display, window);
} }
@ -192,7 +192,6 @@ emu_event(Uxn *u)
static int static int
display_init(void) display_init(void)
{ {
int s = uxn_screen.scale;
Atom wmDelete; Atom wmDelete;
static Visual *visual; static Visual *visual;
XColor black = {0}; XColor black = {0};
@ -202,9 +201,10 @@ display_init(void)
display = XOpenDisplay(NULL); display = XOpenDisplay(NULL);
if(!display) if(!display)
return system_error("init", "Display failed"); return system_error("init", "Display failed");
/* display */ /* default size */
screen_resize(WIDTH, HEIGHT, 1);
visual = DefaultVisual(display, 0); visual = DefaultVisual(display, 0);
window = XCreateSimpleWindow(display, RootWindow(display, 0), 0, 0, uxn_screen.width * s + PAD * 2, uxn_screen.height * s + PAD * 2, 1, 0, 0); window = XCreateSimpleWindow(display, RootWindow(display, 0), 0, 0, uxn_screen.width + PAD * 2, uxn_screen.height + PAD * 2, 1, 0, 0);
if(visual->class != TrueColor) if(visual->class != TrueColor)
return system_error("init", "True-color visual failed"); return system_error("init", "True-color visual failed");
XSelectInput(display, window, ButtonPressMask | ButtonReleaseMask | PointerMotionMask | ExposureMask | KeyPressMask | KeyReleaseMask); XSelectInput(display, window, ButtonPressMask | ButtonReleaseMask | PointerMotionMask | ExposureMask | KeyPressMask | KeyReleaseMask);
@ -212,7 +212,7 @@ display_init(void)
XSetWMProtocols(display, window, &wmDelete, 1); XSetWMProtocols(display, window, &wmDelete, 1);
XStoreName(display, window, boot_rom); XStoreName(display, window, boot_rom);
XMapWindow(display, window); XMapWindow(display, window);
ximage = XCreateImage(display, visual, DefaultDepth(display, DefaultScreen(display)), ZPixmap, 0, (char *)uxn_screen.pixels, uxn_screen.width * s, uxn_screen.height * s, 32, 0); ximage = XCreateImage(display, visual, DefaultDepth(display, DefaultScreen(display)), ZPixmap, 0, (char *)uxn_screen.pixels, uxn_screen.width, uxn_screen.height, 32, 0);
/* hide cursor */ /* hide cursor */
bitmap = XCreateBitmapFromData(display, window, empty, 1, 1); bitmap = XCreateBitmapFromData(display, window, empty, 1, 1);
blank = XCreatePixmapCursor(display, bitmap, bitmap, &black, &black, 0, 0); blank = XCreatePixmapCursor(display, bitmap, bitmap, &black, &black, 0, 0);
@ -284,7 +284,6 @@ main(int argc, char **argv)
return 0; return 0;
} }
/* Game Loop */ /* Game Loop */
screen_resize(WIDTH, HEIGHT, 1);
u.dev[0x17] = argc - i; u.dev[0x17] = argc - i;
if(uxn_eval(&u, PAGE_PROGRAM)) { if(uxn_eval(&u, PAGE_PROGRAM)) {
console_listen(&u, i, argc, argv); console_listen(&u, i, argc, argv);