本文整理汇总了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() ) )
示例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 ) ),
]
)
示例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() )
示例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()
示例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 = """
示例6: setUp
def setUp( self ) :
IECoreGL.init( False )
示例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()
示例8: setUp
def setUp( self ) :
GafferTest.TestCase.setUp( self )
IECoreGL.init( False )