Linking renderman with c api?


#1

Does any1 know how to link renderman with dv++ or any other c/c++ compliers?
Or in a nutshell… how in the world do I connect the c api to renderman? So that when I make a c file it will compile it out to rib…
heres a test code… Please any help will be appreicated…

/* color.c - Create Particles of different colors*/

#include <ri.h>
#include <math.h>

#define COUNT 2000
#ifdef WIN32
#define random rand
#endif

float jitter(float scale)
{
float val=random()%1000;
return (val/500-1)*scale;
}

int main(int argc, char *argv[])
{
RtPoint position[COUNT];
RtColor color[COUNT];
float constantwidth=0.5;
float fov=30;
int i;

/Generate Particle Postions/
for(i=0;i<COUNT;i++)
{
position[i][0]=sin(i*0.5)50+jitter(2);
position[i][1]=cos(i
0.1)50+jitter(2);
position[i][2]=cos(i
0.5)*100+jitter(2);
color[i][0]=jitter(0.5)+0.5;
color[i][1]=jitter(0.5)+0.5;
color[i][2]=jitter(0.5)+0.5;
}

RiBegin(RI_NULL);
RiDisplay (“color.tiff”,“file”,“rgb”,RI_NULL);
RiProjection (“perspective”,
“fov”,&fov,
RI_NULL);
RiWorldBegin();
RiTranslate(0,0,300);
RiPoints(COUNT,“P”,position,
“constantwidth”, &constantwidth,
“Cs”,color,
RI_NULL);
RiWorldEnd();
RiEnd();
return 0;
}


#2

In general, here’s what you need:

Make sure that the ri.h file is on the include path. In my Aqsis installation it’s in /usr/local/lib/aqsis, so I have to use #include <aqsis/ri.h>. Alternatively, I could have added /usr/local/lib/aqsis to my include path and used #include <ri.h>.

In the linker, you will need to make sure that you include the path to the linked library (the LD_LIBRARY_PATH variable in UNIX), and also tell the linker which library to link.

In my case, (again using Aqsis), that’s ri2rib.so, so the command line looks a bit like this:
g++ prim.c -lri2rib -o prim

I hope that gets you started. If you’re using an IDE, you just have to set the appropriate project options, and let it figure out what the command line should look like.


#3

you also need a compiler that has a compatible symbol table with the librib.<so, dll> library.


#4

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.