POV-Ray : Newsgroups : povray.general : Feature Request: Binary #write : Re: Feature Request: Binary #write Server Time
30 Jul 2024 10:24:48 EDT (-0400)
  Re: Feature Request: Binary #write  
From: clipka
Date: 24 Mar 2009 10:55:00
Message: <web.49c8f3446dca0b641484d1730@news.povray.org>
Warp <war### [at] tagpovrayorg> wrote:
> Sounds like another language feature better for POV-Ray 4 rather than
> the current one.
>
>   In other words, rather hacking tons of tiny features on top of the old
> SDL, it's better to design a new SDL which is so flexible that you can do
> almost anything with it without the need to add core features.

This is a bit different from various other SDL extension proposals, IMO.

SDL is so flexible that you can do virtually everything with it, so most
suggested SDL extensions would just eliminate the need of tons of macros.

Writing DF3 files, however, is something that as of now *cannot* be done with
macros, no matter how sophisticated they are. Not unless you're fine with file
sizes of 16 MB and over at less than 7 bit resolution.

So we have a real gap to be filled here, not just some nice polishing-up.

Plus, IMO there's nothing wrong with polishing up the 3.x SDL a bit either - if
it's easy enough to implement. Which is definitely the case here.


BTW, if we'd be talking about POV 4 SDL, I'd take a totally different approach.
For example, the ability to dump a whole 3D-array to DF3 with just a single
statement would come in handy. But with 3.x SDL being ripe for replacement,
*that* is something I decided to file under "too much effort for too little
gain - to be postponed until POV 4 SDL", as it can easily be done with quite a
simple macro once binary #write is available. Much easier than implementing
native SDL support for an "array dump", as a matter of fact:

#macro Write3DArrayToDf3(filename, a)
  #local sizeX = dimension_size(a,1);
  #local sizeY = dimension_size(a,2);
  #local sizeZ = dimension_size(a,3);
  #fopen WriteToDf3_File filename write
  #write (WriteToDf3_File, int16 sizeX sizeY sizeZ)
  #local iZ = 0;
  #while (iZ < sizeZ)
    #local iY = 0;
    #while (iY < sizeY)
      #local iX = 0;
      #while (iX < sizeX)
        #write (WriteToDf3_File, int16 a[iX][iY][iZ] * 65535)
        #local iX = iX + 1;
      #end
      #local iY = iY + 1;
    #end
    #local iZ = iZ + 1;
  #end
  #fclose WriteToDf3_File
#end

There.

To instead add native support for this to POV, not only would something like the
above have to be implemented somewhere - there would also be extra work to do
thinking about a good syntax, implementing code to parse that syntax, taking
care of file handling, checking for unexpected pitfalls, and maybe changing
code to work around these pitfalls. Then checking that it didn't break
anything. That's why I'd agree that *this* isn't worth the pain for 3.x SDL.

Basic support for binary writes, however, is not much of a pain, and its gain
simply cannot be achieved otherwise without 3rd-party tools.

I hope this gives a clear picture of how I think about extending 3.x SDL. Of
course it's just my opinion - yours may differ.


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.