ghaerr / microwindows

The Nano-X Window System
Other
646 stars 91 forks source link

cosmopolitan binaries experiment? #77

Open coderofsalvation opened 1 year ago

coderofsalvation commented 1 year ago

Any thoughts on cosmopolitan libc and microwindows? A bit of a stretch?

ghaerr commented 1 year ago

Hello @coderofsalvation,

Any thoughts on cosmopolitan libc and microwindows? A bit of a stretch?

Actually, I have been working with @jart and last year put together a demo of the Nuklear immediate-mode GUI running on Microwindows as an APE Cosmopolitan executable. This is described in https://github.com/jart/cosmopolitan/issues/35#issuecomment-1097504620, https://github.com/jart/cosmopolitan/issues/35#issuecomment-1085224055 and https://github.com/jart/cosmopolitan/issues/35#issuecomment-1079989433.

This post shows how to compile a demo on Cosmopolitan. There's still some portability problems though, as while Cosmo supplies the abilities to run the C library across many platforms, the mouse and graphics support ends up (in this demo case at least) being marshaled across to another native host binary (a framebuffer emulator).

Tell me more about what you're interested in accomplishing and I'll try to help.

Thank you!

coderofsalvation commented 1 year ago

oh that is very cool to see. I'm going to re-read up on that thread (I recognize it from 1-2 years ago when I helped testing cosmogfx). TBH I'm not really trying to accomplish anything (yet), I was more thinking that the maintainer of this repository has huge knowledge on slim crossplatform gui's (and perhaps wanted to connect you with @jart). But it's great to hear that already happened!

By just looking swiftly at that thread, it seems that there's still a native binary needed to make ends meet. Allow me to brainstorm a bit here: in theory, could there be multiple native host binaries (linux X11, macOS, windows e.g.) which could be zipped into the .com (like redbean) and extracted during runtime?

ps. what I really like about microwindows and cosmopolitan, is that it has a focus on portability & durability (a binary application which ages well over time). There doesn't seem to be much focus on that, so kudos for that.

ghaerr commented 1 year ago

Allow me to brainstorm a bit here: in theory, could there be multiple native host binaries (linux X11, macOS, windows e.g.) which could be zipped into the .com (like redbean) and extracted during runtime?

Well, I suppose native host binaries could be encapsulated within a .com APE binary, but that kind of defeats the purpose of using the APE binary in the first place (and none of those native binaries would be linked with Cosmopolitan). The real problem is that there isn't a cross-platform standard for mouse events (that is, a mouse isn't handled directly by the OS, but instead by a GUI), and that while there is almost a portable way to access hardware video graphics using a framebuffer, the user may not actually be running in a framebuffer-compatble mode (that is, X11 could be running on non-fb graphics chip, or another windowing, GUI or TUI may be currently running).

Both the mouse and graphics drawing issues can be portably solved by using an SDL library layer in between the application and the OS/screen/mouse, but this usually means popping up an SDL window from which the application runs, and SDL is not yet ported to Cosmopolitan.

Thank you!

coderofsalvation commented 1 year ago

Hm good points. Going even deeper, we could say that we're stuck with the blind spots of POSIX SDL would indeed be the way.