#include <stdio.h>
#include <stdlib.h>
#include "ri.h"
int main(int argc, char **argv)
{
char buf[256];
/*
You can still use the standard error output to diagnose your program.
This allows you to see that your program is started only once even if it
is invoked several times in a frame.
*/
fprintf(stderr, "diagnostic: sphere program started.\n");
/*
Requests from the renderer to the program are passed on the standard
input. Each request is written on a single line. The detail level required
is written first, followed by the arguments passed by the user in the RIB.
The two are separated by a single space.
*/
while (fgets(buf, 256, stdin) != NULL)
{
RtFloat detail;
RtColor color = {1.0f, 1.0f, 1.0f};
sscanf(buf, "%g %g %g %g", &detail, &color[0], &color[1], &color[2]);
/*
Calling RiBegin with a file name as a parameter causes the commands
to be output as RIB to that file when using lib3delight. Using
"stdout" or "stderr" will output the RIB to the standard output or
error respectively.
It is important to call RiBegin()/RiEnd() inside the loop (for each
request) to ensure that the output is received properly by the
renderer.
*/
RiBegin("stdout");
RiColor(&color[0]);
RiSphere(1.0f, -1.0f, 1.0f, 360.0f, RI_NULL);
/*
Outputting a single 0xFF character (377 in octal) is the method to
signal the renderer that the program has finished processing this
request. This can also be done manually if you choose not to use the
library to output your RIB.
*/
RiArchiveRecord(RI_VERBATIM, "\377");
RiEnd();
}
fprintf(stderr, "diagnostic: sphere program is about to end.\n");
return 0;
}
This example can be compiled with the following commands:
- Linux
- g++ -o sphere -O3 -I
$DELIGHT
/include/ -L$DELIGHT
/lib/ sphere.cpp -l3delight
- Mac OS X
- g++ -o sphere -O3 -I
$DELIGHT
/include/ -L$DELIGHT
/lib/ sphere.cpp -l3delight
- IRIX
- CC -o sphere -O3 -n32 -TARG:isa=mips4 -TARG:processor=r10k -I
$DELIGHT
/include/ -L$DELIGHT
/lib/ sphere.cpp -l3delight
- Windows
- CL /Ox /I%DELIGHT%\include\ sphere.cpp %DELIGHT%\lib\3Delight.lib
This document was generated
by Aghiles Kheffache on July, 31 2003
using texi2html
3Delight 1.0.0. Copyright 2000-2003 The 3Delight Team.
All Rights Reserved.