Changeset 2664


Ignore:
Timestamp:
04/29/08 16:20:37 (16 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/Lib/Vis/Preprocessing/src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp

    r2663 r2664  
    131131                                                      mDetectEmptyViewSpace); 
    132132 
    133         mSnapErrorFrames = false; 
     133        //mSnapErrorFrames = false; 
     134        mSnapErrorFrames = true; 
    134135        mSnapPrefix = "snap/"; 
    135136        mUseForcedColors = false; 
     
    706707                for (q = 0; ((j + q) < (int)mObjects.size()) && (q < numQ); ++ q)  
    707708                { 
    708                         //glFinish(); 
    709709                        mOcclusionQueries[q]->BeginQuery(); 
    710710                         
     
    712712                 
    713713                        mOcclusionQueries[q]->EndQuery(); 
    714                         //glFinish(); 
    715714                } 
    716715                //cout << "q: " << q << endl; 
     
    14171416void GlRendererBuffer::InitGL() 
    14181417{ 
    1419         MakeCurrent();  
     1418        //MakeCurrent();  
    14201419        GlRenderer::InitGL(); 
    14211420 
     1421#if 0 
    14221422        // initialise dual depth buffer textures 
    14231423        glGenTextures(1, &frontDepthMap); 
     
    14421442        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); 
    14431443 
    1444 #if 0 
     1444 
    14451445#ifdef USE_CG 
    14461446 
     
    14801480#endif 
    14811481#endif 
    1482         DoneCurrent(); 
     1482        //DoneCurrent(); 
    14831483} 
    14841484 
     
    15141514  SetupProjection(GetWidth(), GetHeight()); 
    15151515 
    1516   cout<<"Random Pvs STATS, mPvsStatFrames="<<mPvsStatFrames<<endl; 
     1516  cout << "Random Pvs STATS, mPvsStatFrames=" << mPvsStatFrames << endl; 
    15171517   
    15181518  for (int i=0; i < mPvsStatFrames; i++) { 
     
    15371537 
    15381538 
    1539         if (mPvsErrorBuffer[i].mError > 0.0f) { 
    1540           int pvsSize; 
    1541  
    1542           float error = GetPixelError(pvsSize); 
    1543  
    1544           mPvsErrorBuffer[i].mError = error; 
    1545           mPvsErrorBuffer[i].mPvsSize = pvsSize; 
    1546  
    1547           //      emit UpdatePvsErrorItem(i, 
    1548           //                                                      mPvsErrorBuffer[i]); 
    1549           cout<<"("<<i<<" ["<<mViewPoint<<"]["<<mViewDirection<<"] "<<mPvsErrorBuffer[i].mError<<")"; 
    1550           //      swapBuffers(); 
    1551         } 
    1552          
     1539        if (mPvsErrorBuffer[i].mError > 0.0f) { 
     1540                int pvsSize; 
     1541 
     1542                float error = GetPixelError(pvsSize); 
     1543 
     1544                mPvsErrorBuffer[i].mError = error; 
     1545                mPvsErrorBuffer[i].mPvsSize = pvsSize; 
     1546 
     1547                cout<<"("<<i<<" ["<<mViewPoint<<"]["<<mViewDirection<<"] "<<mPvsErrorBuffer[i].mError<<")"; 
     1548        } 
     1549 
    15531550        err = mPvsErrorBuffer[i].mError; 
    15541551         
     
    16301627                { 
    16311628                        // compute the pixel error 
    1632                         float error = GetPixelError(pvsSize); 
     1629                        const float error = GetPixelError(pvsSize); 
    16331630 
    16341631                        mPvsErrorBuffer[i].mError = error; 
    16351632                        mPvsErrorBuffer[i].mPvsSize = pvsSize; 
    16361633 
    1637                         int pixelError = (int)mPvsErrorBuffer[i].mError * GetWidth() * GetHeight(); 
    1638  
     1634                        const int pixelError = (int)mPvsErrorBuffer[i].mError * GetWidth() * GetHeight(); 
    16391635                        if (0 && (pixelError > 0) && (pvsSize > 0))  
    16401636                        { 
    1641                                 cout << "!err: " << i << "," << mViewPoint << "," << mViewDirection << " " << mPvsErrorBuffer[i].mError * GetWidth() * GetHeight() << endl; 
     1637                                cout << "err: " << i << "," << mViewPoint << "," << mViewDirection << " "  
     1638                                         << mPvsErrorBuffer[i].mError * GetWidth() * GetHeight() << endl; 
    16421639                        } 
    16431640                } 
  • GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.h

    r2663 r2664  
    168168  virtual bool ValidViewPoint(); 
    169169   
    170   virtual float 
    171   GetPixelError(int &pvsSize); 
    172    
    173   virtual void 
    174   EvalPvsStat(); 
     170  virtual float GetPixelError(int &pvsSize); 
     171   
     172  virtual void EvalPvsStat(); 
    175173 
    176174  void PreparePvs(const ObjectPvs &pvs); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp

    r2663 r2664  
    7474QtGlRendererBuffer::MakeCurrent() 
    7575{ 
    76   makeCurrent(); 
     76        makeCurrent(); 
    7777} 
    7878 
     
    8080QtGlRendererBuffer::DoneCurrent() 
    8181{ 
    82   doneCurrent(); 
     82        doneCurrent(); 
    8383} 
    8484   
    8585 
    86 QtGlRendererBuffer::QtGlRendererBuffer(const int w, 
    87                                                                            const int h, 
     86QtGlRendererBuffer::QtGlRendererBuffer(int w, int h, 
    8887                                                                           SceneGraph *sceneGraph, 
    8988                                                                           ViewCellsManager *viewcells, 
    9089                                                                           KdTree *tree): 
    91   QGLPixelBuffer(QSize(w, h)), 
    92   GlRendererBuffer(sceneGraph, viewcells, tree) 
    93 { 
    94   mUseVbos = true; 
    95   MakeCurrent(); 
    96   InitGL(); 
    97   DoneCurrent(); 
    98 } 
    99  
    100 void 
    101 QtGlRendererBuffer::RenderPvs(const ObjectPvs &pvs) 
     90QGLPixelBuffer(QSize(w, h), QGLFormat(QGL::SampleBuffers)), 
     91GlRendererBuffer(sceneGraph, viewcells, tree) 
     92{ 
     93        mUseVbos = true; 
     94        //mUseVbos = false; 
     95         
     96        MakeCurrent(); 
     97        glViewport(0, 0, w, h); 
     98    glMatrixMode(GL_PROJECTION); 
     99    glLoadIdentity(); 
     100    glOrtho(-1, 1, -1, 1, -99, 99); 
     101    //glTranslatef(-0.5f, -0.5f, 0.0f); 
     102    glMatrixMode(GL_MODELVIEW); 
     103    glLoadIdentity(); 
     104 
     105        InitGL(); 
     106        DoneCurrent(); 
     107} 
     108 
     109 
     110void QtGlRendererBuffer::RenderPvs(const ObjectPvs &pvs) 
    102111{ 
    103112        PreparePvs(pvs); 
     
    112121 
    113122// reimplemented here so that we can snap the error windows 
    114 float 
    115 QtGlRendererBuffer::GetPixelError(int &pvsSize) 
    116 { 
    117  
     123float QtGlRendererBuffer::GetPixelError(int &pvsSize) 
     124{ 
    118125        MakeCurrent(); 
    119  
     126         
     127/* 
     128SetupCamera(); 
     129RenderScene(); 
     130*/ 
    120131        float pErrorPixels = -1.0f; 
    121132 
     
    127138 
    128139        if (viewcell == NULL) 
    129                 return 0.0f; 
     140                return -1.0f; 
    130141 
    131142        ObjectPvs pvs; 
     
    143154 
    144155        SetupCamera(); 
     156 
    145157        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); 
    146158        glColorMask(GL_FALSE, GL_TRUE, GL_FALSE, GL_FALSE); 
     
    156168        pvsSize = pvs.GetSize(); 
    157169         
     170        if (pvsSize == 0) 
     171                return 0.0f; 
     172 
    158173        RenderPvs(pvs); 
    159174 
     
    178193        // reenable other state 
    179194        int wait = 0; 
    180          
    181195        while (0 && !query->ResultAvailable())  
    182         { 
    183196                wait ++; 
    184         } 
    185  
    186  
     197         
    187198        pixelCount = query->GetQueryResult(); 
    188199 
    189         if ((pixelCount > 0) && (pvsSize > 0)) 
     200        if (pixelCount > 0)  
    190201        { 
    191202                cout << "vc id: " << viewcell->GetId() << " pvs: " << pvsSize << " pc: " << pixelCount << endl; 
     
    195206 
    196207 
    197         if (mSnapErrorFrames && (pixelCount > 0)) { 
     208        if (mSnapErrorFrames && (pixelCount > 0))  
     209        { 
    198210                glReadBuffer(GL_BACK); 
    199211                //glReadBuffer(GL_FRONT); 
     
    226238                glColor3f(0,1,0); 
    227239                glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); 
    228                 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 
     240                //glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 
     241                glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); 
    229242 
    230243                RenderPvs(pvs); 
     
    412425        glNormalPointer(GL_FLOAT, 0, (char *)arrayPtr + offset * sizeof(Vector3)); 
    413426        glDrawElements(GL_TRIANGLES, mIndexBufferSize, GL_UNSIGNED_INT, mIndices); 
     427 
    414428#if DYNAMIC_OBJECTS_HACK 
    415429        // handle dynamic objects 
    416430        DynamicObjectsContainer::const_iterator dit, dit_end = mDynamicObjects.end(); 
    417  
    418431 
    419432        for (dit = mDynamicObjects.begin(); dit != dit_end; ++ dit) 
     
    541554                if (mUseSpatialFilter && mRenderBoxes)  
    542555                { 
    543                         for (int i=0; i < mPvsCache.filteredBoxes.size(); ++ i) 
     556                        for (size_t i=0; i < mPvsCache.filteredBoxes.size(); ++ i) 
    544557                        { 
    545558                                RenderBox(mPvsCache.filteredBoxes[i]); 
     
    559572                        RenderIntersectable(viewcell); 
    560573                         
    561                         /*glPushMatrix(); 
    562                         glTranslatef(mViewPoint.x, mViewPoint.y, mViewPoint.z); 
    563                         glScalef(5.0f,5.0f,5.0f); 
    564                         glPushAttrib(GL_CURRENT_BIT); 
    565                         glColor3f(1.0f, 0.0f, 0.0f); 
    566                         //        gluSphere((::GLUquadric *)mSphere, 
    567                         //                              1e-3*Magnitude(mViewCellsManager->GetViewSpaceBox().Size()), 6, 6); 
    568                         glPopAttrib(); 
    569                         glPopMatrix(); 
    570                         */ 
    571574                        mWireFrame = false; 
    572575                } 
     
    575578        else  
    576579        { 
    577                 //ObjectContainer::const_iterator oi = mObjects.begin(); 
    578                 //for (; oi != mObjects.end(); oi++) 
    579                 //      RenderIntersectable(*oi); 
     580                //OcclusionQuery *query = mOcclusionQueries[0]; 
     581                //query->BeginQuery(); 
     582                 
    580583                RenderScene(); 
     584 
     585                //query->EndQuery(); 
     586                //int pixels = query->GetQueryResult(); 
     587                //cout << " pixels: " << pixels; 
    581588        } 
    582589 
     
    611618 
    612619        glColor3f(1.0f, 0.0f, 0.0f); 
    613  
    614620 
    615621        OcclusionQuery *query = mOcclusionQueries[0]; 
     
    634640 
    635641        int pixelCount = query->GetQueryResult(); 
    636         pErrorPixels = ((float)pixelCount)/(GetWidth()*GetHeight()); 
    637         if (0) cout<<"error pixels="<<pixelCount<<endl; 
     642        pErrorPixels = ((float)pixelCount) / (GetWidth() * GetHeight()); 
     643        if (0) cout << "error pixels=" << pixelCount << endl; 
    638644 
    639645        mRenderError = pErrorPixels; 
     
    23352341        // set up the pbuffer context 
    23362342        mRenderBuffer->makeCurrent(); 
    2337         /*mRenderBuffer->InitGL(); 
    2338  
    2339         glViewport(0, 0, mRenderBuffer->size().width(), mRenderBuffer->size().height()); 
    2340         glMatrixMode(GL_PROJECTION); 
    2341         glLoadIdentity(); 
    2342         glOrtho(-1, 1, -1, 1, -99, 99); 
    2343         glTranslatef(-0.5f, -0.5f, 0.0f); 
    2344         glMatrixMode(GL_MODELVIEW); 
    2345         glLoadIdentity(); 
    2346  
    2347         glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);*/ 
    2348  
     2343         
    23492344        // generate a texture that has the same size/format as the pbuffer 
    23502345        dynamicTexture = mRenderBuffer->generateDynamicTexture(); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.h

    r2657 r2664  
    5454        Q_OBJECT 
    5555public: 
    56         QtGlRendererBuffer(const int w, 
    57                 const int h, 
    58                 SceneGraph *sceneGraph, 
    59                 ViewCellsManager *viewcells, 
    60                 KdTree *tree); 
    61  
    62   ~QtGlRendererBuffer() {} 
    63  
    64   virtual void MakeCurrent(); 
    65   virtual void DoneCurrent(); 
    66  
    67   virtual int GetWidth() const { return width(); } 
    68   virtual int GetHeight() const { return height(); } 
    69  
    70   int ComputePvs() const { return 0; } 
    71  
    72   void 
    73   RenderPvs(const ObjectPvs &pvs); 
    74  
    75   float 
    76   GetPixelError(int &pvsSize); 
    77    
    78   int ComputePvs(ObjectContainer &objects, ObjectContainer &pvs) const; 
    79       
    80    
    81    
    82    
     56        QtGlRendererBuffer(int w, int h, 
     57                                           SceneGraph *sceneGraph, 
     58                                           ViewCellsManager *viewcells, 
     59                                           KdTree *tree); 
     60 
     61        ~QtGlRendererBuffer() {} 
     62 
     63        virtual void MakeCurrent(); 
     64        virtual void DoneCurrent(); 
     65 
     66        virtual int GetWidth() const { return width(); } 
     67        virtual int GetHeight() const { return height(); } 
     68 
     69        int ComputePvs() const { return 0; } 
     70 
     71        void RenderPvs(const ObjectPvs &pvs); 
     72 
     73        float GetPixelError(int &pvsSize); 
     74 
     75        int ComputePvs(ObjectContainer &objects, ObjectContainer &pvs) const; 
     76 
    8377public: 
    84   signals: 
    85   void UpdatePvsErrorItem(int i, GlRendererBuffer::PvsErrorEntry &); 
     78 
     79signals: 
     80        void UpdatePvsErrorItem(int i, GlRendererBuffer::PvsErrorEntry &); 
    8681}; 
    8782 
  • GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlViewer.cpp

    r2615 r2664  
    2424 
    2525QtGlViewer::QtGlViewer(QWidget *parent, 
    26                                            QtGlRendererWidget *renderer): 
    27   QGLWidget(parent), mRenderer(renderer) 
     26                                           QtGlRendererWidget *renderer) 
     27: QGLWidget(parent), mRenderer(renderer) 
    2828{ 
    2929        scale = 1.0f; 
     
    4242} 
    4343   
     44 
    4445QSize QtGlViewer::minimumSizeHint() const 
    4546{ 
  • GTP/trunk/Lib/Vis/Preprocessing/src/main.cpp

    r2660 r2664  
    309309        if (evalPixelError && (importRandomViewCells || frames)) 
    310310        { 
     311                if (!QGLFormat::hasOpenGL() || !QGLPixelBuffer::hasOpenGLPbuffers()) 
     312                { 
     313                        cerr << "this system does not support OpenGL/pbuffers" << endl; 
     314 
     315                        QMessageBox::information(0, "OpenGL pbuffers",  
     316                                "This system does not support OpenGL/pbuffers.", 
     317                                QMessageBox::Ok); 
     318 
     319                        return NULL; 
     320                } 
     321 
    311322                QGLFormat f; 
    312323                f.setStencil(true); 
     
    329340         
    330341        if (exportRandomViewCells) 
    331           { 
     342        { 
    332343                cout << "exporting random view cells" << endl; 
    333344                preprocessor->mViewCellsManager->ExportRandomViewCells(viewCellPointsFile); 
    334345                cout << "finished" << endl; 
    335           } 
     346        } 
    336347 
    337348        if (preprocessor->mUseGlRenderer || preprocessor->mUseGlDebugger) 
     
    348359                if (!rendererWidget)  
    349360                { 
    350                         if (!QGLFormat::hasOpenGL() || !QGLPixelBuffer::hasOpenGLPbuffers()) { 
    351                                 cout << "damn" << endl; 
     361                        if (!QGLFormat::hasOpenGL() || !QGLPixelBuffer::hasOpenGLPbuffers()) 
     362                        { 
     363                                cerr << "this system does not support OpenGL/pbuffers" << endl; 
     364 
    352365                                QMessageBox::information(0, "OpenGL pbuffers",  
    353366                                        "This system does not support OpenGL/pbuffers.", 
    354367                                        QMessageBox::Ok); 
     368 
    355369                                return NULL; 
    356370                        } 
     
    378392                } 
    379393 
    380  
    381                 /*bool evaluatePixelError; 
    382                 Environment::GetSingleton()->GetBoolValue("Preprocessor.evaluatePixelError",  evaluatePixelError); 
    383  
    384                 if (evaluatePixelError) 
    385                 { 
    386                         cout << "evaluating pixel error" << endl; 
    387                         preprocessor->ComputeRenderError(); 
    388                 }*/ 
    389  
    390394                qApp->exec(); 
    391395        } 
    392 #else // USE_QUT 
    393  
    394         //#if USE_THREADS 
    395         //      pt = new BoostPreprocessorThread(preprocessor); 
    396         //#else 
     396#else // USE_QT 
     397 
     398        /*#if USE_THREADS 
     399                pt = new BoostPreprocessorThread(preprocessor); 
     400        #else 
    397401                // use a dummy thread 
    398402                pt = new DummyPreprocessorThread(preprocessor); 
    399         //#endif 
     403        #endif 
     404        */ 
    400405#endif 
    401406 
Note: See TracChangeset for help on using the changeset viewer.