POV-Ray : Newsgroups : povray.unofficial.patches : Sniffing UberPOV Server Time
15 Oct 2024 17:06:31 EDT (-0400)
  Sniffing UberPOV (Message 1 to 6 of 6)  
From: Cousin Ricky
Subject: Sniffing UberPOV
Date: 5 Mar 2021 10:54:07
Message: <6042541f$1@news.povray.org>
Does anyone know whether it is possible for a scene file to detect 
whether or not it is being rendered by UberPOV, without bombing out if 
it is rendered by official POV-Ray?

Why would I need to do this?  Because I'm writing a macro that needs to 
know whether or not true inverse square light attenuation is available. 
For official POV-Ray, this is version >= 3.8, but for UberPOV, it is 
version >= 3.71.

My first (and so far only) idea was to start with a test for the 
existence of the variable 'unofficial', but it turns out POV-Ray 3.8 
does the same test--but treats it as if it were a keyword.  This screws 
up the test for any SDL code running under 3.8.


Post a reply to this message

From: Mr
Subject: Re: Sniffing UberPOV
Date: 6 Mar 2021 16:40:00
Message: <web.6043f638176d1c7e16086ed00@news.povray.org>
Cousin Ricky <ric### [at] yahoocom> wrote:
> Does anyone know whether it is possible for a scene file to detect
> whether or not it is being rendered by UberPOV, without bombing out if
> it is rendered by official POV-Ray?
>
> Why would I need to do this?  Because I'm writing a macro that needs to
> know whether or not true inverse square light attenuation is available.
> For official POV-Ray, this is version >= 3.8, but for UberPOV, it is
> version >= 3.71.
>
> My first (and so far only) idea was to start with a test for the
> existence of the variable 'unofficial', but it turns out POV-Ray 3.8
> does the same test--but treats it as if it were a keyword.  This screws
> up the test for any SDL code running under 3.8.

Yes.
I believe you're searching for the combination of this :

#ifdef(unofficial)

with a more narrowed patch version number that belongs only to uber pov such as:

#if(unofficial = \"patch\") #if(patch(\"upov-reflection-roughness\") > 0)


Post a reply to this message

From: Bald Eagle
Subject: Re: Sniffing UberPOV
Date: 6 Mar 2021 17:55:00
Message: <web.604407ee176d1c7e1f9dae300@news.povray.org>
"Mr" <nomail@nomail> wrote:

> > My first (and so far only) idea was to start with a test for the
> > existence of the variable 'unofficial', but it turns out POV-Ray 3.8
> > does the same test--but treats it as if it were a keyword.  This screws
> > up the test for any SDL code running under 3.8.
>
> Yes.
> I believe you're searching for the combination of this :
>
> #ifdef(unofficial)
>
> with a more narrowed patch version number that belongs only to uber pov such as:
>
> #if(unofficial = \"patch\") #if(patch(\"upov-reflection-roughness\") > 0)


in qtpovray3.8:

#ifdef (unofficial)
Parse Warning: Trying to test whether a reserved keyword is defined. Test result
may not be what you expect.
#declare U = unofficial;
Parse Error: Expected 'RValue to declare', unofficial found instead
#declare P = patch;
Parse Error: Cannot pass uninitialized identifier to non-optional LValue.
#debug unofficial
Parse Error: Expected 'string expression', unofficial found instead
#debug patch
Parse Error: Expected 'string expression', undeclared identifier 'patch' found
instead


Post a reply to this message

From: Cousin Ricky
Subject: Re: Sniffing UberPOV
Date: 8 Mar 2021 13:30:17
Message: <60466d39$1@news.povray.org>
On 2021-03-06 6:53 PM (-4), Bald Eagle wrote:
> "Mr" <nomail@nomail> wrote:
> 
>>> My first (and so far only) idea was to start with a test for the
>>> existence of the variable 'unofficial', but it turns out POV-Ray 3.8
>>> does the same test--but treats it as if it were a keyword.  This screws
>>> up the test for any SDL code running under 3.8.
>>
>> Yes.
>> I believe you're searching for the combination of this :
>>
>> #ifdef(unofficial)
>>
>> with a more narrowed patch version number that belongs only to uber pov such as:
>>
>> #if(unofficial = \"patch\") #if(patch(\"upov-reflection-roughness\") > 0)
> 
> 
> in qtpovray3.8:
> 
> #ifdef (unofficial)
> Parse Warning: Trying to test whether a reserved keyword is defined. Test result
> may not be what you expect.
> #declare U = unofficial;
> Parse Error: Expected 'RValue to declare', unofficial found instead
> #declare P = patch;
> Parse Error: Cannot pass uninitialized identifier to non-optional LValue.
> #debug unofficial
> Parse Error: Expected 'string expression', unofficial found instead
> #debug patch
> Parse Error: Expected 'string expression', undeclared identifier 'patch' found
> instead

Exactly.  The results are the same in official POV-Ray 3.8.  The problem 
is that the test on 'unofficial' is reliable _only_ with a patch that 
uses it--which is exactly what we don't know in advance; and any further 
refined tests are pointless.

I'll just go ahead and assume that the user is using official POV-Ray, 
and have them set a flag variable if they are using a 3.7.1-based patch.


Post a reply to this message

From: clipka
Subject: Re: Sniffing UberPOV
Date: 26 May 2021 20:17:08
Message: <60aee504$1@news.povray.org>
Am 08.03.2021 um 19:30 schrieb Cousin Ricky:

> Exactly.  The results are the same in official POV-Ray 3.8.  The problem 
> is that the test on 'unofficial' is reliable _only_ with a patch that 
> uses it--which is exactly what we don't know in advance; and any further 
> refined tests are pointless.

Consider this a bug in the POV-Ray v3.8 betas.


Post a reply to this message

From: clipka
Subject: Re: Sniffing UberPOV
Date: 27 May 2021 13:18:21
Message: <60afd45d@news.povray.org>
Am 05.03.2021 um 16:54 schrieb Cousin Ricky:
> Does anyone know whether it is possible for a scene file to detect 
> whether or not it is being rendered by UberPOV, without bombing out if 
> it is rendered by official POV-Ray?
> 
> Why would I need to do this?  Because I'm writing a macro that needs to 
> know whether or not true inverse square light attenuation is available. 
> For official POV-Ray, this is version >= 3.8, but for UberPOV, it is 
> version >= 3.71.
> 
> My first (and so far only) idea was to start with a test for the 
> existence of the variable 'unofficial', but it turns out POV-Ray 3.8 
> does the same test--but treats it as if it were a keyword.  This screws 
> up the test for any SDL code running under 3.8.


Some background information:

The problem arises with recent development versions of POV-Ray that (1) 
recognize `unofficial` as a proper keyword (as in `#version unofficial 
FOO`, which official POV-Ray has been supporting for ages in the sense 
that it prompts a very specific error message), and (2) report all 
recognized keywords as "defined" with respect to the `#ifdef` statement 
and its kin.

In v3.7 and early development versions identifying as v3.7.1, the 
statement had been handled in a comparatively hackish manner, which did 
not recognize `unofficial` as a proper keyword. Therefore, those 
versions are unproblematic.

In later v3.7.1 development versions, starting with 
v3.7.1-alpha.8449793, `unofficial` was promoted to a keyword proper. 
However, `#ifdef` and its kin still reported keywords as "not defined", 
so those versions are also unproblematic.

The problem was only introduced with the experimental 
v3.8.0-tokenizer.9841908, and later with the mainline 
v3.8.0-alpha.10008988, which changed the behaviour of `#ifdef` to report 
keywords as "defined", including the `unofficial` keyword.

Note however that the change of the `#ifdef` statement also means that 
support for the `patch` keyword can be tested directly, in a manner that 
is also compatible with older versions. Also, whether or not `#ifdef` 
works this way can be tested with a known keyword.


The following code will cause parse warnings with some versions, but 
other than that it should work fine for any version:

---------------------------------------------------------------
// Tell POV-Ray that we'll be doing our own feature probing.
#version version;

// Test whether UberPOV-style `#patch`/`patch()` mechanism
// seems to be available
#ifdef(ifdef)
   // New `#ifdef` behaviour, reporting supported keywords as defined.
   // We can probe for support of the `patch` keyword directly.
   #declare HAVE_PATCH = defined(patch);
#else
   // Old `#ifdef` behaviour, reporting keywords as undefined.
   // We can probe for support of the `unofficial` variable.
   #ifdef(unofficial)
     #declare HAVE_PATCH = (unofficial = "patch");
   #else
     #declare HAVE_PATCH = false;
   #end
#end

// Probe for required features
#if(HAVE_PATCH)
   // Probe features individually via `#patch`/`patch()`
   // (or probe for UberPOV version via that same mechanism
   // using "upov" as the feature name, though this is somewhat
   // discouraged)
   ...
#else
   // Probe via `#version`/`version´
   ...
#end
---------------------------------------------------------------


Note that support for the `patch` keyword per se does _not_ necessarily 
imply that the version used is actually UberPOV. Most notably, the 
details of the mechanism were specifically designed such that other 
derivatives of POV-Ray could use the same mechanism without conflict, 
and official POV-Ray might also eventually support it, if only to 
further promote it as a standard mechanism for detecting derivatives and 
probing for their features.


Post a reply to this message

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