2 Replies Latest reply on Oct 11, 2010 12:58 PM by spectral

    Simulate function pointer

    spectral

       

      Hi,

       

      I have some complex code in C++, something like this :

       

      class Fresnel

      {

      float Compute(float* kr, float* kt);

      }

       

      class FresnelConductor::Fresnel

      {

      FresnelConductor(float e, float k) { }

      float Compute(float* kr, float* kt)

      {

      //.... some computations

      *kr = e * 2;
      *kt = 1 - kr;
      return e * 1.31 + k * 3.12; 

      }

      }

       

      class FresnelDielectric::Fresnel

      {

      FresnelDielectric(float r, float g, float b) { ...}

      float Compute(float* kr, float* kt)

      {

      //.... some computations

      Use r,g,b values here

      }

      }

       

      class Transmission

      {

      Fresnel * fresnel;

      MyComputation()

      {

      float kr, kt;

      fresnel->Compute(&kr, &kt);

      }

      }

       

      I'm searching an elegant way to do something like this in OpenCL.

      Do you have some ideas ?