Hello Everyone,
I am having issues with extracting a pixel from a GLubyte array.
Here is what I have
GLubyte* pixels = SOIL_load_image( file_path.c_str() , &width, &height, &channels, SOIL_LOAD_AUTO ); // load the pixel array
//later in the code
//RGB is holds GLint r, g, b
RGB Texture::getPixel( const int x, const int y ) const{
if( x < 0 || x > width -1 || y < 0 || y > height -1 )
return RGB();
int w = channels * width;
int idx = y * w + x;
GLubyte r = pixels[ idx + 0 ];
GLubyte g = pixels[ idx + 1 ];
GLubyte b = pixels[ idx + 2 ];
return RGB( (GLint) r , (GLint) g , (GLint) b ); I think I am tying into the array correctly. I do get integer values for my RGB struct, but they are all wrong. I get colors that don't even appear on the texture.
If anyone knows what I am doing wrong, please let me know.
Thanks so much,
Mike