| 134 | } |
| 135 | |
| 136 | void SpherePrimitive::renderInstances( size_t numInstances ) const |
| 137 | { |
| 138 | if( !m_vertIdsBuffer ) |
| 139 | { |
| 140 | // we don't build the actual buffer until now, because in the constructor we're not guaranteed |
| 141 | // a valid GL context. |
| 142 | CachedConverterPtr cachedConverter = CachedConverter::defaultCachedConverter(); |
| 143 | m_vertIdsBuffer = IECore::runTimeCast<const Buffer>( cachedConverter->convert( m_vertIds.get() ) ); |
| 144 | } |
| 145 | |
| 146 | Buffer::ScopedBinding indexBinding( *m_vertIdsBuffer, GL_ELEMENT_ARRAY_BUFFER ); |
| 147 | glDrawElementsInstancedARB( GL_TRIANGLES, m_vertIds->readable().size(), GL_UNSIGNED_INT, nullptr, numInstances ); |
| 148 | } |
| 149 | |
| 150 | Imath::Box3f SpherePrimitive::bound() const |
| 151 | { |