I have a problem with trying to make procedural textures in SFML
i have this code
sf::Texture* CreateTexture(int w, int h){
sf::Image tempImage;
sf::Texture* Tex = new sf::Texture();
Tex->create(w,h);
sf::Uint8 *pixelData = GeneratePNoise(w,h);
tempImage.create(w, h, pixelData);
Tex->update(tempImage);
//Tex->loadFromImage(tempImage);
return Tex;
}
sf::Uint8* GeneratePNoise(int w,int h){
std::vector<sf::Uint8> data(w*h*4);
for (int i=0;i<w*h*4;i++){
data[i]=128;
if (i+1%4)data[i]=255;
}
return data.data();
}
sf::Texture CreateTexturens(int w, int h){
sf::Image tempImage;
sf::Texture Tex;
Tex.create(w,h);
sf::Uint8 *pixelData = GeneratePNoise(w,h);
tempImage.create(w, h, pixelData);
Tex.update(tempImage);
return Tex;
}
I also have this code which uses the above code
void Star::createStar(){
sf::CircleShape star(r,30);
star.setPosition(x,y);
sf::Texture* t = CreateTexture(256,256);
star.setTexture(t,false);
std::cout << "Done!"<<std::endl;
}
This doesn't seem to render anything, I believe it is about the code revolving around creating and applying the texture, all help is appreciated!