diff --git a/Changes b/Changes index f5843a6fc0..e5cc7301e2 100644 --- a/Changes +++ b/Changes @@ -8,6 +8,12 @@ Fixes - Fixed reading of primitives containing `primvars:normals`. These are now correctly loaded as a primitive variable called `N`, taking precedence over the UsdGeomPointBased `normals` attribute. - Fixed writing of indexed normals so that the indexing is retained on load. Note that this means that normals are now _always_ written as `primvars:normals` and never via the UsdGeomPointBased `normals` attribute. +API +--- + +- IECoreGL::PointsPrimitive : Added `renderUsesGLPoints()` method. +- IECoreGL::CurvesPrimitive : Added `renderUsesGLLines()` method. + 10.4.6.0 (relative to 10.4.5.0) ======== diff --git a/include/IECoreGL/CurvesPrimitive.h b/include/IECoreGL/CurvesPrimitive.h index 6f7d57b1a3..0f64690b26 100644 --- a/include/IECoreGL/CurvesPrimitive.h +++ b/include/IECoreGL/CurvesPrimitive.h @@ -59,6 +59,9 @@ class IECOREGL_API CurvesPrimitive : public Primitive void addPrimitiveVariable( const std::string &name, const IECoreScene::PrimitiveVariable &primVar ) override; const Shader::Setup *shaderSetup( const Shader *shader, State *state ) const override; void render( const State *currentState, IECore::TypeId style ) const override; + /// Returns `true` if `render( state )` will render the curves as `GL_LINES`, + /// and `false` if the curves will be rendered as ribbons. + bool renderUsesGLLines( const State *state ) const; /// Just renders each segment as linear with GL_LINES. void renderInstances( size_t numInstances = 1 ) const override; diff --git a/include/IECoreGL/PointsPrimitive.h b/include/IECoreGL/PointsPrimitive.h index b1e088a4ee..8d86046bf2 100644 --- a/include/IECoreGL/PointsPrimitive.h +++ b/include/IECoreGL/PointsPrimitive.h @@ -67,6 +67,10 @@ class IECOREGL_API PointsPrimitive : public Primitive void addPrimitiveVariable( const std::string &name, const IECoreScene::PrimitiveVariable &primVar ) override; const Shader::Setup *shaderSetup( const Shader *shader, State *state ) const override; void render( const State *currentState, IECore::TypeId style ) const override; + /// Returns `true` if `render( state )` will render the points as `GL_POINTS`, + /// and `false` if the curves will be rendered as geometry such as disks or + /// spheres. + bool renderUsesGLPoints( const State *state ) const; void renderInstances( size_t numInstances = 1 ) const override; //! @name StateComponents diff --git a/src/IECoreGL/CurvesPrimitive.cpp b/src/IECoreGL/CurvesPrimitive.cpp index c1bf665829..8977c0a4ca 100644 --- a/src/IECoreGL/CurvesPrimitive.cpp +++ b/src/IECoreGL/CurvesPrimitive.cpp @@ -288,6 +288,18 @@ void CurvesPrimitive::renderMode( const State *state, bool &linear, bool &ribbon ribbons = !state->get()->value(); } +bool CurvesPrimitive::renderUsesGLLines( const State *state ) const +{ + if( const auto s = state->get() ) + { + if( s->value() ) + { + return true; + } + } + return glslVersion() < 150; +} + const std::string &CurvesPrimitive::cubicLinesGeometrySource() { static std::string s = diff --git a/src/IECoreGL/PointsPrimitive.cpp b/src/IECoreGL/PointsPrimitive.cpp index 2966a85cf2..2401965604 100644 --- a/src/IECoreGL/PointsPrimitive.cpp +++ b/src/IECoreGL/PointsPrimitive.cpp @@ -305,6 +305,11 @@ void PointsPrimitive::render( const State *currentState, IECore::TypeId style ) } } +bool PointsPrimitive::renderUsesGLPoints( const State *state ) const +{ + return effectiveType( state ) == Point; +} + void PointsPrimitive::renderInstances( size_t numInstances ) const { glDrawArraysInstancedARB( GL_POINTS, 0, m_memberData->points->readable().size(), numInstances );