SFML community forums

Help => General => Topic started by: dabo on March 07, 2008, 12:10:44 am

Title: [SVN] Shapes
Post by: dabo on March 07, 2008, 12:10:44 am
Hi, I just downloaded the latest source and in order to get the shapes to link I had to add "Shape.cpp" and "Shape.hpp" to the sfml-graphics project in the SFML.sln solution for VS2008. Did you forget to add them?

Anyway now when I finally managed to build my project, I got a "Debug Assertion Failed" error when I tried to run my project. It said:

"Vector subscript out of range"

This is the code I'm using:

Code: [Select]
//Create a shape
sf::Shape sLine;
sLine.Line(sf::Vector2f(300.f,300.f), sf::Vector2f(320.f,340.f), 2.f, sf::Color(0, 0, 0));

//Draw the shape
App.Draw(sLine);


If I remove the Shape drawing code, I don't get the error. This is the first time I try to use shapes, is my code wrong? Any ideas?
Title: [SVN] Shapes
Post by: Laurent on March 07, 2008, 01:27:48 am
Quote
Did you forget to add them?

That's true :D

Quote
This is the first time I try to use shapes, is my code wrong? Any ideas?

Yes. Line, Circle and Rectangle are static functions which return a sf::Shape ; they won't do anything if called like a member function.
Code: [Select]
sLine = sf::Shape::Line(sf::Vector2f(300.f,300.f), sf::Vector2f(320.f,340.f), 2.f, sf::Color(0, 0, 0));

However, if drawing an empty shape causes a crash, then there's a bug in my code ;)

Thanks for your feedback.
Title: [SVN] Shapes
Post by: dabo on March 07, 2008, 01:52:25 am
Thanks, everything works perfectly now  :)
Title: [SVN] Shapes
Post by: dabo on March 07, 2008, 08:27:50 pm
I've now been playing around with shapes for a while and I must say that it's a great addition, it will definitively come in handy.

One question though, is it possible to draw them anti-aliased? for example like SetSmooth(true) does for images. The edges are pretty sharp right now.
Title: [SVN] Shapes
Post by: Laurent on March 08, 2008, 04:31:02 am
As shapes are drawn using triangles, the only way to antialias them is to activate anti-aliasing when you create the window.
Title: [SVN] Shapes
Post by: dabo on March 08, 2008, 12:13:48 pm
When it says:

"Failed to find a pixel format supporting antialiasing ; antialiasing will be disabled"

...is this because of my crappy on-board graphics card?
Title: [SVN] Shapes
Post by: Laurent on March 08, 2008, 12:29:03 pm
Probably. What graphics card do you have ?
Title: [SVN] Shapes
Post by: dabo on March 08, 2008, 12:47:22 pm
Intel 945GM
Title: [SVN] Shapes
Post by: Laurent on March 08, 2008, 02:31:00 pm
Ok I see. So don't worry about not having support for antialiasing ;)
Title: [SVN] Shapes
Post by: dabo on March 08, 2008, 06:40:45 pm
Quote from: "Laurent"
Ok I see. So don't worry about not having support for antialiasing ;)
I have another computer with a "real" graphics card too, it's just that I prefer to use my laptop. :)