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 - Stanislav

Pages: [1]
1
Graphics / Re: Multiple problems with text drawing
« on: April 12, 2013, 01:50:06 pm »
Since you set the text position to the center of the box, it should work only if the text origin is set to its center. And the default origin is the top-left corner. Yes, there are known issues about text centering, but without knowing exactly what you do (a complete/minimal example would help a lot for that) it's complicated to tell you what to do.

Well, that's how i'm setting the position:

text.setPosition(
    static_cast<int>(button_x + ((button_width - text_bounds.width) / 2)),                 
    static_cast<int>(button_y  + ((button_height - text_bounds.height) / 2)));
            
Without setOrigin() function:


...and now with setOrigin()(setting the origin to the center of the box):
text.setOrigin(button_x + button_width / 2, button_y + button_height / 2);
   


Quote
Yes. It's really strange, I was sure that it was fixed...
I didn't use the setView() function of the RenderWindow object before, now i'm using it and those lines/dots do not appear anymore.


2
Graphics / Re: Multiple problems with text drawing
« on: March 04, 2013, 02:16:54 pm »
1. Where is the origin of the text? At its center?
I don't use the setOrigin() function.

Some other guy had the same problem. The text is drawn little lower than it should be.
http://stackoverflow.com/questions/14505571/centering-text-on-the-screen-with-sfml



Quote from: Laurent
2. This should be fixed, do you use a recent revision of SFML 2?
Yeah, i'm using SFML 2. I downloaded it a month ago, is it recent enough?

3
Graphics / Multiple problems with text drawing
« on: March 04, 2013, 12:50:03 pm »
Look at these two rectangles.



1. Cannot align the text vertically. In the first rectangle the text is correctly aligned, but in the second is not. If i change the text in the second rectangle to "Rectangle" then the text will be correctly aligned. Why is there difference between "Rectangle" and "Button"?  Here's how i set the position of the text in the rectangle:

text.setPosition(
     static_cast<int>(rect_x + ((rect_width - text_container.width) / 2)),         
     static_cast<int>(rect_y  + ((rect_height - text_container.height) / 2)));

http://www.sfml-dev.org/old-forum/viewtopic.php?t=5790&sid=c277620601084e8aa0f406a415a6b795
This doesn't help me at all. It gives me the same result.

2. What's that dot/line above the "R" in "Rectangle" and how to remove it? If the font size is relatively big then this thing appears over the first character.

4
Graphics / Re: Drawing string with SFML 2.0
« on: January 28, 2013, 04:02:32 pm »
Don't forget to link to sfml-system.
Thanks. It works fine now.

5
Graphics / Drawing string with SFML 2.0
« on: January 28, 2013, 03:40:55 pm »
sfml::Font font;
font.loadFromFile("C:\\WINDOWS\\Fonts\\Arial.ttf");
sfml::Text text;
text.setFont(font);
text.setCharacterSize(30);
text.setStyle(sfml::Text::Bold);
text.setColor(sfml::Color::Blue);
text.setString("example");
window.draw(text);
 

I'm getting the following error:
C:\DOCUME~1\STANIS~1\LOCALS~1\Temp\ccFZolgr.o:main.cpp:(.text+0x476d): undefined
 reference to `__imp___ZN2sf6StringC1ERKSsRKSt6locale'
collect2.exe: error: ld returned 1 exit status


If i comment the setString() line it compiles without any errors. What's the problem?

Pages: [1]
anything