OpenGL Control Flickering Problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mark Thompson

    #1

    OpenGL Control Flickering Problem

    I have a problem with my Visual Basic .NET 2003 application which I
    have so far been unable to resolve.

    I am trying to get an OpenGL control that I have created working
    properly as a control on my main form in my VB.NET application. It does
    work and render correctly but the problem is that there is an awful
    flickering that happens on most PCs I try it on. The flickering is
    reminiscent of the sort that you get on a TV when it is not tuned in
    properly, i.e. portions of the background are visible in horizontal
    bands that move up or down the control and make it pretty much
    unusable.

    Bizarrely though, on my laptop, if I Alt-Tab to another application
    which moves in front of the flickering control and then Alt-Tab back to
    my application then it is fine for a while. However, as soon as any
    other dialog or message box appears in my application, or I resize it
    then the flickering starts again. On two of my colleague's laptops
    however, we get the flickering and no amount of moving things in front
    of it makes any difference.

    Also, when I remote desktop into my laptop from my PC, I do not see
    this problem at all, i.e. the control behaves perfectly.

    I am using an OpenGL wrapper library. I oringally tried using CsGL and
    then I tried Tao (more recent and maintained library) for the control,
    both have the same result.

    The code I am using has a timer on the form which fires periodically to
    force the refresh of the control. I have tried varying the periodicity
    of this from 1ms right up to 1000ms but the flickering still happens.
    With 1000ms it almost appears like as soon as the control is refreshed,
    it disappears as with this periodicity it becomes almost invisible.

    Does anyone have any ideas on this as it is driving me barmy now!

    Thanks,

    Mark.

  • Dragon

    #2
    Re: OpenGL Control Flickering Problem

    Hello Mark,

    Probably you'll need to enable double buffering on your control during
    its creation:

    ~
    Me.SetStyle(Con trolStyles.Doub leBuffer, True)
    Me.SetStyle(Con trolStyles.AllP aintingInWmPain t, True)
    Me.SetStyle(Con trolStyles.User Paint, True)
    ~

    Hope this helps,
    Roman


    Comment

    • Mark Thompson

      #3
      Re: OpenGL Control Flickering Problem

      Thanks Roman but I am pretty sure that's not it.

      I probably should have mentioned that I had already eliminated lack of
      Double Bufferring as the problem as I am already doing this. Also, it
      isn't that sort of flickering that you get with the bufferring, it is
      more like the entire control is disappearing every time it is
      refreshed. It's just that I am refreshing so often that it is appearing
      and disappearing several times a second.

      Any further help from anyone would be appreciated.

      Regards,

      Mark.

      Comment

      • Bob Powell [MVP]

        #4
        Re: OpenGL Control Flickering Problem

        You forgot to override OnPaintBackgrou nd so that it doesn't call the base
        class didn't you... ;-)

        --
        Bob Powell [MVP]
        Visual C#, System.Drawing

        Ramuseco Limited .NET consulting


        Find great Windows Forms articles in Windows Forms Tips and Tricks


        Answer those GDI+ questions with the GDI+ FAQ


        All new articles provide code in C# and VB.NET.
        Subscribe to the RSS feeds provided and never miss a new article.



        "Mark Thompson" <choffi@dsl.pip ex.com> wrote in message
        news:1147262574 .132532.110020@ v46g2000cwv.goo glegroups.com.. .[color=blue]
        >I have a problem with my Visual Basic .NET 2003 application which I
        > have so far been unable to resolve.
        >
        > I am trying to get an OpenGL control that I have created working
        > properly as a control on my main form in my VB.NET application. It does
        > work and render correctly but the problem is that there is an awful
        > flickering that happens on most PCs I try it on. The flickering is
        > reminiscent of the sort that you get on a TV when it is not tuned in
        > properly, i.e. portions of the background are visible in horizontal
        > bands that move up or down the control and make it pretty much
        > unusable.
        >
        > Bizarrely though, on my laptop, if I Alt-Tab to another application
        > which moves in front of the flickering control and then Alt-Tab back to
        > my application then it is fine for a while. However, as soon as any
        > other dialog or message box appears in my application, or I resize it
        > then the flickering starts again. On two of my colleague's laptops
        > however, we get the flickering and no amount of moving things in front
        > of it makes any difference.
        >
        > Also, when I remote desktop into my laptop from my PC, I do not see
        > this problem at all, i.e. the control behaves perfectly.
        >
        > I am using an OpenGL wrapper library. I oringally tried using CsGL and
        > then I tried Tao (more recent and maintained library) for the control,
        > both have the same result.
        >
        > The code I am using has a timer on the form which fires periodically to
        > force the refresh of the control. I have tried varying the periodicity
        > of this from 1ms right up to 1000ms but the flickering still happens.
        > With 1000ms it almost appears like as soon as the control is refreshed,
        > it disappears as with this periodicity it becomes almost invisible.
        >
        > Does anyone have any ideas on this as it is driving me barmy now!
        >
        > Thanks,
        >
        > Mark.
        >[/color]


        Comment

        • Mark Thompson

          #5
          Re: OpenGL Control Flickering Problem

          Bob Powell [MVP] wrote:[color=blue]
          > You forgot to override OnPaintBackgrou nd so that it doesn't call the base
          > class didn't you... ;-)
          >[/color]

          Hi Bob,

          Thanks for your help but unfortunately that does not fix it.

          I had really high hopes that that would be it when I saw your post but
          I have just spent the last hour trying it out. I have tried overriding
          it in my OpenGL control. I have tried overriding it in the main form. I
          have even tried overriding it in a Custom Panel class that I have which
          is substituted for all the panels on the main form in case this was the
          problem but to no avail in all cases.

          I feel it has to be something simple like this though.

          Any other ideas?

          Thanks,

          Mark.

          Comment

          • Bob Powell [MVP]

            #6
            Re: OpenGL Control Flickering Problem

            I think that the best thing to do is concentrate on your OpenGL control.
            Everything else is just noise.

            Have you set the styes for AllPaintingInWM Paint and UserPaint ?

            How are you drawing the OpenGL rendering. To the screen or to a bitmap?
            Are you using double-buffering?

            Are you using CreateGraphics anywhere?

            The OnPaintBackgrou nd call in the OpenGL control should look like:

            protected void OnPaintBackgrou nd(PaintEventAr gs pe)
            {
            //Do nothing here...
            }

            Do not call base.OnPaintBac kground in any part of your control.

            If you like, e-mail me the OpenGL control source and I'll look it over.

            --
            Bob Powell [MVP]
            Visual C#, System.Drawing

            Ramuseco Limited .NET consulting


            Find great Windows Forms articles in Windows Forms Tips and Tricks


            Answer those GDI+ questions with the GDI+ FAQ


            All new articles provide code in C# and VB.NET.
            Subscribe to the RSS feeds provided and never miss a new article.



            "Mark Thompson" <choffi@dsl.pip ex.com> wrote in message
            news:1147424308 .793848.254320@ y43g2000cwc.goo glegroups.com.. .[color=blue]
            > Bob Powell [MVP] wrote:[color=green]
            >> You forgot to override OnPaintBackgrou nd so that it doesn't call the base
            >> class didn't you... ;-)
            >>[/color]
            >
            > Hi Bob,
            >
            > Thanks for your help but unfortunately that does not fix it.
            >
            > I had really high hopes that that would be it when I saw your post but
            > I have just spent the last hour trying it out. I have tried overriding
            > it in my OpenGL control. I have tried overriding it in the main form. I
            > have even tried overriding it in a Custom Panel class that I have which
            > is substituted for all the panels on the main form in case this was the
            > problem but to no avail in all cases.
            >
            > I feel it has to be something simple like this though.
            >
            > Any other ideas?
            >
            > Thanks,
            >
            > Mark.
            >[/color]


            Comment

            • Mark Thompson

              #7
              Re: OpenGL Control Flickering Problem

              Hi Bob,

              I have tried to e-mail you at the one on your profile but that just
              bounces back. Could you let me know what address to use?

              I am at choffi@dsl.pipe x.com by the way.

              Thanks,

              Mark.

              Comment

              Working...