Exemplo n.º 1
0
	def __createQGLWidget( cls, format ) :

		# try to make a host specific widget if necessary.
		result = cls.__createMayaQGLWidget( format )
		if result is not None :
			return result

		result = cls.__createHoudiniQGLWidget( format )
		if result is not None :
			return result

		# and if it wasn't necessary, just breathe a sigh of relief
		# and make a nice normal one.
		if cls.__shareWidget is None :
			cls.__shareWidget = QtOpenGL.QGLWidget()

		return QtOpenGL.QGLWidget( format, shareWidget = cls.__shareWidget )
Exemplo n.º 2
0
    def initialize_scene_view(self):
        """
        Instantiates the proper Scene and enables OpenGL if necessary
        Scene instantiation must be override in child classes
        """

        if self._use_opengl:
            self.setViewport(QtOpenGL.QGLWidget(QtOpenGL.QGLFormat(QtOpenGL.QGL.SampleBuffers)))
            self.log.info('Initializing OpenGL renderer')
Exemplo n.º 3
0
	def __createHostedQGLWidget( cls, format ) :

		# When running Gaffer embedded in a host application such as Maya
		# or Houdini, we want to be able to share OpenGL resources between
		# gaffer uis and host viewport uis, because IECoreGL will be used
		# in both. So we implement our own QGLContext class which creates a
		# context which shares with the host. The custom QGLContext is
		# implemented in GLWidgetBinding.cpp, and automatically shares with
		# the context which is current at the time of its creation. The host
		# context should therefore be made current before calling this
		# method.

		result = QtOpenGL.QGLWidget()
		_GafferUI._glWidgetSetHostedContext( GafferUI._qtAddress( result ), GafferUI._qtAddress( format ) )
		return result
Exemplo n.º 4
0
	def __createHoudiniQGLWidget( cls, format ) :

		try :
			import hou
		except ImportError :
			# we're not in houdini - createQGLWidget() will just make a
			# normal widget.
			return None

		import IECoreHoudini

		if hasattr( IECoreHoudini, "sharedGLWidget" ) :
			# In Houdini 14 and 15, Qt is the native UI, and we can access
			# Houdini's shared QGLWidget directly.
			return QtOpenGL.QGLWidget( format, shareWidget = GafferUI._qtObject( IECoreHoudini.sharedGLWidget(), QtOpenGL.QGLWidget ) )

		# While Qt is the native UI in Houdini 16.0, they have moved away
		# from QGLWidgets for their Qt5 builds, so we need to force the
		# Houdini GL context to be current, and share it.
		IECoreHoudini.makeMainGLContextCurrent()
		return cls.__createHostedQGLWidget( format )
Exemplo n.º 5
0
	def __createHoudiniQGLWidget( cls, format ) :

		try :
			import hou
		except ImportError :
			# we're not in houdini - createQGLWidget() will just make a
			# normal widget.
			return None

		import IECoreHoudini

		# Prior to Houdini 14 we are running embedded on the hou.ui idle loop,
		# so we needed to force the Houdini GL context to be current, and share
		# it, similar to how we do this in Maya.
		if hou.applicationVersion()[0] < 14 :
			IECoreHoudini.makeMainGLContextCurrent()
			return cls.__createHostedQGLWidget( format )

		# In Houdini 14 and beyond, Qt is the native UI, and we can access
		# Houdini's shared QGLWidget directly, provided we are using a recent
		# Cortex version.
		return QtOpenGL.QGLWidget( format, shareWidget = GafferUI._qtObject( IECoreHoudini.sharedGLWidget(), QtOpenGL.QGLWidget ) )
Exemplo n.º 6
0
 def use_OpenGL(self):
     format = QtOpenGL.QGLFormat(QtOpenGL.QGL.SampleBuffers)
     format.setSamples(4)
     self.setViewport(QtOpenGL.QGLWidget(format))