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

Author Topic: No smooth RenderTexture  (Read 2366 times)

0 Members and 2 Guests are viewing this topic.

GalakTozawr

  • Newbie
  • *
  • Posts: 17
  • You must create more game that oneself.
    • View Profile
    • My SFML lesson for russian language
    • Email
No smooth RenderTexture
« on: June 16, 2014, 09:14:00 pm »
sf::RenderTexture drawtext;
sf::Sprite s_drawtext;

s_drawtext.setScale(0.2,0.2);
...code..
while(1){

drawtext.setSmooth(true);
s_drawtext.setTexture(drawtext.getTexture());

}
No smooth!!!!

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: No smooth RenderTexture
« Reply #1 on: June 16, 2014, 10:16:57 pm »
You should:
- use a font that everyone knows and can test (Arial for example)
- provide a complete and minimal code that reproduces the problem
Laurent Gomila - SFML developer

GalakTozawr

  • Newbie
  • *
  • Posts: 17
  • You must create more game that oneself.
    • View Profile
    • My SFML lesson for russian language
    • Email
Re: No smooth RenderTexture
« Reply #2 on: June 16, 2014, 11:00:04 pm »
here and so you can see that the font is not smoothed. I create a function to draw text as standard features of the framework for drawing text slow. Just tell me how to smooth it.
#include <iostream>
#include <string>
using namespace std;
//текст
#include <SFML/Graphics.hpp>

sf::RenderTexture drawtext;
sf::Sprite s_drawtext;
sf::Texture t_hero;
sf::Texture t_smallfont;
void drawstring(string massive,int x, int y){

   int wight,//ширина спрайта в который рисуется текст
      height,//высота
      mass_size;//нужен для циклов обработки



//install texture
   mass_size = massive.size();//количество букв в массиве
   wight = 64*massive.size();//ширина текстуры
   height = 600;//высота
   drawtext.create(wight, height);//создаем текстуру в которую будем рендерить спрайты
   sf::Sprite textmass[200];//создать массив букв

   //присвоить текстурку шрифта всем 200 спрайтам
   for(int counter2 = 0; counter2 < mass_size; counter2 ++ )
   {
      textmass[counter2].setTexture(t_hero);
   }

   //присвоить каждой букве текстуру
   for (int counter = 0; counter < mass_size; counter ++ ){

         #include "key.h"//таблица букв
   }
   //что-то тут рисует в текстуру
   for (int counter = 0; counter < mass_size; counter ++ ){
      textmass[counter].setPosition(50*counter,0);

      drawtext.draw(textmass[counter]);
      }
   drawtext.setSmooth(true);
   drawtext.display();

}
int vrom = 150;
int main(){
   sf::RenderWindow window(sf::VideoMode(800, 600), "Kfni.ho.ua load image");

   t_hero.loadFromFile("C:/resources/font.png");
   t_smallfont.loadFromFile("C:/resources/small_font.png");

   sf::Sprite s_hero;
   s_hero.setTexture(t_smallfont);
   s_hero.setPosition(400,300);

   s_hero.setTextureRect(sf::IntRect(0, 0, 21, 21));

   drawstring("я люблю программить на си мне это нрав вообще и я всех лю",15,15);

   s_drawtext.setScale(0.2,0.2);
   while (window.isOpen())
   {
      sf::Event event;
      while (window.pollEvent(event))
      {
         if (event.type == sf::Event::Closed)
            window.close();
      }

      window.clear(sf::Color::White);
      window.draw(s_hero);

      s_drawtext.setTexture(drawtext.getTexture());
      
      window.draw(s_drawtext);
      window.display();
   }
   return 0;
}

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: No smooth RenderTexture
« Reply #3 on: June 17, 2014, 12:15:06 am »
Oh, you're using a custom bitmap font, not a truetype font.

Anyway, please read these rules carefully, especially the part about the complete and minimal example. Your say the render-texture doesn't smooth your sprites: write a simple test case where you draw a single rectangular sprite (or even shape) to a render-texture. No need to bother with your original bitmap font drawing code. Testing things in a reduced context is the key to solving problems.
« Last Edit: June 17, 2014, 12:16:54 am by Laurent »
Laurent Gomila - SFML developer