cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

spectral
Adept II

Simulate function pointer

 

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 ?

 

 

0 Likes
2 Replies

Use a structure with a class ID field and then a switch statement on the class ID field and call a different function in each case.
0 Likes

Thanks for your reply,

 

It is a good idea, but how do I pass a 'dynamic' list of 'generic' values ?

By example, each sub class of 'fresnel' has its own set of parameters ?

Thanks

0 Likes