Hi Nexus, thank you for your reply.
I thought about 1bpp data and I've tried but FPS actually lower than with simple Image->getPixel(x,y). Maybe I'm doing something wrong?
std::map<std::string, std::vector<bool>> bitsets; //string contains texture name
after loading the image & texture I create the bitset for this texture:
bitsets[texturename] = calculateBitset(images[texturename]);
std::vector<bool> calculateBitset(sf::Image img){
sf::Vector2u imgSize = img.getSize();
std::vector<bool> retVal;
for(int i = 0; i < imgSize.x; i++){
for(int j = 0; j < imgSize.y; j++){
retVal.push_back(img.getPixel(i,j).a != 255); //false = transparent
}
}
return retVal;
}
then I check if given point is clickable:
bool isClickable(std::string textureName, sf::Vector2u pos){
int w = images[textureName].getSize().x;
return !bitsets[textureName][w*pos.y+pos.x];
}
With this code I'm experiencing 6-20 FPS drop (depending on map indexes)
If I load and store only sf::Images and call getPixel() every time, FPS drop is only 1-6 and equally lower cpu load.