@@ -39,6 +39,7 @@ static ustring u_s("s"), u_t("t");
3939static TypeDesc TypeFloatArray2 (TypeDesc::FLOAT, 2 );
4040static TypeDesc TypeFloatArray4 (TypeDesc::FLOAT, 4 );
4141static TypeDesc TypeIntArray2 (TypeDesc::INT, 2 );
42+ static TypeDesc TypeIntArray4 (TypeDesc::INT, 4 );
4243
4344
4445
@@ -48,6 +49,7 @@ SimpleRenderer::SimpleRenderer ()
4849 Matrix44 M; M.makeIdentity ();
4950 camera_params (M, u_perspective, 90 .0f ,
5051 0 .1f , 1000 .0f , 256 , 256 );
52+ shutter (0 .0f , 1 .0f /48 , 0 );
5153
5254 // Set up getters
5355 m_attr_getters[ustring (" osl:version" )] = &SimpleRenderer::get_osl_version;
@@ -62,6 +64,7 @@ SimpleRenderer::SimpleRenderer ()
6264 m_attr_getters[ustring (" camera:shutter" )] = &SimpleRenderer::get_camera_shutter;
6365 m_attr_getters[ustring (" camera:shutter_open" )] = &SimpleRenderer::get_camera_shutter_open;
6466 m_attr_getters[ustring (" camera:shutter_close" )] = &SimpleRenderer::get_camera_shutter_close;
67+ m_attr_getters[ustring (" camera:frame" )] = &SimpleRenderer::get_camera_frame;
6568}
6669
6770
@@ -86,7 +89,6 @@ SimpleRenderer::camera_params (const Matrix44 &world_to_camera,
8689 m_pixelaspect = 1 .0f ; // hard-coded
8790 m_hither = hither;
8891 m_yon = yon;
89- m_shutter[0 ] = 0 .0f ; m_shutter[1 ] = 1 .0f ; // hard-coded
9092 float frame_aspect = float (xres)/float (yres) * m_pixelaspect;
9193 m_screen_window[0 ] = -frame_aspect;
9294 m_screen_window[1 ] = -1 .0f ;
@@ -98,6 +100,16 @@ SimpleRenderer::camera_params (const Matrix44 &world_to_camera,
98100
99101
100102
103+ void
104+ SimpleRenderer::shutter (float open, float close, int framenumber)
105+ {
106+ m_shutter[0 ] = open;
107+ m_shutter[1 ] = close;
108+ m_frame = framenumber;
109+ }
110+
111+
112+
101113bool
102114SimpleRenderer::get_matrix (ShaderGlobals *sg, Matrix44 &result,
103115 TransformationPtr xform,
@@ -224,6 +236,25 @@ SimpleRenderer::get_array_attribute (ShaderGlobals *sg, bool derivatives, ustrin
224236 TypeDesc type, ustring name,
225237 int index, void *val)
226238{
239+ if (OIIO::Strutil::starts_with (name, " renderer:" )) {
240+ if (name == " renderer:name" && type == OIIO::TypeString) {
241+ *(ustring *)val = ustring (" OSL testrender" );
242+ return true ;
243+ }
244+ if (name == " renderer:version" && type == TypeIntArray4) {
245+ int *ival = (int *)val;
246+ ival[0 ] = OSL_VERSION_MAJOR;
247+ ival[1 ] = OSL_VERSION_MINOR;
248+ ival[2 ] = OSL_VERSION_PATCH;
249+ ival[3 ] = 0 ;
250+ return true ;
251+ }
252+ if (name == " renderer:versionstring" && type == OIIO::TypeString) {
253+ *(ustring *)val = ustring (OSL_LIBRARY_VERSION_STRING);
254+ return true ;
255+ }
256+ }
257+
227258 AttrGetterMap::const_iterator g = m_attr_getters.find (name);
228259 if (g != m_attr_getters.end ()) {
229260 AttrGetter getter = g->second ;
@@ -451,6 +482,18 @@ SimpleRenderer::get_camera_screen_window (ShaderGlobals *sg, bool derivs, ustrin
451482}
452483
453484
485+ bool
486+ SimpleRenderer::get_camera_frame (ShaderGlobals *sg, bool derivs, ustring object,
487+ TypeDesc type, ustring name, void *val)
488+ {
489+ if (type == TypeDesc::TypeInt) {
490+ ((int *)val)[0 ] = m_frame;
491+ return true ;
492+ }
493+ return false ;
494+ }
495+
496+
454497
455498
456499OSL_NAMESPACE_EXIT
0 commit comments