1
$\begingroup$

I've read about string functions in OSL lang. specification but it didn't give a clear explanation how to use them correctly.

I'm interested in void warning() and void error() functions. Are there any examples how to use them during the working process?

Thanks for your reply!

$\endgroup$
2
$\begingroup$

The 'warning(...)' and 'error(...)' functions behave very similarly to the 'printf' function in that they output strings to the console output.

For example, in this answer the printf function is used to format output to the console using a command as follows :

printf("Point %f,%f,%f\n", P[0], P[1], P[2]);

This outputs the formatted string (with each %f replaced by one of the following arguments) to the console.

The warning(...) and error(...) functions work similarly except each call outputs a line formatted with the work 'WARNING' or 'ERROR' and details of where the function was called from (the shader function) similar to the following :

WARNING: Shader warning [my_shader]: Point -0.320504 -0.812141 0.157532

With the syntax being identical to 'printf' :

warning("Point %f,%f,%f\n", P[0], P[1], P[2]);
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.