Map UBO to change its value.

This commit is contained in:
vlj 2014-08-16 00:33:47 +02:00
parent 5f6d0bd63c
commit 8b81d0ac3f

View File

@ -584,7 +584,8 @@ void IrrDriver::computeCameraMatrix(scene::ICameraSceneNode * const camnode, siz
50.,
};
float *tmp = new float[18 * 8];
glBindBuffer(GL_UNIFORM_BUFFER, SharedObject::ViewProjectionMatrixesUBO);
float *tmp = (float *) glMapBufferRange(GL_UNIFORM_BUFFER, 0, (16 * 8 + 2) * sizeof(float), GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT);
memcpy(tmp, irr_driver->getViewMatrix().pointer(), 16 * sizeof(float));
memcpy(&tmp[16], irr_driver->getProjMatrix().pointer(), 16 * sizeof(float));
@ -710,10 +711,7 @@ void IrrDriver::computeCameraMatrix(scene::ICameraSceneNode * const camnode, siz
tmp[128] = float(width);
tmp[129] = float(height);
glBindBuffer(GL_UNIFORM_BUFFER, SharedObject::ViewProjectionMatrixesUBO);
glBufferSubData(GL_UNIFORM_BUFFER, 0, (16 * 8 + 2) * sizeof(float), tmp);
delete []tmp;
glUnmapBuffer(GL_UNIFORM_BUFFER);
}