Quantcast
Channel: bugs, errors - openFrameworks
Viewing all articles
Browse latest Browse all 636

Instanced rendering glBufferSubData EXC_BAD_ACCESS

$
0
0

@adamtth wrote:

Hi. If I want to render more than 40000 instances I always run into this error EXC_BAD_ACCESS on glBufferSubData when I update the per instance attribute. (xcode). sometimes i can add more than 20000 but after a while i start to get this error, and after a few run i can add only 6000-8000 without EXC_BAD_ACCESS

The updateInstance() runs in the ofApp::update() function.

Mostly the mVboBox.getVbo().updateAttributeData(possize, &_size[0], _size.size()); line triggers this error sometimes the mVboBox.getVbo().updateAttributeData(posCoord, &_coord[0], _coord.size());. I check the values, and everything seems fine with the _coord and _size but i still got these errors after a few seconds.

void ofApp::updateInstance() {

      vector<float> _coord;
      vector<float> _texcoord;
      vector<float> _brightness;
      vector<float> _type;
      vector<float> _height;
      vector<float> _size;

      for (int i = 0; i < 10000; i++)
      {
             if (i < mainWordArray.size()) {
                  _texcoord.push_back(mainWordArray[i].word.x);
                  _texcoord.push_back(mainWordArray[i].word.y);

                  _coord.push_back(mainWordArray[i].x / float(PORT_WIDTH ));
                  _coord.push_back(mainWordArray[i].y / float(PORT_HEIGHT));
                   _size.push_back(mainWordArray[i].word.width);
                  _size.push_back(mainWordArray[i].word.height);
                  _height.push_back(mainWordArray[i].height / float(PORT_HEIGHT));
                 _type.push_back( 6.0 );
            }
            else {
                  _texcoord.push_back(atlas.fboAtlases[0].szo[0].x);
                  _texcoord.push_back(atlas.fboAtlases[0].szo[0].y);
                  _coord.push_back(-10.0);
                  _coord.push_back(-10.0);
                  _size.push_back(atlas.fboAtlases[0].szo[0].width);
                  _size.push_back(atlas.fboAtlases[0].szo[0].height);
                  _height.push_back(1.0);
                  _type.push_back( 6.0 );
            }
      }

      mVboBox.getVbo().updateAttributeData(posCoord, &_coord[0], _coord.size());
      mVboBox.getVbo().updateAttributeData(posheight, &_height[0], _height.size());
      mVboBox.getVbo().updateAttributeData(postexcoord, &_texcoord[0], _texcoord.size());
      mVboBox.getVbo().updateAttributeData(possize, &_size[0], _size.size());
      mVboBox.getVbo().updateAttributeData(postype, &_type[0], _type.size());
}

Posts: 5

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 636

Trending Articles