1 Reply Latest reply on Feb 15, 2011 4:06 PM by unique_screenname_here

    How can I define a function that return a value

    chubakueno

      I've saw examples of void functions but how can I define a function that return a value(for example, a boolean value)

        • 1. Re: How can I define a function that return a value
          unique_screenname_here Level 3

          Here's a contrived example:

           

          <languageVersion: 1.0;>

           

          kernel KernelCallsAFunction

          <

              namespace: "aif::test";

                 vendor: "qa";

                version: 1;

          >

          {

              parameter float x;

              parameter float y;

           

              input  image4 src;

              output pixel4 dst;

           

              float

              xcoord(float2 coord)

              {

                  return coord.x;

              }

           

              bool

              x_less_than_y(float x, float y)

              {

                  bool retVal = false;

                  if (x < y) retVal = true;

           

                  return retVal;

              }

           

              void

              evaluatePixel()

              {

                  float2 coord = outCoord();

                  float  z = coord.y;

                  if (x_less_than_y(x, y))

                  {

                      z = xcoord(coord);

                  }

                  float4 tmp = sampleNearest(src, float2(z+z, coord.y));

                  dst = tmp;

              }

          }

           

          You can find more information in the Pixel Bender Language Reference and the Pixel Bender Developer's Guide.