I'm trying to create a class using sf::Vertex that will give each vertex additional attributes and methods. Main contains a vector of objects making this quite similar to sf::VertexArray but when I go draw it, nothing appears. Any help why?
main.cpp
#include <iostream>
#include <vector>
#include "src/streamer.h"
int main(){
sf::RenderWindow window(sf::VideoMode(800, 600), "My Window");
std::vector<Streamer> streamers;
while(window.isOpen()){
sf::Event event;
while(window.pollEvent(event)){
if(event.type == sf::Event::Closed || sf::Keyboard::isKeyPressed(sf::Keyboard::Escape))
window.close();
}
if(sf::Mouse::isButtonPressed(sf::Mouse::Left)){
Streamer vertex(sf::Vector2f(sf::Mouse::getPosition().x, sf::Mouse::getPosition().y));
streamers.push_back(vertex);
}
std::cout << streamers.size() << std::endl;
window.clear();
window.draw(&streamers[0], streamers.size(), sf::Points);
window.display();
}
}
streamer.h
#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>
class Streamer: public sf::Drawable, public sf::Transformable, public sf::Vertex{
public:
Streamer();
Streamer(const sf::Vector2f);
~Streamer();
private:
virtual void draw(sf::RenderTarget &target, sf::RenderStates states) const;
sf::Vertex m_Vertex;
sf::PrimitiveType m_Type;
bool m_Status = 0;
};
streamer.cpp
#include "streamer.h"
Streamer::Streamer():
m_Status(1){
}
Streamer::Streamer(const sf::Vector2f location):
m_Status(1){
}
Streamer::~Streamer(){}
void Streamer::setPosition(sf::Vector2f){
}
void Streamer::draw(sf::RenderTarget& target, sf::RenderStates states) const{
target.draw(&m_Vertex, 1, sf::Points);
//target.draw(&m_Vertex, states);
}