Readit News logoReadit News
tubs commented on Fenster: Most minimal cross-platform GUI library   github.com/zserge/fenster... · Posted by u/klaussilveira
Surac · 5 days ago
not connected to this, but i wish i would find a c code example on how to draw a line with a width, without antialias while only setting each pixel once. this seems to be a real hard problem.
tubs · 5 days ago
You want to define a parallelogram or rectangle, turn it into edge equations, then iterate the spans.

Alternative is bresenham then for each point iterate a span in the minor axis.

tubs commented on How we enforce .NET coding standards to improve productivity   anthonysimmon.com/worklea... · Posted by u/fratellobigio
kreco · 23 days ago
While msbuild is powerful, I strongly believe it should have been a standard C# language build system instead of a XML-based one.

Any non-trivial thing to do is a pain to figure out if the documentation is not extensive enough.

I really love C#, but msbuild is one of the weak links to me, almost everything else is a joy to use.

tubs · 22 days ago
But you augment it with tools written in c# which is best of both worlds. Builds are defined declaratively and custom actions are defined in code. Not the horrible hybrid of eg ant or cmake.
tubs commented on Simulating hand-drawn motion with SVG filters   camillovisini.com/coding/... · Posted by u/camillovisini
tubs · a month ago
Pretty site and good write up but my phone turned to molten lava viewing it!
tubs commented on Writing your own C++ standard library part 2   nibblestew.blogspot.com/2... · Posted by u/signa11
comex · 3 months ago
> Sadly there is not a simple way to integrate this to native loop constructs without macros and even then it is a bit ugly.

I’ve implemented something like this before, without macros. It’s a little ugly, but not that bad IMO.

If you write a native range-based for loop:

    for (auto foo : obj) { /* do something */ }
it essentially desugars to

    auto it = foo.begin();
    auto end = foo.end();
    for (; it != end; ++it) {
        auto foo = *it;
        /* do something */
    }
        
To make it work with a custom type, you need to implement `begin()` and `end()` methods, but the returned objects don’t need to support the full STL iterator protocol; they only need to support the exact sequence of operations from the desugaring. So, for example, `end()` can return a unique `End` type that contains no data and does nothing. `begin()` can return a different type that does all the real work and implements `operator!=(End)`. With that, it’s not too hard to implement a wrapper around a Python-like iterator protocol.

The main drawback is that you need to temporarily store each item in the begin object before it’s moved into the iteration variable. This is because you have to already know whether a next item exists at the point of `it != end`, but then the item isn’t actually retrieved until `*it`. The extra move has a slight cost, but the compiler can often optimize it away to nothing. You can also avoid this if the for loop uses a reference type (`for (auto& foo : obj)`).

tubs · 3 months ago
I think you can also define begin/end as non member functions (eg if you don’t own the code for the type).
tubs commented on Layers All the Way Down: The Untold Story of Shader Compilation   moonside.games/posts/laye... · Posted by u/birdculture
tsukikage · 3 months ago
GPUs suck at things like e.g. data driven branches. What looks like one shader at a high level ends up creating many separate compiled blobs, because you really want some of the parameters baked in at compile time to avoid the performance tanking, and this means you need to compile a version of the shader for every combination of values those parameters can take.
tubs · 3 months ago
Uniform branches are free pretty much

The main issue is that gpr allocation is static and worse case. So on the majority of hardware you hose your occupancy.

tubs commented on Matt Godbolt sold me on Rust by showing me C++   collabora.com/news-and-bl... · Posted by u/LorenDB
simonask · 4 months ago
Works for whom?

C++ build systems are notoriously brittle. When porting a project to a new platform, you're never just porting the code, you are also porting your build system. Every single project is bespoke in some way, sometimes because of taste, but most of the time because of necessity.

It works because people spend a huge amount of time to make it work.

tubs · 4 months ago
This seems hyperbolic. At work we cross compile the same code for a decent number of different platform - six different OS (Linux Mac windows and some embedded ones) over 20odd cpu architectures.

It’s the same build system for all of them.

tubs commented on Matt Godbolt sold me on Rust by showing me C++   collabora.com/news-and-bl... · Posted by u/LorenDB
dvratil · 4 months ago
The one thing that sold me on Rust (going from C++) was that there is a single way errors are propagated: the Result type. No need to bother with exceptions, functions returning bool, functions returning 0 on success, functions returning 0 on error, functions returning -1 on error, functions returning negative errno on error, functions taking optional pointer to bool to indicate error (optionally), functions taking reference to std::error_code to set an error (and having an overload with the same name that throws an exception on error if you forget to pass the std::error_code)...I understand there's 30 years of history, but it still is annoying, that even the standard library is not consistent (or striving for consistency).

Then you top it on with `?` shortcut and the functional interface of Result and suddenly error handling becomes fun and easy to deal with, rather than just "return false" with a "TODO: figure out error handling".

tubs · 4 months ago
And panics?
tubs commented on Shadertoys Ported to Rust GPU   rust-gpu.github.io/blog/2... · Posted by u/efnx
tubs · 5 months ago
I understand the sentiment but to be very pedantic most GPUs do not understand SPIRV, it’s the drivers that do.
tubs commented on Show HN: JavaScript PubSub in 163 Bytes   github.com/hassanshaikley... · Posted by u/hmmokidk
thewisenerd · 5 months ago
good to know pub-sub shenanigans are ubiquitous lol

here's my implementation from a while back with `setTimeout` like semantics; used it to avoid prop-drilling in an internal dashboard (sue me)

https://gist.github.com/thewisenerd/768db2a0046ca716e28ff14b...

tubs · 5 months ago

    sub => ref = 0
    sub => ref = 1
    unsub(0)
    sub => ref = 1 (two subs with same ref!)

tubs commented on Fast-PNG: PNG image decoder and encoder   github.com/image-js/fast-... · Posted by u/javatuts
mattdesl · 6 months ago
Last time I benchmarked png-tools, it was about 2-6x faster than fast-png for encoding.

https://github.com/mattdesl/png-tools

I’ve also added some other features like multi-threaded encoding, cancellation, encoding physical dimensions, color profiles, all of which is useful for encoding large print-ready PNGs on the client.

(No shade against fast-png, it’s a good library, but maybe not the fastest!)

tubs · 6 months ago
Interesting you default to paeth.

Only working on grayscale 16bit images with only the lower 10bits populated I never found it reduced image size. But I was doing per scan adaptive filtering so maybe if I was only allowed one filter for the entire image that would be it?

Just wondering if you did any experiments with different filter strategies?

u/tubs

KarmaCake day235February 27, 2012View Original