#
#   PyGUI - OpenGL View - Generic
#

from ClipComponents import ClipComponent
from ViewBases import ViewBase

class GLError(StandardError):
    pass

class GLView(ClipComponent, ViewBase):
    """A GLView is a Component providing an OpenGL 3D display area.
    
    Constructor:
        GLView(double_buffer = True, alpha = False, depth_buffer = True,
            stencil_buffer = False, accum_buffer = False, multisample = False)
    """
    
    def __init__(self, **kwds):
        ClipComponent.__init__(self, **kwds)
        ViewBase.__init__(self)
    
    def init_context(self):
        """This method is called once when the OpenGL context associated
        with this view is created. It may be used to establish any desired
        initial OpenGL state."""
        pass
    
    def render(self):
        """This method is called when the contents of the view needs to
        be redrawn, with the view's OpenGL context as the current context.
        After calling this method, buffers will be automatically swapped or
        drawing flushed as appropriate."""
        pass
    
    def viewport_changed(self):
        """This method is called when the view's size has changed, with
        the view's OpenGL context as the current context, and the OpenGL
        viewport set to (0, 0, width, height)."""
        pass
    
    def with_context(self, proc):
        """The proc should be a callable object of no arguments. Calls
        the proc with the view's OpenGL context as the current context."""
        raise NotImplementedError("GUI.GLView.with_gl")

