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

Author Topic: [SFML 2.0] Render onto a sf::RenderTexture messes with quality?  (Read 2402 times)

0 Members and 1 Guest are viewing this topic.

Moonkis

  • Jr. Member
  • **
  • Posts: 58
    • View Profile
Hello all!

I'm been programming the "Saaga Engine Project" which is a text-based adventure engine.
I'v hit up a early version of it yesterday which featured "word by word printing" and some fancy GUI surrounding the screen.

I'm planning to implement word-wrap and allows for rich text ( I'll probably come back later with this topic since I'v been busting my head figuring out how I should parse text with some "tags" that enables different styles of the text. Like This is a Yellow Text will be printed in yellow ).

I am by no means a programming pro I'm more of a n00b with the big 0's. I started making a TextHandler class but seeing as it had a lot of functions that my State's had I decided to make it a TextState that WorldState owns an instance of ( that can be passed onto the sub-screens like Inventory and World Map ).

After a LOT of debugging my code to get it to work ( preparing the code for rich text by having a vector list with all the sf::Text and sf::String objects ).

Enough with the jibberjabber WHAT is the problem son!?
Well when I'm drawing my text with a normal for-loop the text is clear and nice but when pre-rendering it onto a sf::RenderTexture it's thinner and a lot less crisp. Is this a normal behavior and how do i fix it?

EDIT: Minimal example further down the thread, sorry for inconvenience.
« Last Edit: May 17, 2012, 05:03:10 pm by Moonkis »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Laurent Gomila - SFML developer

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: [SFML 2.0] Render onto a sf::RenderTexture messes with quality?
« Reply #2 on: May 17, 2012, 03:53:11 pm »
You said that the problem is when you pre-render text to a render-texture. So just do that in a minimal and complete code ;)
Laurent Gomila - SFML developer

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: [SFML 2.0] Render onto a sf::RenderTexture messes with quality?
« Reply #3 on: May 17, 2012, 04:29:20 pm »
Sorry but your code is neither complete nor minimal, I can't help you. Please follow the link that I posted and read carefully what's in it.
Laurent Gomila - SFML developer

Moonkis

  • Jr. Member
  • **
  • Posts: 58
    • View Profile
Re: [SFML 2.0] Render onto a sf::RenderTexture messes with quality?
« Reply #4 on: May 17, 2012, 05:01:30 pm »
Sorry but your code is neither complete nor minimal, I can't help you. Please follow the link that I posted and read carefully what's in it.
I created a minimal reproduction of the problem:
#include <SFML/Graphics.hpp>

int main(void)
{
  sf::RenderWindow window(sf::VideoMode(800, 600), "TITLE AND STUFF");
  sf::Event evnt;

  sf::RenderTexture render_texture;
  render_texture.create(800,600);

  sf::Text text("The old brown fox was filled with joy.");
  text.setCharacterSize(12);

  sf::Sprite sprite;

  while(window.isOpen())
  {
    while(window.pollEvent(evnt)) { if(evnt.type == sf::Event::Closed) window.close(); }

    render_texture.clear(sf::Color::Transparent);
    render_texture.draw(text);
    render_texture.display(); // Apprently this is needed since it's flipped else
    sprite.setTexture(render_texture.getTexture());

    window.clear(sf::Color::Black);
    window.draw(sprite);
    window.display();
  }
}
 

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: [SFML 2.0] Render onto a sf::RenderTexture messes with quality?
« Reply #5 on: May 17, 2012, 05:25:33 pm »
Here is a beautiful minimal code, thanks :)

I'll test it as soon as I can.
Laurent Gomila - SFML developer

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: [SFML 2.0] Render onto a sf::RenderTexture messes with quality?
« Reply #6 on: May 17, 2012, 05:56:46 pm »
The result is incorrect, indeed. It seems like the alpha channel is smoothed, but it shouldn't.
Laurent Gomila - SFML developer