TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

The Story Behind Fenster

72 点作者 hamdouni8 个月前

8 条评论

Lerc8 个月前
This has popped up because<p>Microui+fenster=Small GUI <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=41477446">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=41477446</a><p>Was posted in the last day.<p>In that thread I suggested that API compatibility would be the way to go for more esoteric platforms, Since there&#x27;s already comments here about BSD and Android targets.<p>All you need is<p><pre><code> struct fenster { const char *title; &#x2F;* window title *&#x2F; const int width; &#x2F;* window width *&#x2F; const int height; &#x2F;* window height *&#x2F; uint32_t *buf; &#x2F;* window pixels, 24-bit RGB, row by row, pixel by pixel *&#x2F; int keys[256]; &#x2F;* keys are mostly ASCII, but arrows are 17..20 *&#x2F; int mod; &#x2F;* mod is 4 bits mask, ctrl=1, shift=2, alt=4, meta=8 *&#x2F; int x; &#x2F;* mouse X coordinate *&#x2F; int y; &#x2F;* mouse Y coordinate *&#x2F; int mouse; &#x2F;* 0 = no buttons pressed, 1 = left button pressed *&#x2F; }; int fenster_open(struct fenster *f) int fenster_loop(struct fenster *f) void fenster_close(struct fenster *f) void fenster_sleep(int ms) int64_t fenster_time() fenster_pixel(f, x, y) uint32_t px = fenster_pixel(f, x, y); </code></pre> A bit more for audio, but that&#x27;s really it&#x27;s own little API<p>As a mimimal API for doing interactive apps, it&#x27;s hard to beat. I can see hobbyists who make their own operating systems taking advantage of this to get things working quickly.
felipefar8 个月前
Nice work! It wouldn&#x27;t be much work to support Android with this library and keep the single source file, since the addition of native_app_glue. It&#x27;d require just an AndroidManifest.xml, and the API communication can be done by calling the functions provided by the NDK or in the worst case by calling JNI.
immibis8 个月前
You might want to use CLOCK_MONOTONIC on POSIX or changing the system time will screw up the refresh rate or freeze the window completely.
评论 #41485700 未加载
unwind8 个月前
Very nice and very straight-forward. I really liked the part on getting &quot;Doom&quot; to run, impressive how easy such porting is now!<p>Any low-level C is kind of catnip for the old SO-powered part of my brain, but did not spend a lot of time and got a lot of confidence.i did find this bug:<p><pre><code> memset(f-&gt;buf, rgb, f-&gt;width*f-&gt;height*sizeoof(*f-&gt;buf)); </code></pre> This will not work to set a color in the general case (`rgb` is `uint32_t`) since `memset()` only uses the lower `CHAR_BIT` bits of the value, it is setting the memory byte by byte. For black or white it will work! :)
onetom8 个月前
Would it work on NetBSD&#x2F;OpenBSD&#x2F;FreeBSD&#x2F;GhostBSD too?<p>Because if it does, it would worth mentioning it in the readme.<p>In Plan 9, Rio, the window manager, does a similar thing; it exposes a framebuffer to the process running in a window, simply as the &#x2F;dev&#x2F;draw device file, iirc.
mrpippy8 个月前
In the Mac&#x2F;AppKit implementation it would be interesting to try using wantsUpdateLayer: and updateLayer: instead of drawRect. That should be more efficient.
password43218 个月前
TIL: <i>Our goal here is to have a framebuffer for a single window that would run and look the same on Linux, Windows and macOS.</i><p>Basically re-implementing enough SDL from scratch to run Doom, nice!
igtztorrero8 个月前
WASN + Fester, for Browser, it is possible?