Reputation: 184
I'm relatively (~1 year) new to C++/oF creative coding. I'm still shaky on using pointers, but I have a basic understanding. I'm not sure if my use of pointers here is the cause of my issue.
At this point, I'm attempting to write a saturation function using this C code as the template: C Code — Function To Change Color Saturation
My saturate() function is a private function in a custom class "LoVid". In the code below I am just trying to run a simple test of the saturation function.
I get no build errors until the linker error.
Here is the relevant code:
LoVid.h:
class LoVid { ...
private:
void saturate(float *_r, float *_g, float *_b, float amt);
}
LoVid.cpp:
LoVid::LoVid(string _path){ ...
//saturation test:
unsigned char oR = 122;
unsigned char oG = 122;
unsigned char oB = 122;
float r = (float)oR;
float g = (float)oG;
float b = (float)oB;
cout << "pre r,g,b: " << r << ", " << g << ", " << b << endl;
saturate(&r, &g, &b, 2.0);
cout << "sat r,g,b: " << r << ", " << g << ", " << b << endl;
}
...
void saturate(float *_r, float *_g, float *_b, float amt){
//conversion constants
const float Pr = 0.299;
const float Pg = 0.587;
const float Pb = 0.114;
float p = sqrt((*_r)*(*_r)*Pr + (*_g)*(*_g)*Pg + (*_b)*(*_b)*Pb);
*_r = p + ((*_r)-p) * amt;
*_g = p + ((*_g)-p) * amt;
*_b = p + ((*_b)-p) * amt;
}
It seems simple enough, so I'm scratching my head as to why this error is happening. Is there something dumb I'm missing?
Thanks so much. Apologies if this question is repetitive, the error is cryptic enough that I couldn't find any related answers.
Upvotes: 0
Views: 46
Reputation: 56567
void saturate(float *_r, float *_g, float *_b, float amt)
should be
void LoVid::saturate(float *_r, float *_g, float *_b, float amt)
Otherwise you are just defining a global function saturate
and not the member one.
Upvotes: 1