c++ - OpenGL: dynamically change loaded vertices -
used: qt 5.8 , qopenglxxx classes. opengl: core 3.3.
i'm drawing sphere , projecting plots of functions on (riemmann sphere). user may change radius dynamically slider, i'm unsure vertices of evaluated , projected function in case. see 2 options:
- use mapping of vbo data , modify data. or use glbuffersubdata.
- remove vbo , create again updated plot info.
there @ least 400 vertices, might more, question of performance crucial (well, it's crucial everywhere, though). think?
i've implemented first option qopenglbuffer::map() , worked great. given options, it's 1 not allocate/deallocate memory merely maps on cpu memory, so, think, case it's perfect. code sort of this:
void sphereradiuschanged(float new_radius) { m_vbo.bind(); vertexclass* vbo_data = static_cast<vertexclass*>( m_vbo.map(qopenglbuffer::writeonly) ); if(vbo_data == nullptr) { ... } // here make necessary transformations. ... m_vbo.unmap(); m_vbo.release(); } probably before you'll have make qopenglwidget's context current. function executed inside class's method, didn't it.
Comments
Post a Comment