1
SFML projects / SFML how to transfer parametr to function(C++, Visual Studio)
« on: October 12, 2019, 12:15:44 pm »
I made code, Visual Studio don't see mistakes, but, program don't compilating;
#include <SFML/Graphics.hpp>
using namespace sf;
void MainMenu(RenderWindow &window) {
Image menu;
menu.loadFromFile("images/Main_menu.png");
Texture a;
a.loadFromImage(menu);
Sprite Mainmenu;
Mainmenu.setTexture(a);
Mainmenu.setPosition(100, 100);
window.draw(Mainmenu);
}
int main()
{
RenderWindow window(VideoMode(1200, 720), "SFML works!");
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == Event::Closed)
window.close();
}
window.clear();
window.display();
}
MainMenu(window);
return 0;
}
Program don't compilating because of this line:
window.draw(Mainmenu); // 13th line.
#include <SFML/Graphics.hpp>
using namespace sf;
void MainMenu(RenderWindow &window) {
Image menu;
menu.loadFromFile("images/Main_menu.png");
Texture a;
a.loadFromImage(menu);
Sprite Mainmenu;
Mainmenu.setTexture(a);
Mainmenu.setPosition(100, 100);
window.draw(Mainmenu);
}
int main()
{
RenderWindow window(VideoMode(1200, 720), "SFML works!");
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == Event::Closed)
window.close();
}
window.clear();
window.display();
}
MainMenu(window);
return 0;
}
Program don't compilating because of this line:
window.draw(Mainmenu); // 13th line.