QOpenGLFramebufferObject so fast or so slow?
-
Hi,
I have problem, as topic say is FBO so fast or so slow? I don't know, but what is in following code mean:
Invert camera (its working, I have tested this on user input like Ctrl+T)
Bind FBO
Draw
Release FBO
Deinvert camera (also working, in test mean hit 2x Ctrl+T if you know what I mean)Code:
@void World::drawReflection()
{
if(!getMapChunkAt(camera->position()))
return;// invert camera float terrainHeight = getMapChunkAt(camera->position())->getHeightFromWorld(camera->position().x(), camera->position().z()); // returns height of terrain under camera camera->invertY(terrainHeight); // calc diff between camera and terrain, then reinvert it with angle camera->translate(QVector3D(), Camera::TranslateViewCenter); reflectionView = camera->viewMatrix(); // set viewMatrix to reflectionView, we need this bind to the shader // activate fbo reflection_fbo->bind(); GLfuncs->glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); GLfuncs->glDisable(GL_DEPTH_TEST); GLfuncs->glEnable(GL_CLIP_PLANE0); GLdouble plane[4] = {0.0, 1.0, 0.0, 0.0}; glClipPlane(GL_CLIP_PLANE0, plane); // delete underwater terrain // draw terrain and objects for(int tx = 0; tx < TILES; ++tx) { for(int ty = 0; ty < TILES; ++ty) { if(tileLoaded(tx, ty)) { mapTiles[tx][ty].tile->draw(MAP_DRAW_DISTANCE, camera->position()); mapTiles[tx][ty].tile->drawObjects(MAP_DRAW_DISTANCE, camera->position(), camera->viewMatrix(), camera->projectionMatrix()); } } } GLfuncs->glDisable(GL_CLIP_PLANE0); GLfuncs->glEnable(GL_DEPTH_TEST); GLfuncs->glClear(GL_DEPTH_BUFFER_BIT); reflection_fbo->release(); // deactivate fbo GLfuncs->glBindTexture(GL_TEXTURE_2D, 0); // not working anyway... to unbind texture in fbo // deinvert camera terrainHeight = getMapChunkAt(camera->position())->getHeightFromWorld(camera->position().x(), camera->position().z()); camera->invertY(terrainHeight); camera->translate(QVector3D(), Camera::TranslateViewCenter);
}@
Here is also screen:
http://ctrlv.cz/2mxYIt's paused after reflection_fbo->release(), paused with calling QMessageBox to debug...
First two message boxes have normal camera (non inverted, middle window). What should be in that window from begin is third window, and whats now in scene (first window, normal it shouldn't be there, this window can now show inverted camera, this should be in large message box)Thanks for help!