SFML community forums

Help => Graphics => Topic started by: heishe on July 17, 2011, 01:25:10 pm

Title: Maximum amount of RenderImages?
Post by: heishe on July 17, 2011, 01:25:10 pm
Is there a maximum amount of RenderImages that a graphics card can support? I'm currently programming mostly on my laptop, which only has an integrated graphics chip, and I'm running into seemingly unrelated problems of flickering screens when working with RenderImages.

And what happens when I create more than the maximum amount? Will different RenderImages start to target the same data?
Title: Maximum amount of RenderImages?
Post by: Laurent on July 17, 2011, 06:34:18 pm
The only limit is the amount of RAM that your graphics card has. But you shouldn't need so many render-images, what do you do with them?
Title: Maximum amount of RenderImages?
Post by: heishe on July 17, 2011, 10:03:15 pm
Quote from: "Laurent"
The only limit is the amount of RAM that your graphics card has. But you shouldn't need so many render-images, what do you do with them?


Well, I actually only have two. One for regular (deferred) rendering (in order to apply full-screen shaders to the scene) and one for my light/shadow map (which is just drawn on top of the regular RenderImage using multiplicative blending).

But I've just now tried to implement a minimal case to reproduce the problem, and it even occurs with just one RenderImage:

Code: [Select]

#include <sfml/window.hpp>
#include <sfml/graphics.hpp>

int main()
{
sf::RenderWindow app(sf::VideoMode(800,600,32),"renderimage");

sf::RenderImage r1;
r1.Create(800,600);

sf::Image i;
i.LoadFromFile("Data/Sprites/test.png");
sf::Sprite spr1(i,sf::Vector2f(0,0));
spr1.Resize(800,600);


sf::Sprite everything;

while(app.IsOpened())
{
sf::Event e;
while(app.PollEvent(e))
{
switch(e.Type)
{
case sf::Event::Closed:
app.Close();
break;
}
}
app.Clear();

r1.Clear();
r1.Draw(spr1);
r1.Display();

everything.SetImage(r1.GetImage());
app.Draw(everything);

app.Display();
}

return 0;
}


Produces the same mad flickering. But that doesn't make sense to me, since I pretty much do exactly the same in my engine and it only produces flickering once I add in clearing/drawing/displaying of a second renderimage.

By the way, this works fine and shows the sprite in question:

Code: [Select]

#include <sfml/window.hpp>
#include <sfml/graphics.hpp>

int main()
{
sf::RenderWindow app(sf::VideoMode(800,600,32),"renderimage");

sf::RenderImage r1;
r1.Create(800,600);

sf::Image i;
i.LoadFromFile("Data/Sprites/test.png");
sf::Sprite spr1(i,sf::Vector2f(0,0));
spr1.Resize(800,600);


sf::Sprite everything;

while(app.IsOpened())
{
sf::Event e;
while(app.PollEvent(e))
{
switch(e.Type)
{
case sf::Event::Closed:
app.Close();
break;
}
}
app.Clear();

                app.Draw(spr1);

app.Display();
}

return 0;
}


I actually might post the relevant code of my renderer, but I'm not sure what good it will do.
Title: Maximum amount of RenderImages?
Post by: heishe on July 18, 2011, 12:12:32 am
Actually, the problem seems to be that you can't interlace Clear() and Display() calls of the RenderWindow and RenderImage-s. I haven't looked at the SFML source so I can't say why that is, but changing the drawing code to:

Code: [Select]
     

      r1.Clear();
      r1.Draw(spr1);
      r1.Display();
     app.Clear();
      everything.SetImage(r1.GetImage());
      app.Draw(everything);

      app.Display();


Fixes the flickering. I'm currently reworking a part of my renderer (now fully deferred rendering using std::vector) to see if it fixes my problem, will check back later.
Title: Maximum amount of RenderImages?
Post by: heishe on July 18, 2011, 12:25:00 am
Yes, this actually fixes everything.

You might want to add some references to this to the tutorials, the documentation of the functions/classes or something like that, though, in case someone runs across the same problem.
Title: Maximum amount of RenderImages?
Post by: Laurent on July 18, 2011, 07:44:51 am
In fact it might be a bug. Unfortunately I can't reproduce it, your first piece of code works fine on my computer.

What OS / graphics card / revision of SFML 2 do you use?
Title: Maximum amount of RenderImages?
Post by: heishe on July 18, 2011, 09:52:52 am
Quote from: "Laurent"
In fact it might be a bug. Unfortunately I can't reproduce it, your first piece of code works fine on my computer.

What OS / graphics card / revision of SFML 2 do you use?


It might be a bug... but my graphics card could be the problem as well. Intel's GPUs are somewhat known for their crappy OpenGL support.

OS: Windows 7
Graphics card: Mobile Intel 965 Express
SFML 2 revision: Well, I don't know the exact version, but it is the revision of about 4 weeks ago. Int-timers are already implemented, PollEvent instead of GetEvent as well.
Title: Maximum amount of RenderImages?
Post by: Laurent on July 18, 2011, 10:14:10 am
Indeed, I have a lot of problems with RenderImage and Intel integrated GPUs.