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

Author Topic: [Solved] sf::Text with sf::Rectangle Problem  (Read 5385 times)

0 Members and 1 Guest are viewing this topic.

AlexAUT

  • Sr. Member
  • ****
  • Posts: 396
    • View Profile
[Solved] sf::Text with sf::Rectangle Problem
« on: December 27, 2012, 11:41:30 am »
Hello,
first of all here a two Screenshots wich shows my Problem






OS: Win8 Pro 64bit
GPU : ATI HD 6850

The Problems appears when i draw a VertexArray, a Shape and a Text in the same frame. But i dont know if its a Problem in my Code, a Problem in SFML or a Problem with the Driver OS...

I hope some of you can test the app and can help me...

#include <iostream>
#include <SFML/Graphics.hpp>



int main()
{
    sf::RenderWindow win(sf::VideoMode(800,640,32), "Bug Test", 7);

    win.setFramerateLimit(120);

    sf::Font font;
    font.loadFromFile("arial.ttf");

    sf::Text text;
    text.setFont(font);
    text.setString("Hallo");
    text.setPosition(20,20);
    text.setCharacterSize(20);
    text.setColor(sf::Color::Black);


    sf::RectangleShape rect;
    rect.setPosition(20,20);
    rect.setFillColor(sf::Color::Green);
    rect.setSize(sf::Vector2f(100,100));

    sf::VertexArray arrayV;
    arrayV.setPrimitiveType(sf::Quads);
    arrayV.append(sf::Vertex(sf::Vector2f(10, 10), sf::Color::Yellow));
    arrayV.append(sf::Vertex(sf::Vector2f(100, 10), sf::Color::Yellow));
    arrayV.append(sf::Vertex(sf::Vector2f(100, 100), sf::Color::Yellow));
    arrayV.append(sf::Vertex(sf::Vector2f(10, 100), sf::Color::Yellow));

    while(win.isOpen())
    {
        sf::Event e;

        while(win.pollEvent(e))
        {
            if(e.type == sf::Event::Closed)
                win.close();

            if(e.type == sf::Event::KeyPressed)
            {
                if(e.key.code == sf::Keyboard::Escape)
                    win.close();
            }
        }

        win.clear(sf::Color::Blue);
        win.draw(arrayV);
        win.draw(rect);
        win.draw(text);

        win.display();
    }


    return 0;
}

 

« Last Edit: December 27, 2012, 12:24:03 pm by AlexAUT »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11033
    • View Profile
    • development blog
    • Email
« Last Edit: December 27, 2012, 11:58:29 am by eXpl0it3r »
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

AlexAUT

  • Sr. Member
  • ****
  • Posts: 396
    • View Profile
Re: sf::Text with sf::Rectangle Problem
« Reply #2 on: December 27, 2012, 12:23:35 pm »
Thank you!  8)