GLBVRender.cc

Go to the documentation of this file.
00001 #include <gra/render/GLBVRender.h>
00002 #include <esg/geometry/FDH14.h>
00003 #include <esg/geometry/FDH6.h>
00004 #include <gra/camera/CameraGL.h>
00005 
00006 using namespace gra;
00007 
00008 void GLBVRender::_render(Shader&           shader,
00009                          FrameBuffer&      fb,
00010                          Camera&           camera,
00011                          Scene&            scene)
00012 {
00013     /*
00014      * first render original objects
00015      */
00016     
00017     if (_showObjects) {
00018         GLRender::_render(shader, fb, camera, scene);
00019     } else {
00020         /*
00021          * This render requires an OpenGL camera (CameraGL class).
00022          * Therefore we have to instantiate it from the general camera.
00023          * Although the OpenGL camera is not furher used, its instantiation
00024          * updates the OpenGL projection and transformation matrices.
00025          */
00026         CameraGL cameraGL(camera);
00027     }
00028 
00029     /*
00030      * then render volumes transparently
00031      */
00032 
00033     if (_useDisplayList && _bvDisplayList) {
00034         glCallList(_bvDisplayList);
00035         return;
00036     }
00037 
00038     if (_useDisplayList) {
00039         _bvDisplayList = glGenLists(1);
00040         glNewList(_bvDisplayList, GL_COMPILE_AND_EXECUTE);
00041     }
00042 
00043     GLboolean depthMask;
00044     bool      haveTransp = (_bvTransp.avgValue() > 0.0) ? true : false;
00045 
00046     if (haveTransp) {
00047         glEnable(GL_BLEND);
00048         glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
00049         glGetBooleanv(GL_DEPTH_WRITEMASK, &depthMask);
00050         glDepthMask(GL_FALSE);
00051     }
00052 
00053     Geometry * pGeom;
00054     Shape    * pShape;
00055     BVExplorer bvExplorer(_depth);
00056     bvExplorer.explore(*(scene.root()));
00057     while ((pGeom = bvExplorer.result())) {
00058         pShape = new Shape();
00059         pShape->setPrivateGeometry(pGeom);
00060         pShape->appendPrivateMaterial(_bvColor.clone());
00061         if (haveTransp) pShape->appendPrivateMaterial(_bvTransp.clone());
00062         shader.setRenderedShape(pShape, NULL);
00063         // shader.illuminatePoint() does nothing and then it's omitted
00064         delete pShape;
00065     }
00066 
00067     if (haveTransp) {
00068         glDisable(GL_BLEND);
00069         glDepthMask(depthMask);
00070     }
00071     
00072     if (_useDisplayList) glEndList();
00073 }

Generated on Tue Nov 21 15:11:42 2006 for gra by  doxygen 1.4.6