OSGDVRClipper.cpp File Reference

#include <OSGDVRClipObjects.h>
#include <OSGDVRTriangle.h>
#include <OSGDVRClipper.h>
#include <OSGDVRVolume.h>
#include <OSGDVRRenderSlice.h>
#include <malloc.h>
#include <stdlib.h>

Go to the source code of this file.

Namespaces

namespace  osg

Functions

static void OSG_APIENTRY errorCallback (GLenum errorCode)
static void OSG_APIENTRY beginCallback (GLenum which, void *data)
static void OSG_APIENTRY endCallback (void *data)
static void OSG_APIENTRY vertexCallback (GLvoid *vertexData, void *data)
static void OSG_APIENTRY vertexCombineCallback (GLdouble *, GLdouble **, GLfloat *, GLdouble **, void *data)
void OSG_APIENTRY vertexCombineCallback (GLdouble *coords, GLdouble *vertexData[4], GLfloat weight[4], GLdouble **dataOut, void *data)


Function Documentation

void OSG_APIENTRY errorCallback ( GLenum  errorCode  )  [static]

Definition at line 461 of file OSGDVRClipper.cpp.

References SFATAL.

Referenced by osg::DVRClipper::initialize().

00462 {
00463     SFATAL << "Error " 
00464            << gluErrorString(errorCode) 
00465            << " occured during tesselation!" 
00466            << std::endl;
00467 }

void OSG_APIENTRY beginCallback ( GLenum  which,
void *  data 
) [static]

Definition at line 469 of file OSGDVRClipper.cpp.

References osg::DVRRenderSlice::directRender, osg::DVRRenderSlicePrimitive::type, and osg::DVRRenderSlicePrimitive::vertices.

Referenced by osg::DVRClipper::initialize().

00470 {
00471     DVRRenderSlice *sliceData = (DVRRenderSlice *) data; 
00472   
00473     if(sliceData->directRender)
00474     {
00475         glBegin(which);
00476     }
00477     else
00478     {
00479         DVRRenderSlicePrimitive *newPrimitive = new DVRRenderSlicePrimitive();
00480 
00481         newPrimitive->vertices.reserve(3); 
00482 
00483         newPrimitive->type = which;
00484 
00485         sliceData->push_back(newPrimitive);
00486     }
00487 }

void OSG_APIENTRY endCallback ( void *  data  )  [static]

Definition at line 489 of file OSGDVRClipper.cpp.

References osg::DVRRenderSlice::directRender.

Referenced by osg::DVRClipper::initialize().

00490 {
00491     DVRRenderSlice *sliceData = (DVRRenderSlice *) data; 
00492 
00493     if(sliceData->directRender)
00494     {
00495         glEnd();
00496     }
00497 }

void OSG_APIENTRY vertexCallback ( GLvoid *  vertexData,
void *  data 
) [static]

Definition at line 499 of file OSGDVRClipper.cpp.

References osg::DVRRenderSlice::directRender, GLdouble, osg::DVRRenderSlice::orientation, osg::DVRRenderSlice::UNDEFINED, osg::DVRRenderSlice::XY, osg::DVRRenderSlice::XZ, and osg::DVRRenderSlice::YZ.

Referenced by osg::DVRClipper::initialize().

00500 {
00501     GLdouble       *v         = (GLdouble       *) vertexData;
00502 
00503     DVRRenderSlice *sliceData = (DVRRenderSlice *) data; 
00504 
00505     if(sliceData->directRender)
00506     {
00507         switch(sliceData->orientation)
00508         {
00509             case DVRRenderSlice::UNDEFINED: // 3D texture
00510                 glTexCoord3dv(&v[3]);
00511                 break;
00512 
00513             case DVRRenderSlice::XY:
00514                 glTexCoord2d(v[3], v[4]);
00515                 break;
00516 
00517             case DVRRenderSlice::XZ:
00518                 glTexCoord2d(v[3], v[5]);
00519             break;
00520 
00521             case DVRRenderSlice::YZ:
00522                 glTexCoord2d(v[4], v[5]);
00523                 break;
00524 
00525             default:
00526                 break;
00527         }
00528         glVertex3dv(v);
00529     }
00530     else
00531     {
00532         sliceData->back()->vertices.push_back(v);
00533     }
00534 }

static void OSG_APIENTRY vertexCombineCallback ( GLdouble ,
GLdouble **  ,
GLfloat *  ,
GLdouble **  ,
void *  data 
) [static]

void OSG_APIENTRY vertexCombineCallback ( GLdouble coords,
GLdouble vertexData[4],
GLfloat  weight[4],
GLdouble **  dataOut,
void *  data 
)

Definition at line 536 of file OSGDVRClipper.cpp.

References FDEBUG, GLdouble, osg::DVRRenderSlice::maxVertexCombineData, osg::DVRRenderSlice::numPerVertexData, osg::DVRRenderSlice::numVertexCombineData, and osg::DVRRenderSlice::vertexCombineData.

00541 {
00542     DVRRenderSlice *sliceData = (DVRRenderSlice *) data;
00543 
00544     // allocate additional memory if neccessary
00545     if(sliceData->maxVertexCombineData <= sliceData->numVertexCombineData)
00546     {
00547         if(sliceData->maxVertexCombineData == 0)
00548             sliceData->maxVertexCombineData = 2;
00549         else
00550             sliceData->maxVertexCombineData *= 2;
00551 
00552         sliceData->vertexCombineData = 
00553             (GLdouble *) realloc(sliceData->vertexCombineData,
00554                                  (6                              + 
00555                                   sliceData->numPerVertexData)   * 
00556                                  sliceData->maxVertexCombineData * 
00557                                  sizeof(GLdouble));
00558 
00559         FDEBUG(("realloc vd %i\n",sliceData->numVertexCombineData));
00560     }
00561     
00562     GLdouble *vertex = 
00563         &(sliceData->vertexCombineData[
00564               (6 + sliceData->numPerVertexData) *
00565               sliceData->numVertexCombineData   ]);
00566 
00567     sliceData->numVertexCombineData++;
00568   
00569     vertex[0] = coords[0];
00570     vertex[1] = coords[1];
00571     vertex[2] = coords[2];
00572 
00573     // linearly interpolate per vertex data (texcoords, color, etc.)
00574     // there is at least one 3D texture coordinate given, that is 
00575     // numPerVertexData == 0 
00576 
00577     for(UInt32 i = 0; i < 3+sliceData->numPerVertexData; i++)
00578     {
00579         vertex[i+3] = 0.0;
00580     }
00581 
00582     for(UInt32 j = 0; j < 4; j++)
00583     {
00584         // this should never ever happen according to the GLU specification...
00585         if(vertexData[j] == NULL)
00586             continue;
00587 
00588         for(UInt32 i = 0; i < 3+sliceData->numPerVertexData; i++)
00589         {
00590             vertex[i + 3] += weight[j] * vertexData[j][i + 3];
00591         }
00592     }
00593 
00594     *dataOut = vertex;
00595 }


Generated on Mon Mar 17 12:02:33 2008 for OpenSG by  doxygen 1.5.5