Hi, I'm new to the forum, so I'm sorry if I am misusing this question area, or if I'm just dumb when it comes to searching on the site.
I am new to SFML and C++ in general, and am trying to make the background of an image transparent in the window. I keep trying to find information about how the createMaskFromColor works, I keep getting errors, and when I search online I can't find information about what I'm doing wrong.
My code is:
sf::Texture test1;
test1.loadFromFile("Right1.png");
test1.createMaskFromColor(sf::Color::White);
I mainly keep getting "class "sf::Texture" has no member "createMaskFromColor" ". Alot of information I find online about it is for an older version of sfml when the command was CreateMaskFromColor, and I can't figure out what I'm missing. I thought it might have been that I needed to include image.hpp in my header like I have for other commands, but that still won't let it work. I've really hit a dead end here after searching online for hours trying to find a solution, and would really appreciate any help. My image is a png that has a transparent background already.
Alternatively if you have a better solution for how to make textures transparent let me know, the createMaskFromColor is what I see people recommending online them most.
Oh it also says error C2039: createMaskFromColor': is not a member of 'sf::Texture when I try to run it.
Before I post this I tried to make an entirely separate program to run just this one command to see if it was something wrong with my setup, and I get the same error. This is the code from the program I'm trying to run:
#include <SFML/Graphics.hpp>
int main()
{
sf::RenderWindow window(sf::VideoMode(1920, 1080), "Taking Flight", sf::Style::Default);
sf::RectangleShape airplane(sf::Vector2f(50.f, 50.f));
sf::Texture test1;
test1.loadFromFile("test1.png");
test1.createMaskFromColor(sf::Color::Black);
window.clear();
airplane.setPosition(910, 750);
airplane.setTexture(&test1);
while (1 == 1)
{
window.clear();
window.draw(airplane);
window.display();
}
return 0;
}
Again any help with this would be awesome, I've given myself a headache trying to figure it out