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

Pages: [1] 2
1
Graphics / BUG - Bad Text Display
« on: January 19, 2012, 12:59:30 pm »
ok, thanks for your answer ;)

Anyway to fix it temporarily ?

2
Graphics / BUG - Bad Text Display
« on: January 19, 2012, 12:22:46 am »
sorry for the forget...

I use SFML 2.0 ... of course ;)

3
Graphics / BUG - Bad Text Display
« on: January 18, 2012, 09:12:29 pm »
Hi,

I have some trouble with displaying text with the SFML.



As you can see with the screenshot, the text isn't display properly. (But, sometimes, the same text is display properly ...)

I made some test with Mac OS X and Windows...

Any ideas why i have this trouble ?

Thanks for your help ;)

4
Graphics / Mac os X Lion - RenderTexture show random pixels
« on: January 17, 2012, 09:03:38 pm »
It's also working with ATI GPU :)

Thanks a lot for your help and hope that our troubles will help you to make your Librarie even better ;)

5
Graphics / Mac os X Lion - RenderTexture show random pixels
« on: January 17, 2012, 12:08:04 pm »
Quote from: "Hiura"
Quote from: "Laurent"
I'll see if I can flush contexts internally, when switching contexts, and if it doesn't impact performances too much.
If the performances are too reduced maybe we can do it only on Mac, or, to be more precise : only on Mac until this issue appears on other OSes.

BTW, I tried on Nvidia GPU. It might work on ATI GPU (maybe) but I can't test that.


someone in my group project has a mac with an ATI graphic card. I let you informed if it works.

Quote
But I don't know why it happens only on OS X... I guess that other drivers are more clever


yes, and the problem on mac is that you cannot choose your drivers ... so maybe in a future drivers update by apple, this issue will be solved

6
Graphics / Mac os X Lion - RenderTexture show random pixels
« on: January 17, 2012, 01:46:47 am »
I forgot an important thing. It doesn't work with integrated graphic card

you have to use the other one (geforce GT 330m for me)

on mac by default, the system switches automatically between the 2 graphic cards

I used this software to select manually which one I want to use :

gfxCardStatus

7
Graphics / Mac os X Lion - RenderTexture show random pixels
« on: January 17, 2012, 01:17:46 am »
Quote from: "Hiura"
Adding "window.Display();" before "rt.Clear();" makes it works. Still no idea why. Will spend some time on this issue ASAP (but exams first!).


Quote
Can you try to add calls to glFlush() after or before drawing to the render-texture?


first, both solution did not work in my program.
but then, I found a solution (for the moment, the bug did not appear again)

In my program (not in this sample code), I used "sf::RenderTexture*" instead of "sf::RenderTexture"

I changed it to "sf::RenderTexture"

Then, once render texture has been displayed, I create a new sf::texture(rt. GetTexture)

then I create a new sprite using the texture and with both solution, it works like a charm

but if I use a pointer for RenderTexture, it does not work and some artifacts appear

I guess that window.Display() calls glFlush() ?

I put the glFlush() before calling rt.Create()



so Hiura, your sample code should work with glflush if you create a new texture from rt, then create the sprite



by the way thanks a lot to both of you, I will post a message tomorrow after lots of test in order to tell you if problem is resolved or not


Bonne nuit et merci ;)



[/quote]

8
Graphics / Mac os X Lion - RenderTexture show random pixels
« on: January 16, 2012, 11:24:08 am »
Quote from: "Haikarainen"
I noticed you clear your rendertexture using sf::Color::Transparent. Try clearing it with a solid color or without arguments


unfortunately, this is worse. I get no transparency, and I have more artifacts.

Quote
Since it's a Mac OS X only bug, I cannot help. We'd need someone with a Mac and OpenGL/debugging skills.


thx by the way

9
Graphics / Mac os X Lion - RenderTexture show random pixels
« on: January 16, 2012, 11:05:11 am »
hello,

tested again on another windows computer and it works

any idea ?

10
Graphics / Mac os X Lion - RenderTexture show random pixels
« on: January 15, 2012, 11:33:50 pm »
thanks for your time.

the problem is, I load all my images before the main loop, so I cannot draw the RT twice  :?

is there a temporary solution ?

11
Graphics / Mac os X Lion - RenderTexture show random pixels
« on: January 15, 2012, 10:29:12 pm »
Quote from: "Laurent"
Quote
by the way, I tried on 2 macbook pro with different graphic cards

And it works? Or not?
Have you tried on PCs (Linux or Windows)?


no it doesnt work on mac computers

it works on windows (pc) computer and also on ubuntu virtual machine under mac os

12
Graphics / Mac os X Lion - RenderTexture show random pixels
« on: January 15, 2012, 09:12:52 pm »
I also tried different file format, it doesn't work

any idea ?

thanks

13
Graphics / Mac os X Lion - RenderTexture show random pixels
« on: January 15, 2012, 07:11:31 pm »
ok

I tried this, but its still not working :(

Code: [Select]
 while (Window_->IsOpen())
    {
      sf::Event event;
      while (Window_->PollEvent(event))
{
 if (event.Type == sf::Event::KeyPressed && event.Key.Code == sf::Keyboard::Escape)
   {
     Window_->Close();
     break;
   }
}
 Window_->Clear();
 Window_->Draw(*sprite);
 Window_->Display();
    }

14
Graphics / Mac os X Lion - RenderTexture show random pixels
« on: January 15, 2012, 06:43:39 pm »
Sorry for the misunderstood :(

here is a minimal code, as requested :

Code: [Select]


#include <SFML/Graphics.hpp>
#include <SFML/Window.hpp>
#include <SFML/System.hpp>

int main()
{
  // Adjust these two variables to your screen resolution
  int Width_ = 1680;
  int Height_ = 1050;
  float ElapsedTime_;

  // Creating the sf::RenderWindow
  sf::RenderWindow *Window_ = new sf::RenderWindow(sf::VideoMode(Width_, Height_), "Title", sf::Style::Fullscreen);
  sf::Clock Clock_;


  sf::Texture texture;

  // Loading an image in a sf::Texture
  if (!(texture.LoadFromFile("./image.png")))
    return -1;

  // Creating the sf::Sprite from the texture, and scaling it
  sf::Sprite spriteTmp(texture);
  spriteTmp.Scale(Width_ / 1920.f, Height_ / 1200.f);

  // Creating the sf::RenderTexture, and filling it with the scaled sprite
  sf::RenderTexture   *renderTexture = new sf::RenderTexture;
  if (!renderTexture->Create(texture.GetWidth() * (Width_ / 1920.f), texture.GetHeight() * (Height_ / 1200.f)))
    return -1;
  renderTexture->Clear(sf::Color::Transparent);
  renderTexture->Draw(spriteTmp);
  renderTexture->Display();

  // Creating the new sf::sprite with the new scaled texture
  sf::Sprite *sprite = new sf::Sprite(renderTexture->GetTexture());

  while (Window_->IsOpen())
    {
      // event
      ElapsedTime_ = Clock_.GetElapsedTime();
      if (ElapsedTime_ > 17)
{
 Window_->Clear();
 Window_->Draw(*sprite);
 Window_->Display();
 Clock_.Reset();
}
      else
sf::Sleep(2);
    }
}


here is the compilation line :

Code: [Select]
g++ main.cpp  -lsfml-graphics -lsfml-system -lsfml-window

I know that i can use a sf::Texture instead of sf::RenderTexture, but, somewhere in my program, i need a new texture already scaled.

Please, refer to the screenshot i posted before.

sometimes, the full texture is showing good, but it often load some random pixels

by the way, I tried on 2 macbook pro with different graphic cards

thx a lot for your time

15
Graphics / Mac os X Lion - RenderTexture show random pixels
« on: January 15, 2012, 05:46:00 pm »
Here is the MINIMAL code:

main.cpp

Code: [Select]

#include "DisplaySfml.hh"

#define WIDTH (desktop.width())
#define HEIGHT (desktop.height())

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    QDesktopWidget desktop;

    IDisplay* Win = new DisplaySfml();
    Win->InitWindow(WIDTH, HEIGHT, "Air Type");
//    Win->loadImage("Ship", "./Resources/ShipNormal.png");
//    Win->loadImage("ShipForward", "./Resources/ShipForward.png");
//    Win->loadImage("ShipBack", "./Resources/ShipBack.png");
//    Win->loadImage("ShipLeft", "./Resources/ShipLeft.png");
//    Win->loadImage("ShipRight", "./Resources/ShipRight.png");
    Win->loadImage("Background", "./Resources/Background.jpg");
//    Win->loadImage("FrontStars", "./Resources/FrontStars.png");
//    Win->loadImage("BackStars", "./Resources/BackStars.png");
//    Win->loadImage("DoubleStars", "./Resources/FrontStars.png");
//    Win->getSprite("Ship")->SetPosition(WIDTH / 2, HEIGHT / 2);
    Win->DisplayWindow();
    return EXIT_SUCCESS;
}


DisplaySfml.cpp

Code: [Select]


#include "DisplaySfml.hh"

DisplaySfml::DisplaySfml()
    :Speed_(0.01f)
{
    turnSendDirection_[sf::Keyboard::Down] = &moveRight;
    turnSendDirection_[sf::Keyboard::Up] = &moveLeft;
    turnSendDirection_[sf::Keyboard::Left] = &moveBack;
    turnSendDirection_[sf::Keyboard::Right] = &moveForward;
    turnSendDirection_[sf::Keyboard::Space] = &moveSpace;
}

DisplaySfml::~DisplaySfml()
{
    for (std::vector<sf::RenderTexture*>::iterator it = saveTexture_.begin(); it != saveTexture_.end(); ++it)
        delete *it;
    for (std::map<std::string, Sprite>::iterator it = displayImage_.begin(); it != displayImage_.end(); ++it)
        delete (it->second).sprite_;
    delete Window_;
}

void DisplaySfml::InitWindow(int Width, int Height, const std::string & Title)
{
    Width_ = Width;
    Height_ = Height;
    Window_ = new sf::RenderWindow(sf::VideoMode(Width_, Height_), Title.c_str(), sf::Style::None);
    Window_->EnableVerticalSync(true);
}

void DisplaySfml::loadImage(std::string const &name, std::string const & pathImage)
{
    sf::RenderTexture   *renderTexture = new sf::RenderTexture;
    sf::Texture texture;

    if (!(texture.LoadFromFile(pathImage)))
        std::cerr << "Image [" << pathImage << "] is missing" << std::endl;

    sf::Sprite spriteTmp(texture);
    spriteTmp.Scale(Width_ / 1920.f, Height_ / 1200.f);
    if (!renderTexture->Create(texture.GetWidth() * (Width_ / 1920.f), texture.GetHeight() * (Height_ / 1200.f)))
        std::cerr << "RenderTexture [" << pathImage << "] failed to create" << std::endl;
    renderTexture->Clear(sf::Color::Transparent);
    renderTexture->Draw(spriteTmp);
    renderTexture->Display();
    displayImage_[name].sprite_ = new sf::Sprite(renderTexture->GetTexture());
    displayImage_[name].width_ = renderTexture->GetWidth();
    displayImage_[name].height_ = renderTexture->GetHeight();
    displayImage_[name].loop_ = 0;
    displayImage_[name].screenWidth_ = 0;
    saveTexture_.push_back(renderTexture);
}

sf::Sprite  *DisplaySfml::getSprite(std::string const &name)
{
    return displayImage_[name].sprite_;
}

int DisplaySfml::getXSprite(std::string const &name)
{
    return displayImage_[name].sprite_->GetPosition().x;
}

int DisplaySfml::getYSprite(std::string const &name)
{
    return displayImage_[name].sprite_->GetPosition().y;
}

void DisplaySfml::drawImage(std::string const &name, int const &x, int const &y)
{
    displayImage_[name].sprite_->SetPosition(x, y);
    Window_->Draw(*(displayImage_[name].sprite_));
}

void DisplaySfml::DisplayWindow()
{
    x = 0;
    y = 0;
    Clock_.Reset();
    Window_->SetFramerateLimit(60);
    while (Window_->IsOpen())
    {
        event();
        ElapsedTime_ = Clock_.GetElapsedTime();
        if (ElapsedTime_ > 17)
        {
            Window_->Clear();
            drawImage("Background", 0, 0);
//             loopSprite("Background", 3);
//            loopSprite("FrontStars", 2);
//            loopSprite("BackStars", 1);
//            drawImage("Ship", getXSprite("Ship") + x, getYSprite("Ship") + y);
//            drawImage("Ship", 500, 500);
//            loopSprite("DoubleStars", 6);
            Window_->Display();
            Clock_.Reset();
        }
    }
}

void DisplaySfml::event()
{
    sf::Event event;
    while (Window_->PollEvent(event))
    {
        if (event.Type == sf::Event::KeyPressed)
        {
            if ((event.Key.Code == sf::Keyboard::Escape))
            {
                Window_->Close();
                break;
            }
            for (std::map<sf::Keyboard::Key, setNewPos>::iterator it = turnSendDirection_.begin(); it != turnSendDirection_.end(); ++it)
            {
                if (sf::Keyboard::IsKeyPressed(it->first))
                    turnSendDirection_[it->first](x, y);
            }
        }
    }
}

void DisplaySfml::loopSprite(const std::string name, int const speed)
{
    if ((displayImage_[name]).screenWidth_ >= Width_)
        (displayImage_[name]).screenWidth_ = 0;

    if ((displayImage_[name]).loop_ >= (displayImage_[name]).width_)
        (displayImage_[name]).loop_ = 0;

    sf::IntRect leftRect((displayImage_[name]).loop_, 0,
                         Width_ - (displayImage_[name]).screenWidth_, Height_);

    (displayImage_[name]).sprite_->SetTextureRect(leftRect);
    drawImage(name, 0, 0);


    if ((displayImage_[name]).loop_ + Width_ >= (displayImage_[name]).width_)
    {
        sf::IntRect rightRect(0 ,0, (displayImage_[name]).screenWidth_, Height_);
        (displayImage_[name]).sprite_->SetTextureRect(rightRect);
        drawImage(name, Width_ - (displayImage_[name]).screenWidth_, 0);
        (displayImage_[name]).screenWidth_ += speed;
    }
    (displayImage_[name]).loop_ += speed;
}


Any help ?

Pages: [1] 2
anything