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

Pages: 1 [2]
16
Graphics / Calling Text.setString before RenderTexture.create
« on: May 27, 2012, 03:01:46 pm »
I am having a problem with the RenderTexture.
If I call e.g. sf::Text::setString before calling sf::RenderTexture::create then I get a strange result.

In the example code below I am first setting the string to "abcde" before the create call and after the create call I set it to "test". Only the "e" will be drawn on the screen. After looking into this I found out that only the a, b, c, d or e letters would be drawn. So the letters that were not used before the create call are simply not drawn.
Calling window.draw(text) instead of drawing the render texture has the same result!

#include <SFML/Graphics.hpp>

int main()
{
    // Create a new render-window
    sf::RenderWindow window(sf::VideoMode(800, 600), "SFML window");
   
    // Create a new render-texture
    sf::RenderTexture texture;
   
    sf::Text text;
    text.setString("abcde");
   
    if (!texture.create(500, 500))
        return -1;
   
    text.setString("test");

    // The main loop
    while (window.isOpen())
    {
        sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                window.close();
        }
       
        // Clear the whole texture with red color
        texture.clear(sf::Color::Red);

        // Draw the text on the texture
        texture.draw(text);
       
        // We're done drawing to the texture
        texture.display();
       
        // Now we start rendering to the window, clear it first
        window.clear();
       
        // Draw the texture
        sf::Sprite sprite(texture.getTexture());
        window.draw(sprite);
       
        // End the current frame and display its contents on screen
        window.display();
    }
}

I am on a Mac OS X Lion with SFML2-RC.

EDIT:
I tested it in my VirtualBox and both windows and linux could display the word "test" correctly.
I did also notice however that the texture was drawn a few pixels lower on my windows xp. The red rectangle didn't start at top position 0.

17
Graphics / Big character size
« on: April 05, 2012, 01:09:48 pm »
Is there any reason why a big character size would't work?
I gave a text a size of 400 (accidentally) and the program stopped on the assert in Texture::update.

18
Window / TextEntered event not sent on backspace/delete on mac
« on: March 31, 2012, 07:57:15 pm »
When pressing the backspace or delete key I don't get TextEntered events on Mac OS X Lion.
I do get KeyPressed events, so it is not a big issue.

Example code:
while (App.isOpen())
{
    sf::Event event;
    while (App.pollEvent(event))
    {
        if (event.type == sf::Event::Closed)
            App.close();
           
        if (event.type == sf::Event::TextEntered)
        {
            if (event.text.unicode == 8) // 8 = backspace
            {
                // The program never passes here
            }
            else if (event.text.unicode == 127) // 127 = delete
            {
                // Neither does is pass here
            }
        }
       
        if (event.type == sf::Event::KeyPressed)
        {
            if (event.key.code == sf::Keyboard::Back)
            {
                // This works
            }
            else if (event.key.code == sf::Keyboard::Delete)
            {
                // This also works
            }
       }
    }
           
    App.clear();
    App.display();
}
 

Is this a problem with sfml or is it just mac os x that isn't sending those events?

19
Graphics / Text.setString("") crashes on mac
« on: March 31, 2012, 02:08:40 pm »
I noticed that calling Text.setString with an empty string gives my a SIGABRT.
However, when passing '\0' instead of "" it worked correctly.

The SIGABRT comes from "/usr/include/c++/4.2.1/ext/new_allocator.h" on line 97, which is the deallocate function.

I am working on Mac OS X Lion with Xcode 4.3.2.

20
SFML projects / TGUI: a c++ GUI for SFML (with Form Builder)
« on: February 12, 2012, 06:49:13 pm »
TGUI is an easy to use cross-platform GUI based on SFML and written in C++.

Currently (v0.4) the following objects can be used:
- Label
- Picture
- SpriteSheet
- Button
- Checkbox
- RadioButton
- EditBox
- Slider
- Scrollbar
- Listbox
- ComboBox
- LoadingBar
- TextBox
- Panel

Screenshots:
TGUI v0.3.4 (Black style)


TGUI v0.4.0 (Black style)


TGUI v0.4.0 (BabyBlue style)


Video of the TGUI Form Builder v0.2 that shows how easily you can make a login screen.




Features:
 * It is extremely easy to use: only a few lines of code and you have e.g. a fully working edit box.
 * You can handle object callbacks just like you handle events in SFML.
 * You can create unlimited objects, even while the program is running e.g. create object on click.
 * Objects can be loaded from a file, you can update e.g. the positions without compilation.
 * TGUI uses an internal texture manager so that no image is loaded twice.
 * All objects are derived from sf::Transformable, so you can use e.g. setPosition.
 * TGUI used the camelCase notation which is the same as SFML uses.
 * Just like SFML, it is licensed under the zlib/libpng license.
 * Cross-platform: Windows, Linux and Mac OS X.
 * TGUI provides an easy to use drag-and-drop form builder.

Tutorials can be found here.
I have also written a fully commented example code that you can find here.

TGUI can be downloaded from my download page or from GitHub.
You will have to build TGUI with cmake, but I have provided some Getting Started tutorials for that.

I hope that someone will find this project useful.
If you have any questions, if you you find bugs or if you have any remarks then just let me know.

21
Graphics / Is it possible to crop a text?
« on: January 07, 2012, 05:53:04 pm »
Is it possible to draw e.g. only the top part of a text in SFML2?

22
Graphics / Text.GetLocalBounds ignores spaces at the beginning and end?
« on: January 03, 2012, 04:55:59 pm »
When I fill a sf::Text with a string that starts or ends with spaces then the GetLocalBounds and GetGlobalBounds functions don't return the correct width.

Here is an example code:
Code: [Select]
sf::Text text("     test     ");
float Width = text.GetGlobalBounds().Width;

Width will be 49 (with the default font).
This is only the width of the "test", so the spaces are ignored.
The width should be something like 127 (this is what FindCharacterPosition returned).

23
Graphics / Calling SetScale inside Render function
« on: December 31, 2011, 04:46:35 pm »
Suppose I have a class derived from sf::Drawable.
Is there an easy way to change the scale inside the Render function?

This would be the code to create, scale and draw the object:
Code: [Select]
Object obj;
obj.Scale(2, 2);
window.Draw(obj);

And this is where the problem lies:
Code: [Select]
void Object::Render(sf::RenderTarget& target, sf::Renderer& renderer) const
{
    // I want to change the scale here!
    SetScale(4, 4);
}

I have found a way to do this by using a second class also derived from sf::Drawable and let that class take care of the drawing.
But I was wondering if there isn't an easier way to accomplish this.

I am using SFML2.

24
Graphics / How to center sf::Text (SFML2)
« on: September 05, 2011, 08:15:02 pm »
I am creating a button class for SFML2 and I am trying to center a text in my button (a texture).
The problem is that a text is not draw exactly at the correct coordinates (when drawing e.g. a text on position 0 then it will be drawn a little lower).

This is the code I am using:
Code: [Select]
sf::FloatRect rect = Text.GetRect();
rect.Left = (Texture.GetWidth() / 2.0f) - (rect.Width / 2.0f);
rect.Top = (Texture.GetHeight() / 2.0f) - (rect.Height / 2.0f);
Text.SetPosition(rect.Left, rect.Top);

Is there a way to get the top position of the text right?
At this moment the text is always too low.

25
Network / SocketUDP.Receive returns Error when sending delete
« on: August 13, 2011, 08:29:04 pm »
I was using the SocketUDP while I noticed something strange.
When I use
Code: [Select]
SocketUDP.Send("delete", 7, IP_ADDRESS, 5000);
SocketUDP.Receive(ReceiveBuffer, BUFFER_SIZE, BytesReceived, IP_Address, Port);
then the last line returns sf::Socket::Error.
The return value of the first line is always Done.

If I change "delete" into any other word then it returns Done, but when it starts with delete then it fails (even "delete_test" fails).

This happens with both blocking and non-blocking. (Of course in non-blocking there has to be a sleep between the lines.)
Is there some reason why you can't send "delete"?

PS: I am using SFML 1.6.

Pages: 1 [2]
anything