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

Author Topic: SFML 2.0 RenderImage  (Read 7176 times)

0 Members and 1 Guest are viewing this topic.

vidjogamer

  • Jr. Member
  • **
  • Posts: 67
    • View Profile
SFML 2.0 RenderImage
« on: March 31, 2011, 08:58:08 am »
Is there a limit on the size of a RenderImage?
Also, is this even stable in SFML 2 because im getting lots of strange behavior.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
SFML 2.0 RenderImage
« Reply #1 on: March 31, 2011, 09:01:02 am »
Quote
Is there a limit on the size of a RenderImage?

Yes, the same limit as sf::Image.

Quote
Also, is this even stable in SFML 2 because im getting lots of strange behavior.

There are indeed some bugs, but I'm working on it so wait a few days and it should be better.
However you can explain your problem, to make sure you didn't do anything wrong.
Laurent Gomila - SFML developer

vidjogamer

  • Jr. Member
  • **
  • Posts: 67
    • View Profile
SFML 2.0 RenderImage
« Reply #2 on: March 31, 2011, 09:31:26 am »
Quote

Yes, the same limit as sf::Image.


Out of curiosity, what would that be?

Quote
There are indeed some bugs, but I'm working on it so wait a few days and it should be better.
However you can explain your problem, to make sure you didn't do anything wrong.


I am doing everything in the documentation.

initialization:
Code: [Select]

renderImage.Create(1024,1024);
renderImage.SetSmooth(true);


render loop:
Code: [Select]

renderWindow->SetView(*scene->view);
renderWindow->Clear(sf::Color(25,122,200,255));

scene->renderImage->Clear(sf::Color(255,5,92,255));

//i do this for each tile
scene->renderImage.Draw(*tileSprite);


scene->renderImage.Display();
Sprite sprite;
sprite.SetImage(scene->renderImage->GetImage());
renderWindow->Draw(sprite);

renderWindow->Display();


What I get is a render image of the correct size in the correct position but only drawing a few of the tiles (the upper left quarter or so) when the exact same code on just the renderWindow draws all of the tileSprites.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
SFML 2.0 RenderImage
« Reply #3 on: March 31, 2011, 09:38:45 am »
Quote
Out of curiosity, what would that be?

http://www.sfml-dev.org/documentation/2.0/classsf_1_1Image.htm#acb15b7adf8aa6f2155e6f5ce3c11baf5

Quote
What I get is a render image of the correct size in the correct position but only drawing a few of the tiles (the upper left quarter or so) when the exact same code on just the renderWindow draws all of the tileSprites.

That's weird. What's your OS and graphics card? Are you able to produce this bug with a complete and minimal code (ie. outside your project)?
Laurent Gomila - SFML developer

panithadrum

  • Sr. Member
  • ****
  • Posts: 304
    • View Profile
    • Skyrpex@Github
    • Email
SFML 2.0 RenderImage
« Reply #4 on: March 31, 2011, 09:39:09 am »
Quote from: "vidjogamer"
Quote

Yes, the same limit as sf::Image.


Out of curiosity, what would that be?

sf::Image::GetMaximumSize()

vidjogamer

  • Jr. Member
  • **
  • Posts: 67
    • View Profile
SFML 2.0 RenderImage
« Reply #5 on: March 31, 2011, 09:51:35 am »
OS : WinXP
Graphics Card : Mobile Intel(R) 965 Express Chipset Family


Ill get back to with a minimal code project.[/code]

Groogy

  • Hero Member
  • *****
  • Posts: 1469
    • MSN Messenger - groogy@groogy.se
    • View Profile
    • http://www.groogy.se
    • Email
SFML 2.0 RenderImage
« Reply #6 on: March 31, 2011, 10:14:00 am »
Intel chipsets can give very weird behavior. They freaked out Ruby while I was writing the bindings. Literally, the garbage collector tried to access memory Intel's drivers had deallocated or something, hard to know what it really was but it was terrifying to watch.

Also the ATI bug was also present on Intel cards. So this could be related to it just being an Intel card.
Developer and Maker of rbSFML and Programmer at Paradox Development Studio

vidjogamer

  • Jr. Member
  • **
  • Posts: 67
    • View Profile
SFML 2.0 RenderImage
« Reply #7 on: March 31, 2011, 10:18:57 am »
What is the ATI bug?

vidjogamer

  • Jr. Member
  • **
  • Posts: 67
    • View Profile
SFML 2.0 RenderImage
« Reply #8 on: March 31, 2011, 10:32:34 am »
This does it as well. I see the blue background of the renderImage across the entire window but the images stop drawing approximately 600/700 pixels in?

Code: [Select]

int main(int argc, char *argv)
{

 if (!sf::RenderImage::IsAvailable())
    return -1;

 sf::RenderWindow window(sf::VideoMode::GetDesktopMode(), "SFML window");
 
 sf::RenderImage renderImage;
 if (!renderImage.Create(2048, 2048))
     return -1;


 Image image;
 image.LoadFromFile("image.png");
 Sprite tileSprite(image);
 
 while (window.IsOpened())
 {
    renderImage.Clear(sf::Color::Blue);

for(int x = 0; x<50; x++)
{
for(int y = 0; y<50; y++)
{
tileSprite.SetPosition(x*image.GetWidth(),y*image.GetHeight());
renderImage.Draw(tileSprite);  // sprite is a sf::Sprite
}
}

    renderImage.Display();

    window.Clear();

    sf::Sprite sprite(renderImage.GetImage());
    window.Draw(sprite);

    window.Display();
 }
return 0;
}

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
SFML 2.0 RenderImage
« Reply #9 on: March 31, 2011, 10:38:58 am »
Quote
What is the ATI bug?

Freeze at startup or crash at exit. So it has nothing to do with your problem. And it was fixed a few weeks ago anyway.

Your code looks good, so I think we should get back to this problem after I'm done changing the implentation.
Laurent Gomila - SFML developer

Oneiros

  • Jr. Member
  • **
  • Posts: 60
    • View Profile
SFML 2.0 RenderImage
« Reply #10 on: March 31, 2011, 11:50:58 am »
I don't know if it's related but under xp I'have seen some strange bug with using vector2f or rect, if I set position of something or use contains whith a rect or vector creating with another vector, the result is a rect/vector with value that not those I have passed, if i create Rect/Vector with using member of vector/rect instead of passing it to function, it works.

For exemple :

Code: [Select]
sprite.SetPosition( object.GetPosition() );// Work on ubuntu but don't on xp.
sprite.SetPosition( object.GetPosition().x,object.GetPosition().y);// Work both ubuntu/xp;


Maybe there is a bug under xp with Vector.
If you check the size of renderImage after create, it give you the good size?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
SFML 2.0 RenderImage
« Reply #11 on: March 31, 2011, 12:02:32 pm »
Quote
Maybe there is a bug under xp with Vector.

Honestly, this is unlikely to be true. The code is straight-forward maths and has nothing which is OS-specific.
I suspect there is something wrong on your side. I'd like to see a minimal and complete example that reproduces this kind of bug (open a new thread if you provide one).
Laurent Gomila - SFML developer