создал 2 класса:
1) Window.hpp
#ifndef WINDOW_HPP
#define WINDOW_HPP
#include <SFML/Graphics.hpp>
#include "Widgets/Button.hpp"
#include <iostream>
using namespace std;
class Window{
public:
Window(){
window.create(sf::VideoMode(width, height), "Window", sf::Style::Close);
window.setPosition(sf::Vector2i(desktop_width/2-width/2, desktop_height/2-height/2));
Button_void();
while(window.isOpen()){
while(window.pollEvent(event)){
if(event.type==sf::Event::Closed)
window.close();
if(sf::Keyboard::isKeyPressed(sf::Keyboard::Escape))
window.close();
}
window.clear();
window.display();
}
}
void Button_void(){
button.setSize(200, 200);
button.setBackgroundColor(255, 231, 0);
button.setPosition(0, 0);
}
private:
sf::Button button;
const int width=800;
const int height=800;
const int desktop_width=sf::VideoMode::getDesktopMode().width;
const int desktop_height=sf::VideoMode::getDesktopMode().height;
sf::RenderWindow window;
sf::Event event;
};
#endif // WINDOW_HPP
2) Button.hpp
#ifndef BUTTON_HPP
#define BUTTON_HPP
#include <SFML/Graphics.hpp>
#include <iostream>
using namespace std;
namespace sf{
class Button : public sf::RectangleShape{
public:
void setSize(float width, float height){
Button::setSize(width, height);
}
void setPosition(float x, float y){
Button::setPosition(x, y);
}
void setBackgroundColor(int r, int g, int b){
Button::setFillColor(sf::Color(r, g, b));
}
};
}
#endif // BUTTON_HPP
Код компиляции:
COMPILER = g++
FILENAME = Program.cpp
OUTPUT = Program
PARAMS = -lsfml-graphics -lsfml-system -lsfml-window
output:
${COMPILER} ${FILENAME} -o ${OUTPUT} ${PARAMS}
Ощибка: Segmentation Fault
Помогите пж :)