Hi guys, i need help with my project, the renderWindow is not showing anything.
if you need i can post the headers too.
main.cpp
#include <SFML/Graphics.hpp>
#include <iostream>
#include "Display.h"
#include "Obj.h"
using namespace std;
int main()
{
Display app;
Obj obj;
app.window.setFramerateLimit(60);
while (app.window.isOpen())
{
app.eventsCheck();
app.clear();
//Game
obj.logic();
obj.output();
obj.draw(app.window);
app.display();
}
return 0;
}
display.cpp
#include "Display.h"
Display::Display()
{
window.create(sf::VideoMode(800, 600), "Ai", sf::Style::Default);
}
void Display::display()
{
window.display();
}
void Display::clear()
{
window.clear(sf::Color::White);
}
void Display::eventsCheck()
{
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
}
}
obj.cpp
#include "Obj.h"
Obj::Obj()
{
pos.x = 100;
pos.y = 100;
cell.scale(sf::Vector2f(1, 1));
cell.setFillColor(sf::Color::Black);
cell.setPosition (pos);
if (!font.loadFromFile("arial.ttf"))
std::cout << "Errore durante il caricamento del font" << std::endl;
posOut.setCharacterSize(30);
posOut.setColor(sf::Color::Black);
posOut.setPosition(sf::Vector2f(2, 1));
}
void Obj::draw(sf::RenderWindow &window)
{
window.draw(cell);
window.draw(posOut);
}
void Obj::logic()
{
}
void Obj::output()
{
ss << "x." << pos.x << " y." << pos.y;
posOut.setString(ss.str());
}