Skip to main content

JDK bug report

Hey everyone,

A few days ago, I watched a YouTube video on pixel snapping effects in 2D games, which are even present in highly popular games. I was curious if ScrewBox also suffers from these issues. Upon closer inspection, I noticed some strange effects on the edges of the game window. The effects were rarely visible and I didn't notice them before because they only appeare next to the screen edges.

After investigating for a few hours, I identified the error as the metal render on MacOs. However, I couldn’t find any workaround other than switching to OpenGL rendering, which is significantly slower on Mac because it’s outdated.

I shared this Java bug with a colleague, and she expressed indifference if it wasn’t officially reported. Of course, she was right, so I invested a few more hours to report the bug, which was reviewed and now is officially accepted as JDK-8371679.

So you could say I found a genuine edge case bug in the JDK.😏

Flexible draw order

Hey everyone,

in the past, ScrewBox had some very restrictive limitations due to the architecture decisions I made, both consciously and unconsciously. For instance, I never considered implementing a split-screen mode within the existing code base. However, it was possible, but it was a significant challenge to rewrite hundreds of lines of code. After at least three months of work, finally getting it done felt like a huge success.

The upcoming version 3.14.0 will finally address another restriction that had been bothering me. Unfortunately, it doesn’t sound particularly exciting: Now, it’s possible to draw entities in any order across all entity systems. This allows for some nice refactorings within the engine, which results in slight performance improvements. However, it also provides much more freedom when creating games with ScrewBox.

To draw across entity system execution order simply add the order offset to your drawing call.
// will be drawn second
canvas.drawLine(line, LineDrawOptions.color(RED).drawOrder(2));

// will be drawn first
canvas.drawLine(line, LineDrawOptions.color(RED).drawOrder(1));

// will be drawn above the light
int aboveLight = Order.PRESENTATION_LIGHT.mixinDrawOrder(1);
canvas.drawLine(line, LineDrawOptions.color(RED).drawOrder(aboveLight));

Lights on

Hey there! I’ve just dropped version 3.9.0. This version adds support for drawing arcs, expands the options for drawing rectangles and uses the new options to add enhanced light effects. Expanded light areas also support lens flare effects now. Looking back on some old screenshots it really makes me smile. ScrewBox graphics made a huge leap since I started in 2021.

2021

2025

The new version also comes with a lot of useful minor features and fixes. For all features have a look at the full changelog. I will concentrate on adding even more light effects for expanded light areas in the next version(s).

Lessons on performance

I must have spends hundreds of hours on enhancing the performance of ScrewBox, but today I learned that I have missed some pretty obvious basics.

For context: I am working on a MacOs machine and when I started graphic programming with Java I learned that there was a pretty unavoidable system property that must be set to avoid software rendering and therefore low fps values: sun.java2d.opengl=true. When I discovered the option this massively enhanced the speed of apps created with ScrewBox.

When JDK 21 added support for the Metal API on MacOs I was quite disappointed that this didn't enhance the performance at all. But I simply missed removing the outdated property.

ScrewBox warns you, when you are not using the opengl setting and my local run configurations already packed these settings so I didn't question this after so many hours getting used to enforce this setting.

Today I discovered that removing the setting allows the JDK on MacOs to default to the Metal API and therefore push the performance from 800 to 1000 fps in one app and from 8000 to 11000 fps in another simpler one.

Version 3.8.0 removed the unnecessary warning on MacOs and automatically defaults to OpenGl on Windows machines. There is no longer a need to specify any JVM start parameters when working on Windows.

Make some noise

Greetings! Version 3.4.0 of ScrewBox added support for generating Perlin Noise and fractal noise. Both algorithms can be used to generate infinite deterministic landscapes and are commonly used in games like Minecraft or whenever 'procedural generation' is mentioned. The next minor version of ScrewBox will also add support for three dimensional Perlin Noise.

noise

ScrewBox is a game engine designed for creating 2D content, so the third dimension used for generating noise will most likely be time. Nonetheless, you can also create some pseudo 3D content using these utilities, as seen in the example screenshots. The second one is a three-dimensional fractal noise which looks quite cool but doesn't add much value to the engine because it's so slow and I cannot imagine any actual use but creating nice looking blog post illustrations.

noise

Generating noise is quite easy. Enjoy!

// 2D noise
PerlinNoise.generatePerlinNoise(seed, x, y); // value in range -1 to 1

// 3D noise
PerlinNoise.generatePerlinNoise3d(seed, x, y, z); // value in range -1 to 1

Update July 26, 2025

After massively improving the performance of noise generation (10 times faster!) version 3.6.0 will also ship 3d Fractal Noise generation. Because, why not?

Maven relocation

Yesterday I reworked the build process to move Maven source to the updated Sonartype Central Repository. I used the opportunity to update the Maven coordinates to the new domain. ScrewBox can now be found at the updated coordinates: dev.screwbox:screwbox-core. The update comes with updated packages for all classes and some improvements for the build process. For further info see full changelog.

Fluid physics

Greetings! Version 2.19.0 of the ScrewBox engine has just been released. This version adds support for simple fluid physics.

fluids

To make something fluid, just add a FluidComponent to the entity you want it to be. To make the fluid show up, add a FluidRenderComponent and pick your colors to make water, lava, or anything else you want. Physics entities can swim in the fluid by adding a FloatComponent.

Future will tell what features will be added to the fluid physics. In the current state, the fluids are quite rudimentary. Combining the fluids with a reflection is definitely on my to-do list.

A fresh start

A few weeks ago I decided to add some real documentation to ScrewBox, the project I have worked on for nearly four years now. I used this opportunity to register screwbox.dev as new home address for the project. Hopefully anybody will have a few good hours or days working with ScrewBox. Stay tuned for some upcoming content updates.