[vtk-developers] ReadOpenGLExtensions() should not call Render()

Moreland, Kenneth kmorel at sandia.gov
Tue Sep 7 13:23:44 EDT 2010


I think we can all agree that having vtkOpenGLExtensionManager call Render is not a great idea.  The problem is that there is a chicken-and-egg problem where vtkOpenGLExtensionManager needs the OpenGL context already created to accurately report the extensions supported, but you often want query available extensions early in initialization before rendering occurs.

So, how should ReadOpenGLExtensions behave if the context has not yet been created?  Perhaps vtkRenderWindow could expose a method that forces the context to be created.  But does that actually solve the problem?  Could this still cause problems if the user has not set up size, position, offscreen rendering, alpha channel, etc?  What if the render window is later used with a QVTKWidget?

Perhaps ReadOpenGLExtensions should just error out if the OpenGL context is not yet created.  This might "break" a lot of existing code, but should we consider that code already broken?  If this is the right solution, then vtkRenderWindow should probably still get a method that forces the context to created.  That would allow users to initialize the parameters of the render window, create the OpenGL context, and then use vtkOpenGLExtensionManager to initialize the rest of the rendering.

-Ken


On 9/7/10 7:30 AM, "David Gobbi" <david.gobbi at gmail.com> wrote:

Hi All,

I have a little complaint about this code in
vtkOpenGLExtensionManager::ReadOpenGLExtensions()

    this->RenderWindow->MakeCurrent();
    if (!this->RenderWindow->IsCurrent())
      {
      // Really should create a method in the render window to create
      // the graphics context instead of forcing a full render.
      this->RenderWindow->Render();
      }

Calling Render() inside ReadOpenGLExtensions() is a bad thing.  It can
cause the first render to occur as a side effect, and it might result
in the window being rendered before it has been properly sized and
positioned.  From what I've seen, this Render always gets called on
Windows but never on X.  This render was also the cause of bug 11208
(http://www.vtk.org/Bug/view.php?id=11208) which took me the better
part of a day to track down.

  David
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtk-developers





   ****      Kenneth Moreland
    ***      Sandia National Laboratories
***********
*** *** ***  email: kmorel at sandia.gov
**  ***  **  phone: (505) 844-8919
    ***      web:   http://www.cs.unm.edu/~kmorel

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20100907/50711b06/attachment.html>


More information about the vtk-developers mailing list