Dale_ee
29-08-2007 17:59:16
Hi,
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?
smernesto
29-08-2007 20:45:47
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 ?
bleubleu
30-08-2007 06:04:15
Hi!
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.
Mat
Dale_ee
30-08-2007 16:41:40
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;
..
void ogrePanel_Paint()
{
mOgreWindow.Paint();
}
//Problems start when I try to do something like this
void timer1Tick() // ~1000ms
{
ogrePanel.Invalidate();
}
...
public class OgreWindow
{
public void Paint()
{
updateStuff();
root.RenderOneFrame();
}
}
smernesto
30-08-2007 17:44:44
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.
Dale_ee
30-08-2007 18:03:21
Hm, seems like you are right, it solved the problem.
But why Invalidate() caused it?
smernesto
30-08-2007 23:02:28
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.
bleubleu
30-08-2007 23:48:18
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)
{
RenderOneFrame();
base.OnPaint(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!
Mat