fork(1) download
  1. #include <SFML/Graphics.hpp>
  2. #include <string>
  3. #include <iostream>
  4. #include <vector>
  5.  
  6. using namespace sf; using namespace std;
  7.  
  8. class Obj {
  9. public:
  10. string path;
  11. Sprite sprite;
  12. Texture texture;
  13. Obj(string Path) : path(Path)
  14. {
  15. if (!texture.loadFromFile(Path))
  16. {
  17. cout << "load texture fail" << endl;
  18. }
  19. sprite.setTexture(texture);
  20. }
  21. };
  22.  
  23. vector<Obj> obj;
  24.  
  25. int countObjects = 0;
  26.  
  27. void createObject(string Path){
  28. countObjects++;
  29. obj.emplace_back(Path);
  30. }
  31.  
  32.  
  33. int main() {
  34. RenderWindow window(VideoMode(800, 600), L"name", Style::Default);
  35. createObject("res/obj1.png");
  36. createObject("res/obj2.png");
  37.  
  38.  
  39. Event event;
  40. while (window.isOpen()){
  41. while (window.pollEvent(event)) {
  42. if (event.type == Event::Closed ||
  43. (event.type == sf::Event::KeyPressed && event.key.code == Keyboard::Escape))
  44. window.close();
  45. }
  46.  
  47.  
  48. window.clear();
  49. window.draw(obj[0].sprite);
  50. window.display();
  51. }
  52. return 0;
  53. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:1:29: fatal error: SFML/Graphics.hpp: No such file or directory
compilation terminated.
stdout
Standard output is empty