POV-Ray : Newsgroups : povray.unix : Rendering several scenes from c++ program Server Time
26 Jun 2024 02:46:11 EDT (-0400)
  Rendering several scenes from c++ program (Message 1 to 7 of 7)  
From: Cesar
Subject: Rendering several scenes from c++ program
Date: 27 Mar 2005 17:10:01
Message: <web.42472f00891d40d43a965a410@news.povray.org>
Hi!

I'll have to render like 100 images using povray from inside a c++ program.
Ideally, I would like to get raw data in a buffer (instead of a png file.
Maybe get the png file in memory and not in a file, so that I don't have to
waste time reading the file) but I don't know if it's possible. If not, no
big deal, but I don't know how to find out when the rendering is over, so I
can start the next rendering.

Anyone could help me or point me to a tutorial or something on the subject?

Thanks,

Cesar


Post a reply to this message

From: Vincent LE PRINCE
Subject: Re: Rendering several scenes from c++ program
Date: 28 Mar 2005 03:05:03
Message: <pan.2005.03.28.08.05.05.637919@nospam.wanadoo.fr>
On Sun, 27 Mar 2005 17:09:04 -0500, Cesar wrote:

> I'll have to render like 100 images using povray from inside a c++ program.
> Ideally, I would like to get raw data in a buffer (instead of a png file.
> Maybe get the png file in memory and not in a file, so that I don't have to
> waste time reading the file) but I don't know if it's possible. If not, no
> big deal, but I don't know how to find out when the rendering is over, so I
> can start the next rendering.

I had to do the same once. Here is how it works, in my case :
  _ i create 2 pipes : 1 for povray text output ( to catch error messages,
  stats etc... ) and 1 for image raw data.
  _ i launch povray with +GApipe1 +Opipe2 +FP
  _ i also launch 2 threads to read each pipe
 
You know render is over when you got all image data, but you have to
relaunch povray for each image ( you can use the same pipes i think ). I
guess you can do without threads if you don't need to catch error message,
cancel render etc... it would be really more simple :)

Bye.


Post a reply to this message

From: Cesar
Subject: Re: Rendering several scenes from c++ program
Date: 28 Mar 2005 07:55:00
Message: <web.4247fe4ef6d6dc3ca81ae8950@news.povray.org>
> I had to do the same once. Here is how it works, in my case :
>   _ i create 2 pipes : 1 for povray text output ( to catch error messages,
>   stats etc... ) and 1 for image raw data.
>   _ i launch povray with +GApipe1 +Opipe2 +FP
>   _ i also launch 2 threads to read each pipe
>
> You know render is over when you got all image data, but you have to
> relaunch povray for each image ( you can use the same pipes i think ). I
> guess you can do without threads if you don't need to catch error message,
> cancel render etc... it would be really more simple :)

Tks for answering. I don't get it. What do you mean by 2 pipes? How do I
separate text output from the data (if I understood correctly)? At first I
won't need to catch error msgs, so I can use the "really more simple"
version, but I'm interested in the more complex one too. :o)


Post a reply to this message

From: Vincent LE PRINCE
Subject: Re: Rendering several scenes from c++ program
Date: 30 Mar 2005 12:38:13
Message: <pan.2005.03.30.17.38.32.86017@nospam.wanadoo.fr>
On Mon, 28 Mar 2005 07:53:34 -0500, Cesar wrote:

> Tks for answering. I don't get it. What do you mean by 2 pipes? How do I
> separate text output from the data (if I understood correctly)? At first I
> won't need to catch error msgs, so I can use the "really more simple"
> version, but I'm interested in the more complex one too. :o)

Pipes are special files created by mkfifo function ( and some others ones ).
They are used to communicate between two programs. The first one ( pov )
writes to the pipe, the second one read in ( your program ). So you invoke
pov with '+GApipe1 +Opipe2 +FP' and pov writes all text stuff ( stats,
errors, warnings... ) to pipe1 and image data ( here ppm data ) to pipe2.
Then you have 2 threads, each of them reading a pipe. Not really easy, and
certainly the simplest solution, but it works !


Post a reply to this message

From: Cesar
Subject: Re: Rendering several scenes from c++ program
Date: 30 Mar 2005 13:55:01
Message: <web.424af5b4f6d6dc3cedf9457e0@news.povray.org>
Ok. I now create the pipe and set it as the povray output. In my program,
after I create the pipe I fork() and run povray in the child, while in the
parent I read the pipe. But now I get the following error:

Possible Rendering Error: Got 1 SIGPIPE.

I presume it has something to do with the synchronization between reading
from and writing to the pipe, but I can't figure out what's wrong. Can you
help me with that?

Thanks



Vincent LE PRINCE <vin### [at] nospamwanadoofr> wrote:
> On Mon, 28 Mar 2005 07:53:34 -0500, Cesar wrote:
>
> > Tks for answering. I don't get it. What do you mean by 2 pipes? How do I
> > separate text output from the data (if I understood correctly)? At first I
> > won't need to catch error msgs, so I can use the "really more simple"
> > version, but I'm interested in the more complex one too. :o)
>
> Pipes are special files created by mkfifo function ( and some others ones ).
> They are used to communicate between two programs. The first one ( pov )
> writes to the pipe, the second one read in ( your program ). So you invoke
> pov with '+GApipe1 +Opipe2 +FP' and pov writes all text stuff ( stats,
> errors, warnings... ) to pipe1 and image data ( here ppm data ) to pipe2.
> Then you have 2 threads, each of them reading a pipe. Not really easy, and
> certainly the simplest solution, but it works !


Post a reply to this message

From: Warp
Subject: Re: Rendering several scenes from c++ program
Date: 30 Mar 2005 15:42:58
Message: <424b0f52@news.povray.org>
Cesar <ces### [at] terracombr> wrote:
> Possible Rendering Error: Got 1 SIGPIPE.

  The SIGPIPE signal is thrown when a process writes to a pipe but
there's no process reading it (ie. there's no process which has that
pipe open in read mode). This can only happen if the reader process
closes the pipe (or is killed or whatever) because the pipe cannot
be opened in write mode unless it's already opened in read mode by
something else.

-- 
plane{-x+y,-1pigment{bozo color_map{[0rgb x][1rgb x+y]}turbulence 1}}
sphere{0,2pigment{rgbt 1}interior{media{emission 1density{spherical
density_map{[0rgb 0][.5rgb<1,.5>][1rgb 1]}turbulence.9}}}scale
<1,1,3>hollow}text{ttf"timrom""Warp".1,0translate<-1,-.1,2>}//  - Warp -


Post a reply to this message

From: Vincent LE PRINCE
Subject: Re: Rendering several scenes from c++ program
Date: 1 Apr 2005 15:35:32
Message: <pan.2005.04.01.20.36.04.520216@nospam.wanadoo.fr>
On Wed, 30 Mar 2005 15:42:58 -0500, Warp wrote:


>   The SIGPIPE signal is thrown when a process writes to a pipe but
> there's no process reading it (ie. there's no process which has that
> pipe open in read mode). This can only happen if the reader process
> closes the pipe (or is killed or whatever) because the pipe cannot
> be opened in write mode unless it's already opened in read mode by
> something else.

That's right. You have to create/open the pipe before launching pov. You 
can also receive a sigpipe if pipe buffers are full, i.e if the read
process don't read it.


Post a reply to this message

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