当前位置: 首页>>代码示例>>Python>>正文


Python IECoreGL类代码示例

本文整理汇总了Python中IECoreGL的典型用法代码示例。如果您正苦于以下问题:Python IECoreGL类的具体用法?Python IECoreGL怎么用?Python IECoreGL使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了IECoreGL类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: resizeEvent

	def resizeEvent( self, event ) :

		if self.scene() is not None :

			self.scene().setSceneRect( 0, 0, event.size().width(), event.size().height() )
			owner = GafferUI.Widget._owner( self )

			# clear any existing errors that may trigger
			# error checking code in _resize implementations.
			while GL.glGetError() :
				pass

			owner._makeCurrent()

			# We need to call the init method after a GL context has been
			# created, but before any events requiring GL have been triggered.
			# We had been doing this from GLWidget.__draw(), but it was still
			# possible to trigger mouseMove events prior to drawing by hovering
			# over top of an about-to-become-visible GLWidget. resizeEvent
			# seems to always be triggered prior to both draw and mouseMove,
			# ensuring GL is initialized in time for those other events.
			# Calling it here does mean we call init() more than needed,
			# but it's safe.
			IECoreGL.init( True )

			owner._resize( imath.V2i( event.size().width(), event.size().height() ) )
开发者ID:mattigruener,项目名称:gaffer,代码行数:26,代码来源:GLWidget.py

示例2: testGeometryShaderViaFile

	def testGeometryShaderViaFile( self ) :
	
		if IECoreGL.glslVersion() < 150 :
			# no point testing unavailable functionality
			return

		g = IECore.Group()
		
		p = IECore.PointsPrimitive( IECore.V3fVectorData( [ IECore.V3f( 0 ) ] ) )
		p["type"] = IECore.PrimitiveVariable( IECore.PrimitiveVariable.Interpolation.Uniform, IECore.StringData( "gl:point" ) )
		g.addChild( p )
		
		g.addState( IECore.AttributeState( { "gl:pointsPrimitive:glPointWidth" : IECore.FloatData( 4 ) } ) )
		g.addState( IECore.Shader( "pointTripler", "gl:surface" ) )
		
		image = self.renderImage( g )

		self.assertImageValues(
			image,
			[
				( IECore.V2f( 0.125, 0.5 ), IECore.Color4f( 0, 0, 0, 0 ) ), 
				( IECore.V2f( 0.25, 0.5 ), IECore.Color4f( 1, 1, 1, 1 ) ), 
				( IECore.V2f( 0.375, 0.5 ), IECore.Color4f( 0, 0, 0, 0 ) ), 
				( IECore.V2f( 0.5, 0.5 ), IECore.Color4f( 1, 1, 1, 1 ) ), 
				( IECore.V2f( 0.625, 0.5 ), IECore.Color4f( 0, 0, 0, 0 ) ), 
				( IECore.V2f( 0.75, 0.5 ), IECore.Color4f( 1, 1, 1, 1 ) ), 
				( IECore.V2f( 0.875, 0.5 ), IECore.Color4f( 0, 0, 0, 0 ) ), 
			]
		)	
开发者ID:boberfly,项目名称:cortex,代码行数:29,代码来源:ShadingTest.py

示例3: testGeometryShader

	def testGeometryShader( self ) :
	
		if IECoreGL.glslVersion() < 150 :
			# can't test geometry shaders if they don't exist
			return
			
		geometrySource = """
		#version 150
		
		layout( triangles ) in;
		layout( triangle_strip, max_vertices=3 ) out;
		
		uniform float geometryShaderParameter = 0;
		
		void main()
		{
			for( int i = 0; i < gl_in.length(); i++)
			{
				gl_Position = gl_in[i].gl_Position + vec4( geometryShaderParameter, 0, 0, 1 );
				EmitVertex();
			}
		}
		"""
		
		s = IECoreGL.Shader( IECoreGL.Shader.defaultVertexSource(), geometrySource, IECoreGL.Shader.defaultFragmentSource() )
		
		self.failUnless( "geometryShaderParameter" in s.uniformParameterNames() )
开发者ID:Shockspot,项目名称:cortex,代码行数:27,代码来源:Shader.py

示例4: __draw

	def __draw( self ) :

		# Qt sometimes enters our GraphicsScene.drawBackground() method
		# with a GL error flag still set. We unset it here so it won't
		# trigger our own error checking.
		while GL.glGetError() :
			pass

		if not self.__framebufferValid() :
			return

		# we need to call the init method after a GL context has been
		# created, and this seems like the only place that is guaranteed.
		# calling it here does mean we call init() way more than needed,
		# but it's safe.
		## \todo: this might be removable if we can prove resizeEvent
		# is always called first.
		IECoreGL.init( True )

		self._draw()
开发者ID:mattigruener,项目名称:gaffer,代码行数:20,代码来源:GLWidget.py

示例5: DAMAGES

#  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
#  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
#  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
#  LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
#  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
#  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
##########################################################################

import unittest
import os.path

import IECore
import IECoreGL

IECoreGL.init( False )

class TestShader( unittest.TestCase ) :

	def testConstructor( self ) :

		self.assertRaises( RuntimeError, IECoreGL.Shader, "i don't think i'm valid", "me neither" )

		vertexSource = """
		void main()
		{
			gl_Position = ftransform();
		}
		"""

		fragmentSource = """
开发者ID:danbethell,项目名称:cortex,代码行数:31,代码来源:Shader.py

示例6: setUp

	def setUp( self ) :
	
		IECoreGL.init( False )
开发者ID:Shockspot,项目名称:cortex,代码行数:3,代码来源:TextureLoaderTest.py

示例7: runPointAtVTest

	def runPointAtVTest( self, curvesPrimitive, expectedPositions=None, expectedLengths=None, visualTest=False, printPoints=False ) :
	
		e = IECore.CurvesPrimitiveEvaluator( curvesPrimitive )
		r = e.createResult()
	
		p = IECore.V3fVectorData()
		for ci in range( 0, curvesPrimitive.variableSize( IECore.PrimitiveVariable.Interpolation.Uniform ) ) :
			numSamples = 50
			for i in range( 0, numSamples ) :
		
				s = e.pointAtV( ci, float( i ) / float( numSamples - 1 ), r )
				self.failUnless( s )

				p.append( r.point() )

		if expectedPositions :
		
			self.assertEqual( len( p ), len( expectedPositions ) )
			for i in range( 0, len( p ) ) :
				self.failUnless( p[i].equalWithAbsError( expectedPositions[i], 0.00001 ) )
		
		if expectedLengths :
			
			self.assertEqual( curvesPrimitive.numCurves(), len( expectedLengths ) )
			linearNonPeriodic = ( curvesPrimitive.basis() == IECore.CubicBasisf.linear() ) and not curvesPrimitive.periodic()
			for i in range( 0, curvesPrimitive.numCurves() ) :
				if linearNonPeriodic :
					self.assertEqual( e.curveLength( i ), expectedLengths[i] )
				else :
					self.assertAlmostEqual( e.curveLength( i ), expectedLengths[i], 5 )
		
		if printPoints :
		
			print repr( p ).replace( "),", "),\n" )

		if visualTest :
		
			import IECoreGL
			IECoreGL.init( False )
			
			r = IECoreGL.Renderer()
			r.setOption( "gl:mode", IECore.StringData( "deferred" ) )
			
			pointsPrimitive = IECore.PointsPrimitive( p )
			pointsPrimitive["constantwidth"] = IECore.PrimitiveVariable( IECore.PrimitiveVariable.Interpolation.Constant, IECore.FloatData( 0.1 ) )
			
			with IECore.WorldBlock( r ) :
			
				w = IECoreGL.SceneViewer( "scene", r.scene() )
				
				with IECore.AttributeBlock( r ) :
				
					r.shader( "surface", "red", { "gl:fragmentSource" : IECore.StringData( "void main() { gl_FragColor = vec4( 1, 0, 0, 1 ); }" ) } )
					r.setAttribute( "gl:curvesPrimitive:useGLLines", IECore.BoolData( True ) )
					curvesPrimitive.render( r )
				
				with IECore.AttributeBlock( r ) :
				
					r.shader( "surface", "blue", { "gl:fragmentSource" : IECore.StringData( "void main() { gl_FragColor = vec4( 0, 0, 1, 1 ); }" ) } )
					pointsPrimitive.render( r )
						
			w.start()
开发者ID:AtomicFiction,项目名称:cortex,代码行数:62,代码来源:CurvesPrimitiveEvaluatorTest.py

示例8: setUp

	def setUp( self ) :

		GafferTest.TestCase.setUp( self )

		IECoreGL.init( False )
开发者ID:ivanimanishi,项目名称:gaffer,代码行数:5,代码来源:RendererTest.py


注:本文中的IECoreGL类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。