OpenGL In 500 Lines (Sort Of…)

How difficult is OpenGL? How difficult can it be if you can build a basic renderer in 500 lines of code? That’s what [Dmitry] did as part of a series of tiny applications. The renderer is part of a course and the line limit is to allow students to build their own rendering software. [Dmitry] feels that you can’t write efficient code for things like OpenGL without understanding how they work first.

For educational purposes, the system uses few external dependencies. Students get a class that can work with TGA format files and a way to set the color of one pixel. The rest of the renderer is up to the student guided by nine lessons ranging from Bresenham’s algorithm to ambient occlusion. One of the last lessons switches gears to OpenGL so you can see how it all applies.

Continue reading “OpenGL In 500 Lines (Sort Of…)”

The Noble Effort To Put OpenSCAD In The Browser

In a world of CAD packages with arcane or unfriendly interfaces there’s a stand-out player that’s remarkable because it has no interface. OpenSCAD is a CAD package for coders, in which all design elements are created in a scripting language rather than graphically. It’s maybe not for everyone but it has a significant following, and its reach has been extended further as you can now run it from within a modern web browser.

The origins of this project can be tracked back to August of 2021, when when Autodrop3D’s [mmiscool] offered a sizable bounty for anyone willing to port the parametric CAD modeler to web assembly. Developer [Dominick Schroer] ultimately answered the call with openscad-wasm, which implements the core of OpenSCAD as a JavaScript ES6 module. From there, it just needed to get paired with a user interface, and off to the cloud we go.

Opening it up and giving it a go, we found it to be a very usable OpenSCAD version, albeit a little slower to render than the desktop equivalent on a mediocre laptop. We didn’t try exporting and printing an STL, but so far it has given us no reason to believe it wouldn’t be every bit as useful as the version you’re used to.

But wait, there’s more! Parallel to this effort, [Olivier Chafik] has also been working on his own idea of what OpenSCAD in the web should be. He’s using the same core developed by [Dominick], but has combined it with the Monaco editor from Microsoft and a Javascript STL viewer. Despite being very similar, we’re happy to report there’s no rivalry here; in fact, according to the video after the break, it sounds like two the projects have already swapped a bit of code.

The move among desktop applications to move into the browser and often into a pay-to-play cloud has seemed relentless over recent years, so it’s pleasing to see a rare example of a browser migration that’s open-source. It has the handy effect of bringing the CAD package to platforms such as tablets or Chromebooks which wouldn’t normally be an OpenSCAD platform, and this we like, a lot.

Continue reading “The Noble Effort To Put OpenSCAD In The Browser”

WebGPU… Better Than WebGL?

As the browser becomes more like an operating system, we are seeing more deep features being built into them. For example, you can now do a form of assembly language for the browser. Sophisticated graphics have been around using WebGL since around 2011, but some people find it hard to use. [Surma] was one of those people and tried a new method that is just surfacing to do the same thing: WebGPU.

[Surma] liked it better and shares a lot of information in the post and — oddly — the post doesn’t use WebGPU for graphics very much. Instead, the post focuses on using GPU cores for fast computation, something else you can do with WebGPU. If your goal is to draw on the screen, though, you need to know the basics and the post links to a site with examples of doing this.

Continue reading “WebGPU… Better Than WebGL?”

Modern CPUs Are Smarter Than You Might Realize

When it comes to programming, most of us write code at a level of abstraction that could be for a computer from the 1960s. Input comes in, you process it, and you produce output. Sure, a call to strcpy might work better on a modern CPU than on an older one, but your basic algorithms are the same. But what if there were ways to define your programs that would work better on modern hardware? That’s what a pre-print book from [Sergey Slotin] answers.

As a simple example, consider the effects of branching on pipelining. Nearly all modern computers pipeline. That is, one instruction is fetching data while an older instruction is computing something, while an even older instruction is storing its results. The problem arises when you already have an instruction partially executed when you realize that an earlier instruction caused a branch to another part of your code. Now the pipeline has to be backed out and performance suffers while the pipeline refills. Anything that had an effect has to reverse and everything else needs to be discarded.

That’s bad for performance. Because of this, some CPUs try to predict if a branch is likely to occur or not and then speculatively fill the pipeline for the predicted case. However, you can structure your code, for example, so that it is more obvious how branching will occur or even, for some compilers, explicitly inform the compiler if the branch is likely or not.

As you might expect, techniques like this depend on your CPU and you’ll need to benchmark to show what’s really going on. The text is full of graphs of execution times and an analysis of the generated assembly code for x86 to explain the results. Even something you think is a pretty good algorithm — like binary search, for example, suffers on modern architectures and you can improve its performance with some tricks. Actually, it is interesting that the tricks work on GCC, but don’t make a difference on Clang. Again, you have to measure these things.

Probably 90% of us will never need to use any of the kind of optimization you’ll find in this book. But it is a marvelous book if you enjoy solving puzzles and analyzing complex details. Of course, if you need to squeeze those extra microseconds out of a loop or you are writing a library where performance is important, this might be just the book you are looking for. Although it doesn’t cover many different CPUs, the ideas and techniques will apply to many modern CPU architectures. You’ll just have to do the work to figure out how if you use a different CPU.

We’ve looked at pieces of this sort of thing before. Pipelining, for example. Sometimes, though, optimizing your algorithm isn’t as effective as just changing it for a better one.

Bringing IMessage To The Mac

If you’ve invested in the Apple ecosystem, the joys of iMessage likely illuminate your life. Your phone and desktop and laptop all sync your messages. But what if your desktop is running Mac OS 9 or System 2? This is where [CamHenlin’s] MessagesForMacintosh comes in.

Unfortunately, it does require a more modern Mac to act as an access point into the wider iMessage network. The modern Mac sets up a GraphQL database that can be accessed. Then a serial cable connects your “retro daily driver” to a translation layer that converts the serial commands into GraphQL commands. This could be something simple and network-connected like an ESP32 or a program running on your iMessage Mac. [CamHenlin] has a second Mac mini in his demo, seen above.

[CamHenlin] leverages his library known as CoprocessorJS. It allows older machines to hand off complex workloads to more modern machines, allowing modern machines to act as a coprocessor. Getting a single binary to run across many different versions of Mac OS and System is tricky and there were a few tricks involved. Retro68 is a C++17 compiler that targets PowerPC and 68k architectures. Additionally, Nuklear Quickdraw is used to provide a GUI in a performant manner.

It is always a joy to see older hardware do new tricks, often with the help of a bit of modern hardware. Connecting your Mac to the internet can be as easy as Pi.

Where Do You Want To Go Today? Perhaps To A Linux With A Familiar Interface?

Sometimes we cover works of extreme technological merit here at Hackaday, other times we cover interesting projects that while they might not lie at the bleeding edge are interesting enough that they deserve a wider audience. Sometimes though, we bring you something in this field simply because it amuses us and we think it will you too. Such is the case with [Bryan Lunduke]’s look at making a Linux desktop look like Windows 95. And lest you think that it might be yet another skin to make Windows users transition to Linux a bit easier, the aim and result is to make it look exactly like Microsoft’s mid-90s desktop.

Underneath it all is the relatively familiar xUbuntu distribution, with a deliciously troll-worthy project called Chicago95 atop it. This takes some existing Windows 95 theme and icon projects, and adds GTK themes, an MS-DOS shell theme, the ability to install those cheesy ’90s Plus! themes, and a Microsoft Office 95 theme for LibreOffice. It really does deliver an experience very close to the Redmond original.

So, what’s the point here in 2022? In the first instance it’s an excellent opportunity to troll open-source enthusiast friends with a crusty laptop seemingly running ’95 and showing YouTube videos on Netscape Navigator 3. But beyond the jokes there is a serious use for it. There may be many criticisms that can be leveled at Windows 95, but it’s safe to say that its GUI was a significant success whose echoes can be found in many desktops here in 2022. There are a huge number of people in the world who are completely at home in a Windows 95 environment who might struggle with a Linux desktop, and this gives them a way to be immediately productive.  Would you give your grandmother a Linux box with this desktop?

screenshow showing the supposed AllSpice interface. It resembles the GitHub interface, and shows a pull request open to add some ESD protection to a device.

AllSpice Building A Hardware Development Ecosystem For Companies

In our “hardware development gets serious” news, we’ve recently learned about AllSpice, a startup building hardware development collaboration infrastructure for companies. Hardware developers are great at building hardware tools for themselves, but perhaps not always so when it comes to software, and AllSpice aims to fill that gap at the “hardware company” level. Nowadays, what commonly happens is that software development tools and integrations are repurposed for hardware needs, and the results aren’t always as stellar as they get in the software world. In other words, AllSpice is learning from the positive outcomes of software industry and building a platform that takes the best parts from these tools, aiming to get to similarly positive outcomes in areas where currently hardware team experiences are lacking.

What AllSpice is building seems to be an umbrella platform designed to augment, integrate and hook into a slew of different already-developed platforms like GitHub, GitLab, Jira (and some other ones), and add much-needed features that large-scale hardware developers can’t afford to maintain and develop themselves. “Design review by screenshot” isn’t unheard of in hardware circles, and likely a thing that everyone of us with hardware collaboration experience has partaken in. On a company scale, there’s a myriad of hardware-related problems like that to solve and polish over.

Continue reading “AllSpice Building A Hardware Development Ecosystem For Companies”