Ignore:
Timestamp:
01/07/07 03:53:52 (17 years ago)
Author:
mattausch
Message:

worked on depth peeling

File:
1 edited

Legend:

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

    r1945 r1949  
    6060        glLoadIdentity(); 
    6161 
    62         gluPerspective(60.0, (GLfloat)w/(GLfloat)h, 3, 5000.0); 
     62        //gluPerspective(60.0, (GLfloat)w/(GLfloat)h, 3, 5000.0); 
    6363        //gluPerspective(60.0, (GLfloat)w/(GLfloat)h, 0.5, 10.0); 
     64        glOrtho(-1000, 1000, -1000, 1000, 1, 1000); 
    6465} 
    6566 
     
    9293        switch(key) 
    9394        { 
    94         case ' ': 
     95        case '2': 
     96                ++ globalLinesRenderer->mMaxDepth; 
     97                cout << "max depth: " << globalLinesRenderer->mMaxDepth << endl; 
     98                return; 
     99        case '1': 
     100                -- globalLinesRenderer->mMaxDepth; 
     101                cout << "max depth: " << globalLinesRenderer->mMaxDepth << endl; 
    95102                return; 
    96103        default: 
     
    108115} 
    109116*/ 
    110 GlobalLinesRenderer::GlobalLinesRenderer(Preprocessor *preprocessor, GlRenderer *renderer):  
     117GlobalLinesRenderer::GlobalLinesRenderer(Preprocessor *preprocessor,  
     118                                                                                 GlRenderer *renderer):  
    111119mNewBuffer(NULL),  
    112120mOldBuffer(NULL),  
    113 mMaxDepth(100),  
     121mMaxDepth(0),  
    114122mRenderer(renderer),  
    115123mPreprocessor(preprocessor) 
     
    188196        AxisAlignedBox3 bbox = globalLinesRenderer->mPreprocessor->mKdTree->GetBox(); 
    189197        const Vector3 midPoint = bbox.Center(); 
    190         const Vector3 viewPoint = midPoint + Vector3(-800, 0, 0); 
     198        //const Vector3 viewPoint = midPoint + Vector3(-800, 0, 0); 
     199        const Vector3 viewPoint = midPoint + Vector3(2, 0, 0); 
    191200 
    192201        cout << "midPoint: " << midPoint << endl; 
     
    200209        gluLookAt(0, 0, 3, 0, 0, 0, 0, 1, 0); 
    201210 
    202         glDisable(GL_CULL_FACE); 
     211        //glDisable(GL_CULL_FACE); 
     212        glEnable(GL_CULL_FACE); 
    203213        glDisable(GL_LIGHTING); 
    204214        //glEnable(GL_COLOR_MATERIAL); 
     
    214224         
    215225        mNewBuffer = new RenderTexture(texWidth, texHeight, true, true); 
    216         mNewBuffer->Initialize(true, true, false, true, true, 8, 8, 8, 8);//, RenderTexture::RT_COPY_TO_TEXTURE); 
    217  
     226        //mNewBuffer->Initialize(true, true, false, true, true, 8, 8, 8, 8);//, RenderTexture::RT_COPY_TO_TEXTURE); 
     227        mNewBuffer->Initialize(true, true, false, true, true, 8, 8, 8, 8, RenderTexture::RT_COPY_TO_TEXTURE); 
     228         
    218229        mOldBuffer = new RenderTexture(texWidth, texHeight, true, true); 
    219         mOldBuffer ->Initialize(true, true, false, true, true, 8, 8, 8, 8);//, RenderTexture::RT_COPY_TO_TEXTURE); 
     230        //mOldBuffer ->Initialize(true, true, false, true, true, 8, 8, 8, 8);//, RenderTexture::RT_COPY_TO_TEXTURE); 
     231        mOldBuffer ->Initialize(true, true, false, true, true, 8, 8, 8, 8, RenderTexture::RT_COPY_TO_TEXTURE); 
    220232 
    221233        // Setup Cg 
     
    265277                glClearColor(0.1, 0.7, 0.2, 1); 
    266278                glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 
    267          
     279 
     280                glFrontFace(GL_CCW); 
     281                glCullFace(GL_BACK); 
     282                glEnable(GL_CULL_FACE); 
     283                glShadeModel(GL_FLAT); 
     284                glEnable(GL_DEPTH_TEST); 
     285                 
    268286                glMatrixMode(GL_MODELVIEW); 
    269287                glLoadIdentity(); 
     
    272290                                  0, 1, 0); 
    273291 
    274                 glEnable(GL_DEPTH_TEST);  
    275292        } 
    276293        mNewBuffer->EndCapture(); 
     
    282299                glMatrixMode(GL_MODELVIEW); 
    283300                glLoadIdentity(); 
     301                 
     302                glFrontFace(GL_CCW); 
     303                glCullFace(GL_BACK); 
     304                glEnable(GL_CULL_FACE); 
     305                glShadeModel(GL_FLAT); 
     306                glEnable(GL_DEPTH_TEST); 
     307                 
    284308                gluLookAt(viewPoint.x, viewPoint.y, viewPoint.z,  
    285309                                  midPoint.x, midPoint.y, midPoint.z,  
    286310                                  0, 1, 0); 
    287311 
    288                 glEnable(GL_DEPTH_TEST);  
    289312                glClearColor(0.6, 0.2, 0.2, 1); 
    290313        } 
     
    326349        mNewBuffer->EndCapture(); 
    327350         
    328         //mNewBuffer->Bind(); 
    329         mNewBuffer->BindDepth(); 
    330         mNewBuffer->EnableTextureTarget(); 
    331  
    332  
    333         //glBindTexture(texture_target,texID); 
    334         //const int texID = mNewBuffer->GetTextureTarget(); 
    335         //glGetTexImage(texture_target,0,texture_format,GL_FLOAT,data); 
    336 /* 
    337         for(int l = 0; l < mMaxDepth; ++ l)  
     351        //mNewBuffer->BindDepth(); 
     352        //float data[262144]; 
     353        //glGetTexImage(mNewBuffer->GetTextureTarget(), 0, mNewBuffer->texture_format, GL_FLOAT, data); 
     354        if (mNewBuffer->IsRectangleTexture()) cout << "rect" << endl; 
     355//else cout << "haga"<<endl; 
     356 
     357        for(int i = 0; i < mMaxDepth; ++ i)  
    338358        { 
    339359                // Peel another layer 
     
    348368 
    349369                        cgGLBindProgram(sCgDepthPeelingProgram); 
     370                //      cgGLBindProgram(sCgPassThroughProgram); 
    350371                        cgGLEnableProfile(sCgFragmentProfile); 
    351372                        cgGLSetTextureParameter(sTextureParam, mOldBuffer->GetDepthTextureID()); 
    352373                        cgGLEnableTextureParameter(sTextureParam); 
    353374 
    354                         //glColor3f(0,0.0,0.0); 
    355                         DrawGeometry(); 
     375                        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 
     376                        glMatrixMode(GL_MODELVIEW); 
     377                        glPushMatrix(); 
     378                        {  
     379                                //glutSolidTorus(0.25, 1, 32, 64); 
     380                                DrawGeometry(); 
     381                        } 
     382                        glPopMatrix(); 
     383 
    356384                        cgGLDisableTextureParameter(sTextureParam); 
     385                        cgGLDisableProfile(sCgFragmentProfile); 
    357386                } 
    358387                mNewBuffer->EndCapture(); 
    359388        } 
    360 */ 
     389 
     390        PrintGLerror("display 1"); 
     391 
     392        //mNewBuffer->Bind(); 
     393        mNewBuffer->BindDepth(); 
     394        mNewBuffer->EnableTextureTarget(); 
     395 
    361396 
    362397        PrintGLerror("display 2"); 
    363398        glColor3f(1,1,1); 
    364399        glBegin(GL_QUADS); 
    365     glTexCoord2f(0, 0); glVertex3f(-1, -1, -0.5f); 
    366     glTexCoord2f(1, 0); glVertex3f( 1, -1, -0.5f); 
    367     glTexCoord2f(1, 1); glVertex3f( 1,  1, -0.5f); 
    368     glTexCoord2f(0, 1); glVertex3f(-1,  1, -0.5f); 
     400    glTexCoord2f(0, 0); glVertex3f(-1000, -1000, -0.5f); 
     401    glTexCoord2f(1, 0); glVertex3f( 1000, -1000, -0.5f); 
     402    glTexCoord2f(1, 1); glVertex3f( 1000,  1000, -0.5f); 
     403    glTexCoord2f(0, 1); glVertex3f(-1000,  1000, -0.5f); 
    369404    glEnd(); 
    370         PrintGLerror("display 1"); 
    371405 
    372406    if (mNewBuffer->IsFloatTexture()) 
Note: See TracChangeset for help on using the changeset viewer.