MCPcopy Create free account
hub / github.com/bulletphysics/bullet3 / writeTransforms

Method writeTransforms

examples/OpenGLWindow/GLInstancingRenderer.cpp:714–847  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

712}
713
714void GLInstancingRenderer::writeTransforms()
715{
716 {
717 //B3_PROFILE("b3Assert(glGetError() 1");
718 b3Assert(glGetError() == GL_NO_ERROR);
719 }
720 {
721 //B3_PROFILE("glBindBuffer");
722 glBindBuffer(GL_ARRAY_BUFFER, m_data->m_vbo);
723 }
724
725 {
726 //B3_PROFILE("glFlush()");
727 //without the flush, the glBufferSubData can spike to really slow (seconds slow)
728 glFlush();
729 }
730
731 {
732 //B3_PROFILE("b3Assert(glGetError() 2");
733 b3Assert(glGetError() == GL_NO_ERROR);
734 }
735
736#ifdef B3_DEBUG
737 {
738 //B3_PROFILE("m_data->m_totalNumInstances == totalNumInstances");
739
740 int totalNumInstances = 0;
741 for (int k = 0; k < m_graphicsInstances.size(); k++)
742 {
743 b3GraphicsInstance* gfxObj = m_graphicsInstances[k];
744 totalNumInstances += gfxObj->m_numGraphicsInstances;
745 }
746 b3Assert(m_data->m_totalNumInstances == totalNumInstances);
747 }
748#endif //B3_DEBUG
749
750 int POSITION_BUFFER_SIZE = (m_data->m_totalNumInstances * sizeof(float) * 4);
751 int ORIENTATION_BUFFER_SIZE = (m_data->m_totalNumInstances * sizeof(float) * 4);
752 int COLOR_BUFFER_SIZE = (m_data->m_totalNumInstances * sizeof(float) * 4);
753 // int SCALE_BUFFER_SIZE = (totalNumInstances*sizeof(float)*4);
754
755#if 1
756 {
757 // printf("m_data->m_totalNumInstances = %d\n", m_data->m_totalNumInstances);
758 {
759 //B3_PROFILE("glBufferSubData pos");
760 glBufferSubData(GL_ARRAY_BUFFER, m_data->m_maxShapeCapacityInBytes, m_data->m_totalNumInstances * sizeof(float) * 4,
761 &m_data->m_instance_positions_ptr[0]);
762 }
763 {
764 // B3_PROFILE("glBufferSubData orn");
765 glBufferSubData(GL_ARRAY_BUFFER, m_data->m_maxShapeCapacityInBytes + POSITION_BUFFER_SIZE, m_data->m_totalNumInstances * sizeof(float) * 4,
766 &m_data->m_instance_quaternion_ptr[0]);
767 }
768 {
769 // B3_PROFILE("glBufferSubData color");
770 glBufferSubData(GL_ARRAY_BUFFER, m_data->m_maxShapeCapacityInBytes + POSITION_BUFFER_SIZE + ORIENTATION_BUFFER_SIZE, m_data->m_totalNumInstances * sizeof(float) * 4,
771 &m_data->m_instance_colors_ptr[0]);

Callers 15

updateTextureMethod · 0.45
syncPhysicsToGraphicsMethod · 0.45
stepSimulationMethod · 0.45
renderSceneMethod · 0.45
mainFunction · 0.45
TutorialMethod · 0.45
stepSimulationMethod · 0.45
initPhysicsMethod · 0.45
mouseButtonCallbackMethod · 0.45
createBroadphaseMethod · 0.45

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected