I am trying to add a rectangle shape over the screen and for some reason lines that are under it(the rectangle is transparent) don't show up. size() show that the vector is getting bigger so lines are being put inside, but they don't show up.
Edit - opaqueness is supposed to be 0, not 255.
#include <SFML/Graphics.hpp>
#include <vector>
#include <iostream>
int main()
{
// create the window
sf::VideoMode mode = sf::VideoMode::getDesktopMode();
sf::RenderWindow window(sf::VideoMode(mode.width / 2, mode.height), "My window");
std::vector <sf::Vertex> lines;
std::vector <std::vector<sf::Vertex>> archivedLines;
sf::RectangleShape screen;
screen.setSize(sf::Vector2f(1600, 900));
screen.setPosition(sf::Vector2f(160, 90));
screen.setFillColor(sf::Color(255, 255, 255, 255));
screen.setOutlineThickness(160);
screen.setOutlineColor(sf::Color(102, 102, 102));
sf::Event event;
int mousedown = 0;
// run the program as long as the window is open
window.setFramerateLimit(1000);
sf::Vector2i smth = sf::Mouse::getPosition(window);
sf::Vector2f mousePosition = window.mapPixelToCoords(smth);
while (window.isOpen())
{
// check all the window's events that were triggered since the last iteration of the loop
smth = sf::Mouse::getPosition(window);
mousePosition = window.mapPixelToCoords(smth, window.getView());
while (window.pollEvent(event))
{
// "close requested" event: we close the window
if (event.type == sf::Event::Closed)
window.close();
if (event.type == sf::Event::MouseButtonPressed)
{
mousedown = 1;
}
if (event.type == sf::Event::MouseButtonReleased)
{
mousedown = 0;
archivedLines.push_back(lines);
lines.clear();
}
if ((event.type == sf::Event::MouseMoved) && (mousedown == 1))
{
sf::Vertex line;
line.color = sf::Color::Black;
line.position = sf::Vector2f(mousePosition);
lines.push_back(line);
}
}
std::cout<<archivedLines.size()<<std::endl;
window.clear(sf::Color::White);
if(archivedLines.size() > 0)
{
for(int i = 0; i < archivedLines.size(); ++i)
{
window.draw(&archivedLines[i][0], archivedLines[i].size(), sf::LineStrip);
}
}
window.draw(&lines[0], lines.size(), sf::LineStrip);
window.draw(screen);
window.display();
}
return 0;
}