Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - vanpet

Pages: [1]
1
Graphics / Drawing a std::vector<sf::Vector2f> like a VertexArray
« on: October 30, 2012, 07:24:32 pm »
I'm new to graphic programming in general, so my questions may seem stupid, please excuse me, but I swear I'm doing my best to read and understand most of the documentation (-> not easy for me)!

Until now, I've played with VertexArray to draw complex polygons, and it was fine. But now, I need to edit these shapes (for example, the user must be able to add a point between to other points), and I don't think I can use VertexArray to insert a point in the middle because it has only push_back method at the end of the array.

So, now I made my own class Polygon and I store the points in a vector<sf::Vector2f>

In my class Polygon, I inherited Drawable, and I want to make a virtual draw function to handle the drawing of my Polygon...

virtual void draw(sf::RenderTarget& target, sf::RenderStates states) const;

Unfortunately, I have no idea how to implement this function. I don't know how to go from my vector to a drawable object like a vertexArray.

Foolishly, I tried to use low level OpenGL instructions, but it was a big mess and I guess I feel more confortable staying in the SFML world for the moment.

Can someone please push me in the right direction? I suppose the answer is easy for you!

Thanks in advance!

Pages: [1]
anything