View Full Version : Writing C++ mental ray shader

09-05-2008, 03:41 PM
What do I have to do to get shader compiled as C++ to work?

Here is a test shader, compiling it with VS2005 as C it works, if I switch to C++ it doesn't.

#include "shader.h"
DLLEXPORT int color_test_texture_version(void) {
DLLEXPORT miBoolean color_test_texture (miColor *result, miState *state, void *params) {
result->r = 1.0;
result->g = 0.5;
result->b = 0.25;
result->a = 1.0;
return miTRUE;

Is there some specific setting I have to turn on or what?

09-06-2008, 08:50 AM
Hi Jerry,

have you taken a look at the PDF "Compiling mentaly ray shaders" available here:

It covers how ro set up VS to compile the shaders.
If you've already done all of that and it still doesn't work, let me know and I can mail you a simple C++ project that you can pull apart.


09-06-2008, 09:38 AM
Yeah I hadn't taken a look at it. The thing I was missing was 'extern "C"' from the begining of dllexports, now it works. Thanks Dave!

- Jerry

CGTalk Moderation
09-06-2008, 09:38 AM
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.