Live data from Hacker News

Minimal Cross-Platform Graphics

zserge.com

41–50 of 67 posts

Re: Minimal Cross-Platform Graphics

#43
post #20

Earlier quoted context omitted.

2d graphics are rendered on the GPU nowadays, and rightly so. Even SDL uses the GPU wherever it can, by default.

That's a silly statement. If you want to place single pixels, a GPU won't help in any way. The most efficient way would be to write pixels with the CPU into a mapped GPU texture, and then render this texture as fullscreen quad. That's hardly more efficient than going through the system's windowing system. For applications like emulators, or making vintage games (like Doom) run on modern platforms, that approach makes…

Doing this through the GPU is actually somehow A LOT slower on at least Windows than going through the windowing system.

Re: Minimal Cross-Platform Graphics

#44

This is extremely useful, and the page is beautifully written. Some people write absurd electron behemoths, and then there's this jewel of elegance. Could this be compiled as an αpε? Such a thing would make many heads explode.

Alpha Rho Epsilon? Alpha Pee Epsilon? Google isn't helping me here...

Re: Minimal Cross-Platform Graphics

#45

This is extremely useful, and the page is beautifully written. Some people write absurd electron behemoths, and then there's this jewel of elegance. Could this be compiled as an αpε? Such a thing would make many heads explode.

Alpha Rho Epsilon? Alpha Pee Epsilon? Google isn't helping me here...

I think they're referring to this:

https://justine.lol/ape.html

One of many HN discussions about the topic here:

https://news.ycombinator.com/item?id=26273960

Re: Minimal Cross-Platform Graphics

#46

This is extremely useful, and the page is beautifully written. Some people write absurd electron behemoths, and then there's this jewel of elegance. Could this be compiled as an αpε? Such a thing would make many heads explode.

Alpha Rho Epsilon? Alpha Pee Epsilon? Google isn't helping me here...

[deleted]

Re: Minimal Cross-Platform Graphics

#48

This is extremely useful, and the page is beautifully written. Some people write absurd electron behemoths, and then there's this jewel of elegance. Could this be compiled as an αpε? Such a thing would make many heads explode.

I think the Xlib dependency would prevent compilation as an αpε. I put some effort into doing X11 from scratch (without Xlib or Xcb) to make this possible. Or at least, my aim was to be able to build with musl libc and generate a single executable that would run on many different Linuxes. https://github.com/abainbridge/deadfrog-lib/blob/master/src/... . It is janky though.

One advantage of speaking X directly for small projects is that one can allocate fixed ids.

Re: Minimal Cross-Platform Graphics

#49
post #39
post #28

Wonderful. I really wanted something like this to do Graphic the "hard way", also the most fun way... I was trying to use Tcl-TK for that but this seems a lot lower level, perfect for what I wanted to do which is to write a small GUI toolkit for tiny apps.

Writing pixels into an RGBA framebuffer in main memory is fun, but it's also the easy and slow way to do graphics. The hard way these days is to figure out how to use a modern GPU to do the rendering you need. It's almost always several orders of magnitude faster.

writing pixels into an rgba framebuffer in main memory is still plenty fast to do a full-screen animation at 60 hertz tho

the benefit of the gpu is no longer (since maybe late last millennium) that you don't have the memory bandwidth to your framebuffer; it's that you can do a lot of computation per pixel

typically the gpu advantage is only about an order of magnitude tho

Re: Minimal Cross-Platform Graphics

#50
post #17
post #5

Very cool! This example I think needs editing: memset(f->buf, rgb, f->width*f->height*sizeoof(uint32_t)); it's described as a way to "fill the complete framebuffer with a solid colour", but 'rgb' is shown in the previous snipped to be 'uint32_t'. That is not how 'memset()' [1] works, it will only use the least significant 8 bits of the 'int'-typed value argument. So it would use whatever blue bits where in 'rgb', onl…

Fine, but at least fix this bug: .. (sizeof *f->buf) .. Because otherwise thats one stray space char away from a bad day ..

Or ... sizeof(*f->buf)? I’d forgotten that sizeof even allows dropping the parens, but isn’t that asking for trouble? “sizeof a b” is sometimes parsed as “sizeof(a) b” and sometimes as “sizeof(a b) depending on the precedence of operator . Is there any downside to always using parens and writing sizeof() like a function call?
Post reply on HN