Skip to content

Commit f19949d

Browse files
authored
Merge pull request #1347 from johnhaddon/rendersWithMethods
GL primitives : Add utilities to query OpenGL draw mode
2 parents 81339b8 + d4577bc commit f19949d

File tree

5 files changed

+30
-0
lines changed

5 files changed

+30
-0
lines changed

Changes

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ Fixes
88
- 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.
99
- 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.
1010

11+
API
12+
---
13+
14+
- IECoreGL::PointsPrimitive : Added `renderUsesGLPoints()` method.
15+
- IECoreGL::CurvesPrimitive : Added `renderUsesGLLines()` method.
16+
1117
10.4.6.0 (relative to 10.4.5.0)
1218
========
1319

include/IECoreGL/CurvesPrimitive.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ class IECOREGL_API CurvesPrimitive : public Primitive
5959
void addPrimitiveVariable( const std::string &name, const IECoreScene::PrimitiveVariable &primVar ) override;
6060
const Shader::Setup *shaderSetup( const Shader *shader, State *state ) const override;
6161
void render( const State *currentState, IECore::TypeId style ) const override;
62+
/// Returns `true` if `render( state )` will render the curves as `GL_LINES`,
63+
/// and `false` if the curves will be rendered as ribbons.
64+
bool renderUsesGLLines( const State *state ) const;
6265
/// Just renders each segment as linear with GL_LINES.
6366
void renderInstances( size_t numInstances = 1 ) const override;
6467

include/IECoreGL/PointsPrimitive.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ class IECOREGL_API PointsPrimitive : public Primitive
6767
void addPrimitiveVariable( const std::string &name, const IECoreScene::PrimitiveVariable &primVar ) override;
6868
const Shader::Setup *shaderSetup( const Shader *shader, State *state ) const override;
6969
void render( const State *currentState, IECore::TypeId style ) const override;
70+
/// Returns `true` if `render( state )` will render the points as `GL_POINTS`,
71+
/// and `false` if the curves will be rendered as geometry such as disks or
72+
/// spheres.
73+
bool renderUsesGLPoints( const State *state ) const;
7074
void renderInstances( size_t numInstances = 1 ) const override;
7175

7276
//! @name StateComponents

src/IECoreGL/CurvesPrimitive.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,18 @@ void CurvesPrimitive::renderMode( const State *state, bool &linear, bool &ribbon
288288
ribbons = !state->get<UseGLLines>()->value();
289289
}
290290

291+
bool CurvesPrimitive::renderUsesGLLines( const State *state ) const
292+
{
293+
if( const auto s = state->get<UseGLLines>() )
294+
{
295+
if( s->value() )
296+
{
297+
return true;
298+
}
299+
}
300+
return glslVersion() < 150;
301+
}
302+
291303
const std::string &CurvesPrimitive::cubicLinesGeometrySource()
292304
{
293305
static std::string s =

src/IECoreGL/PointsPrimitive.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,11 @@ void PointsPrimitive::render( const State *currentState, IECore::TypeId style )
305305
}
306306
}
307307

308+
bool PointsPrimitive::renderUsesGLPoints( const State *state ) const
309+
{
310+
return effectiveType( state ) == Point;
311+
}
312+
308313
void PointsPrimitive::renderInstances( size_t numInstances ) const
309314
{
310315
glDrawArraysInstancedARB( GL_POINTS, 0, m_memberData->points->readable().size(), numInstances );

0 commit comments

Comments
 (0)