0

SimpleOpenGlControl我对 Tao 的控制有一个奇怪的“闪烁”问题。我有 3 个标签页System.Windows.Forms.TabControl。第一页和第二页填满了SimpleOpenGlControl一会儿,第三页上有一个MonthCalendar(或一个Button或别的东西)。考虑这段代码:

public partial class Form1 : Form {
    public Form1() {
        InitializeComponent();
        simpleOpenGlControl1.InitializeContexts();
        Gl.glClearColor(0, 0, 0, 1);
        simpleOpenGlControl2.InitializeContexts();
        Gl.glClearColor(0, 0, 0, 1);
    }

    private void simpleOpenGlControl1_Paint(object sender, PaintEventArgs e) {
        // This delay makes the problem evident.
        Thread.Sleep(2000);
        Gl.glClear(Gl.GL_COLOR_BUFFER_BIT);
    }

    private void simpleOpenGlControl2_Paint(object sender, PaintEventArgs e) {
        Thread.Sleep(2000);
        Gl.glClear(Gl.GL_COLOR_BUFFER_BIT);
    }
}

如果我从第一页切换到第二页、第三页、第二页和第一页,我会在绘制第一个控件之前将日历视为一种背景。

从源码中看到,OnPaintBackground方法被覆盖,基类UserControl.OnPaintBackground方法没有被调用。会不会是问题?

编辑:

我试图覆盖OnPaintBackground子类中的方法,但没有调用它。实际上控件的样式是这样初始化的:

this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
this.SetStyle(ControlStyles.DoubleBuffer, false);
this.SetStyle(ControlStyles.Opaque, true);
this.SetStyle(ControlStyles.ResizeRedraw, true);
this.SetStyle(ControlStyles.UserPaint, true);

我怀疑选项卡控件缓冲与SimpleOpenGlControl某些方面的缓冲冲突。

和属性设置为 true AutoMakeCurrentAutoSwapBuffers我尝试SwapBuffers()在更改之前调用TabPage,结果更好但并不完美:在选项卡中前后移动会导致MonthCalendar有时闪烁。

编辑2:

我使用OpenTK.GLControl. 使用 dotNet 控件作为PictureBox.

编辑3:

WndProc我也尝试过覆盖为什么我的 WinForm 控件在绘制事件之前闪烁?但结果是一样的。OpenTk 论坛上的这个答案也无济于事。

似乎不可能没有解决这个问题!

4

0 回答 0