[Help] Flicker-free rendering
I'm trying to develop 3d application using MOGRE.
I have Form with controls I need and Panel where I render my stuff. Problem is, when I render new frame there is a noticeble flick going through the Panel.
I tried to make a DoubleBuffered Panel, but it didn't help, because Hwnd, that Ogre gets while initializing isn't valid for rendering with double-buffering enabled. I couldn't find any "back buffer Handle" for this purpose in my Panel, so I don't know what to do.
Is this problem solvable at all?
I am using a picturebox to render and it doesnÂ´t have flicker.
Are you using a rendering cycle or are you rendering the scene when changes are made to the scene?.
Can you post a picture of your application ?
I inherit from UserControl and I dont set any special style (such as DoubleBuffered or anything) and I dont get any flicker here. Can you post your code or at least a stripped down version of it. Im pretty sure me or smernesto can help you here.
I tried both UserControl and Picture box and still have flicker.
Here is structure of my code:
public class OgrePanel : UserControl
private OgreWindow mOgreWindow;
private OgrePanel ogrePanel;
//Problems start when I try to do something like this
void timer1Tick() // ~1000ms
public class OgreWindow
public void Paint()
Well, I donÂ´t recommend to use Invalidate() to call your render.
And why are you using a Timer?
In your timer timer1Tick() call mOgreWindow.Paint(); and dont use Invalidate().
Tell us if it works.
Hm, seems like you are right, it solved the problem.
But why Invalidate() caused it?
Maybe because Invalidate() do something with GDI+ and it is very slow. I donÂ´t know exactly but is better not to use it in this case.
Yeah, smernesto is right.
Use the Paint() method as a fallback. Only use it when the control really needs to be redrawn (for example, the user is dragging a window over you application). Keep it simple.
protected override void OnPaint(PaintEventArgs e)
When you need to render stuff, simply render with ogre as usual (StartRendering(), RenderOneFrame(), RenderWindow.Update(), etc.). Avoid nesting your code with the GDI rendering stuff. Have fun!