Rendering Scenes in HTML TADS

I had a weird dream last night, and it got some gears turning in my head.

So, it’s been a while since I’ve delved into the deeper parts of TADS code, but I remember there being a thing where a custom I/O reader could be defined to load an asset.

Is it possible to write TADS code which writes pixel values to a buffer, which is then live-loaded as an image asset for an HTML TADS game?

If I had room images and object images, could I assemble a composite image from them, based on state data?

Or, more like what happened in my dream: If I had geometry data which used fixed-point numbers (for speed reasons), and a custom 3D rendering algorithm, could I dynamically render a scene with changing camera angles and object locations, save the result to a buffer, and load that buffer as an image?

I’m fully expecting this to be really slow, even with optimizations put in place. Also, if I’m misremembering the intricacies of how I/O works in TADS, this might all be completely wrong.

3 Likes

I don’t recall this mechanism exactly, but I wonder if you could do something like this: Create a TemporaryFile, write to it using a ByteArray, and then present the image to the user doing something like this:

<img src="<<tmpFile.getFilename>>">

If HTML TADS supported a data: URL for the IMG SRC, that would save the hassle of writing a temporary file.

Of course, that leaves the heavy lifting of producing a ByteArray in an image format HTML TADS supports.

(I was considering a similar problem for my WIP, but did not have to deal with fully arbitrary image composition. I was going to produce images for each possible combination of game state, name them in a way that made it easy to map state → file name, and present them that way. Ugly, but achievable.)

3 Likes

I have known people having weird dreams, but you take the cake. In fact, all the cakes are yours now.

4 Likes

Woo!! Cakes!! :star_struck:

Yeah, in my dream, @jbg was the one who figured this out. Then I woke up like "Haha that was wild… :grin: … …wait a moment. :thinking: "

3 Likes

on the speed, dunno. try implementing Jim’s idea with wireframe models (cubes, pyramids &c. and see how many frames can do. (aside that, IMVHO, discussing FPS-improving algorithms in an IF programming site perhaps is heavily OT…)

Best regards from Italy,
dott. Piergiorgio.

1 Like