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

Author Topic: [SVN] Shapes  (Read 6514 times)

0 Members and 1 Guest are viewing this topic.

dabo

  • Sr. Member
  • ****
  • Posts: 260
    • View Profile
    • http://www.dabostudios.net
[SVN] Shapes
« 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?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
[SVN] Shapes
« Reply #1 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.
Laurent Gomila - SFML developer

dabo

  • Sr. Member
  • ****
  • Posts: 260
    • View Profile
    • http://www.dabostudios.net
[SVN] Shapes
« Reply #2 on: March 07, 2008, 01:52:25 am »
Thanks, everything works perfectly now  :)

dabo

  • Sr. Member
  • ****
  • Posts: 260
    • View Profile
    • http://www.dabostudios.net
[SVN] Shapes
« Reply #3 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.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
[SVN] Shapes
« Reply #4 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.
Laurent Gomila - SFML developer

dabo

  • Sr. Member
  • ****
  • Posts: 260
    • View Profile
    • http://www.dabostudios.net
[SVN] Shapes
« Reply #5 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?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
[SVN] Shapes
« Reply #6 on: March 08, 2008, 12:29:03 pm »
Probably. What graphics card do you have ?
Laurent Gomila - SFML developer

dabo

  • Sr. Member
  • ****
  • Posts: 260
    • View Profile
    • http://www.dabostudios.net
[SVN] Shapes
« Reply #7 on: March 08, 2008, 12:47:22 pm »
Intel 945GM

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
[SVN] Shapes
« Reply #8 on: March 08, 2008, 02:31:00 pm »
Ok I see. So don't worry about not having support for antialiasing ;)
Laurent Gomila - SFML developer

dabo

  • Sr. Member
  • ****
  • Posts: 260
    • View Profile
    • http://www.dabostudios.net
[SVN] Shapes
« Reply #9 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. :)