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.


Messages - TheBoff

Pages: [1]
1
Graphics / Possible sf::String.GetRect() Bug
« on: June 05, 2010, 09:58:54 pm »
For the record I use this function to do the job. If it becomes a bottleneck, I will only check characters at the start and ends of lines, rather than looping through all of them, but it's not going to be called very often at all, so...

Also, there are a couple of hacks for the width detection, which I couldn't get quite right.

Code: [Select]

sf::FloatRect get_string_area(const sf::String& str) {
const sf::Font& font = str.GetFont();
const std::string& text = str.GetText();
float right, bottom;
sf::FloatRect r; //Start with relative positions to begin with
for (uint char_i = 0; char_i < text.length(); ++char_i) {
const sf::Vector2f& pos = str.GetCharacterPos(char_i);
const sf::IntRect& glyph_rect = font.GetGlyph(text[char_i]).Rectangle;
const sf::Vector2f size(glyph_rect.GetWidth(), glyph_rect.GetHeight());
right = pos.x + size.x; bottom = pos.y + size.y;
if (pos.y < r.Top) { r.Top = pos.y; }
if (pos.x < r.Left) { r.Left = pos.x; }
if (right > r.Right) { r.Right = right; }
if (bottom > r.Bottom) { r.Bottom = bottom; }
}
const sf::FloatRect& str_r = str.GetRect();
sf::Vector2f pos = str.GetPosition();
pos.y += str_r.GetHeight() - r.GetHeight(); //Deals with the offset
pos.x += (str_r.GetWidth() - r.GetWidth()) / 2;
r.Left += pos.x + 2; r.Right += pos.x; //The plus 2 is a hack.
r.Top += pos.y; r.Bottom += pos.y;
return r;
}

2
Graphics / Variables in App.Draw
« on: June 05, 2010, 09:07:59 pm »
If I am reading this correctly, then yes it is perfectly possible to say (for example)

Code: [Select]

sf::Color red(255, 0, 0);
sf::Shape circle = sf::Shape::Circle(0, 0, 20, red);

3
General discussions / Switching to CMake
« on: June 04, 2010, 09:32:41 pm »
If it will make it easier to compiler in VC++ 2010, by all means go for it :D

I can't imagine that it's that much effort to install + use cmake: it even seems to have a gui on windows!

4
Graphics / Possible sf::String.GetRect() Bug
« on: June 04, 2010, 08:43:51 pm »
Hello All!

I've been writing a bit of a GUI library, and for it I need to know the bounds of an sf::String. I'm using the GetRect() method for this, but the rect it produces is somewhat taller than the actual text:



The red rect is rendered using the rect returned from get rect. It is not anything to do with letters with tails, as the problem still occurs there. Using a smaller font size reduces the gap.

Is this deliberate behaviour, and if not, what can I do?[/img]

5
General / Non static .lib files not generated in VC++2010
« on: June 04, 2010, 08:05:02 pm »
I am: this bug also occurs (using exactly the same settings - linked to the -d files) when using release mode.

[strike]And also when linking against the static libs.[/strike] It does work with the static libs: somewhat unsurprisingly it is helpful to remove the SFML_DYNAMIC macro...

6
General / Non static .lib files not generated in VC++2010
« on: June 04, 2010, 06:58:50 pm »
Ugh: I've managed to get the lib files (the solution was to change the output directory, as has already been suggested) but when I build my app against them I get a memory access violation creating my render window.

Sorry about this, and thanks for all the help Laurent!

7
General / Non static .lib files not generated in VC++2010
« on: June 03, 2010, 06:41:17 pm »
I have used every configuration.

I can make it generate the dlls (sfml-graphics-d.dll for example), or the static libraries (sfml-graphics-d-s.lib), but not the lib for the dll (sfml-graphics-d.lib)

Thanks for SFML, and all the support!

8
General / Non static .lib files not generated in VC++2010
« on: June 03, 2010, 06:22:48 pm »
Hello all: basically, I'm trying to compile SFML 1.6 with VC++ 2010, and everything works fine, but it's doesn't appear to be generating .lib files without the -s suffix, other than for sfml-main.

I expect this is a stupid newbie error, but could really do with some help!

9
Graphics / Drawing a Sprite or other Image onto an Image
« on: May 03, 2010, 10:38:35 pm »
Awesome, thanks guys.

How stable is SFML2 seems to the logical next question: when will it be released?

10
Graphics / Drawing a Sprite or other Image onto an Image
« on: May 03, 2010, 09:15:07 pm »
Is it possibly, basically!

I'm doing a simple gui, and an image button will have three parts: a border, a background and an image.

Is it possible to "pre render" one on top of the other, to stop me having to draw all three parts every time, or is there simply no point?

Thanks!

Pages: [1]
anything