In the GeneratePNoise() function, you are returning the data() from a vector that is going to be destroyed upon the returning of that function, and thus the data won't be available anymore.
Instead of a vector, I would recommend creating a unique_ptr and returning that unique_ptr from the function, such as:
unique_ptr<sf::Uint8[]> GeneratePNoise(int w, int h)
{
unique_ptr<sf::Uint8[]> data(new sf::Uint8[w * h * 4]);
for (int i = 0; i < w * h * 4; i++) {
data[i] = 128;
if (i + 1 % 4)
data[i] = 255;
}
return data;
}
In that case you don't even need to delete the resource that was returned. You should do the same with the CreateTexture() function.