Ignore:
Timestamp:
01/10/07 18:20:53 (17 years ago)
Author:
mattausch
Message:

worked on global lines

File:
1 edited

Legend:

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

    r1963 r1964  
    2828static CGprofile sCgFragmentProfile; 
    2929static CGparameter sTextureParam; 
     30static CGparameter sTexWidthParam;  
     31static CGparameter sStepSizeParam; 
    3032 
    3133GlobalLinesRenderer *globalLinesRenderer = NULL; 
    32  
    33 //static int texWidth = 32; 
    34 //static int texHeight = 32; 
    35 static int texWidth = 256; 
    36 static int texHeight = 256; 
    3734 
    3835static bool isDepth = true; 
     
    137134 
    138135                        ++ globalLinesRenderer->mMaxDepth; 
    139                         globalLinesRenderer->ApplyDepthPeeling(rays, Beam(), 0); 
     136                        globalLinesRenderer->ApplyDepthPeeling(rays); 
    140137 
    141138                        cout << "max depth: " << globalLinesRenderer->mMaxDepth << endl; 
     
    150147                        cout << "max depth: " << globalLinesRenderer->mMaxDepth << endl; 
    151148                         
    152                         globalLinesRenderer->ApplyDepthPeeling(rays, Beam(), 0); 
     149                        globalLinesRenderer->ApplyDepthPeeling(rays); 
    153150                        CLEAR_CONTAINER(rays); 
    154151                        return; 
     
    156153        case '3': 
    157154                { 
    158                         //globalLinesRenderer->ApplyDepthPeeling(Beam(), 0); 
    159155                        globalLinesRenderer->ExportDepthBuffer(); 
    160                          
    161156                        return; 
    162157                } 
    163158        case '4': 
    164159                { 
    165                         //globalLinesRenderer->ApplyDepthPeeling(Beam(), 0); 
    166160                        globalLinesRenderer->ExportItemBuffer(); 
    167                          
    168161                        return; 
    169162                } 
     
    176169                { 
    177170                        VssRayContainer rays; 
    178                         globalLinesRenderer->ApplyDepthPeeling(rays, Beam(), 0); 
     171                        globalLinesRenderer->ApplyDepthPeeling(rays); 
    179172                        VssRayContainer outRays; 
    180173                        VssRayContainer::const_iterator vit, vit_end = rays.end(); 
     
    197190                { 
    198191                        VssRayContainer rays; 
    199                         globalLinesRenderer->ApplyDepthPeeling(rays, Beam(), 0); 
     192                        globalLinesRenderer->ApplyDepthPeeling(rays); 
    200193                        CLEAR_CONTAINER(rays); 
    201194                        return; 
     
    219212 
    220213GlobalLinesRenderer::GlobalLinesRenderer(Preprocessor *preprocessor,  
    221                                                                                  GlRenderer *renderer):  
     214                                                                                 GlRenderer *renderer, 
     215                                                                                 const float mTexHeight, 
     216                                                                                 const float mTexWidth, 
     217                                                                                 const float eps):  
    222218mNewTexture(NULL),  
    223219mOldTexture(NULL),  
    224220mMaxDepth(0),  
    225221mRenderer(renderer),  
    226 mPreprocessor(preprocessor) 
    227 { 
    228 } 
     222mPreprocessor(preprocessor), 
     223mTexHeight(mTexHeight), 
     224mTexWidth(mTexWidth), 
     225mEpsilon(eps) 
     226{ 
     227} 
     228 
     229 
     230GlobalLinesRenderer::GlobalLinesRenderer(Preprocessor *preprocessor,  
     231                                                                                 GlRenderer *renderer): 
     232mNewTexture(NULL),  
     233mOldTexture(NULL),  
     234mMaxDepth(0),  
     235mRenderer(renderer),  
     236mPreprocessor(preprocessor), 
     237mTexHeight(128), 
     238mTexWidth(128), 
     239mEpsilon(0.0001) 
     240{} 
    229241 
    230242 
     
    279291 
    280292  
    281 void GlobalLinesRenderer::CastGlobalLines(Beam &beam, const int samples) 
    282 { 
    283         VssRayContainer rays; 
    284  
    285         // bind pixel shader implementing the front depth buffer functionality 
    286         ApplyDepthPeeling(rays, beam, samples); 
    287 } 
    288  
    289  
    290 void GlobalLinesRenderer::RenderObject(Intersectable *obj) 
    291 { 
    292         mRenderer->RenderIntersectable(obj); 
    293 } 
    294  
    295  
    296 void GlobalLinesRenderer::DrawGeometry() 
    297 {  
    298         glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 
    299         glMatrixMode(GL_MODELVIEW); 
    300  
    301         glPushMatrix(); 
    302         {  
    303                 //glLoadIdentity(); 
    304                 ObjectContainer::const_iterator oit, oit_end = mPreprocessor->mObjects.end(); 
    305  
    306                 Intersectable::NewMail(); 
    307  
    308                 for (oit = mPreprocessor->mObjects.begin(); oit != oit_end; ++ oit) 
    309                 { 
    310                         //cout << (*oit)->GetId() << " "; 
    311                         RenderObject(*oit); 
    312                 } 
    313         } 
    314         glPopMatrix(); 
    315 } 
    316  
    317  
    318 void GlobalLinesRenderer::SwitchRenderTextures() 
    319 { 
    320         RenderTexture *buffer = mOldTexture; 
    321         mOldTexture = mNewTexture; 
    322         mNewTexture = buffer; 
    323 } 
    324  
    325  
    326 void GlobalLinesRenderer::ComputeLookAt(const float alpha,  
    327                                                                                 const float beta, 
    328                                                                                 Vector3 &eye,  
    329                                                                                 Vector3 &up,  
    330                                                                                 Vector3 left) 
    331 { 
    332         //float x = cos(alpha); 
    333         //float y = sin(alpha); 
    334         eye.x = sin(alpha) * cos(beta); 
    335         eye.y = sin(alpha) * sin(beta); 
    336         eye.z = cos(beta); 
    337  
    338         eye.RightHandedBase(up, left); 
    339 } 
    340  
    341  
    342 void GlobalLinesRenderer::InitGl() 
    343 { 
    344         InitDevIl(); 
    345  
    346     glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE); 
    347         glutInitWindowPosition(50, 50); 
    348         glutInitWindowSize(512, 512); 
    349         glutCreateWindow("TestRenderDepthTexture");   
    350  
    351         int err = glewInit(); 
    352         if (GLEW_OK != err) 
    353         { 
    354                 // problem: glewInit failed, something is seriously wrong 
    355                 fprintf(stderr, "GLEW Error: %s\n", glewGetErrorString(err)); 
    356                 exit(-1); 
    357         }   
    358          
    359         glutKeyboardFunc(Keyboard); 
    360         glutDisplayFunc(Display); 
    361         glutIdleFunc(Idle); 
    362         glutReshapeFunc(Reshape); 
    363  
    364         Reshape(512, 512); 
    365         glMatrixMode(GL_MODELVIEW); 
    366         glLoadIdentity(); 
    367  
    368         // initialise the receiving buffers 
    369         mNewDepthBuffer = new float[texWidth * texHeight]; 
    370         mNewItemBuffer = new unsigned char[texWidth * texHeight * 4]; 
    371  
    372         mOldDepthBuffer = new float[texWidth * texHeight]; 
    373     mOldItemBuffer = new unsigned char[texWidth * texHeight * 4]; 
    374  
    375         for (int i = 0; i < texWidth * texHeight; ++ i) 
    376         { 
    377                 mNewDepthBuffer[i] = 1; 
    378                 mOldDepthBuffer[i] = 1; 
    379  
    380                 mNewItemBuffer[i * 4]     = 255; 
    381                 mNewItemBuffer[i * 4 + 1] = 255; 
    382                 mNewItemBuffer[i * 4 + 2] = 255; 
    383                 mNewItemBuffer[i * 4 + 3] = 255; 
    384  
    385                 mOldItemBuffer[i * 4]     = 255; 
    386                 mOldItemBuffer[i * 4 + 1] = 255; 
    387                 mOldItemBuffer[i * 4 + 2] = 255; 
    388                 mOldItemBuffer[i * 4 + 3] = 255; 
    389         } 
    390  
     293void GlobalLinesRenderer::InitScene(const float alpha, const float beta) 
     294{ 
    391295        AxisAlignedBox3 bbox = globalLinesRenderer->mPreprocessor->mKdTree->GetBox(); 
    392296         
     297        const float sceneSize = Magnitude(bbox.Diagonal()); 
     298 
     299        // compute the center of the scene 
    393300        Vector3 midPoint = bbox.Center(); 
    394301         
    395         const float sceneSize = Magnitude(bbox.Diagonal()); 
    396         mViewPoint = midPoint + Vector3(0.5 * sceneSize, 0, 0.5 * sceneSize); 
    397          
     302        // add a small offset to provide some randomness in the sampling 
     303        Vector3 offset(Random(sceneSize * 1e-3f),  
     304                                   Random(sceneSize * 1e-3f),  
     305                                   Random(sceneSize * 1e-3f)); 
     306 
     307        midPoint += offset; 
     308                 
     309        mNear = 1; 
     310        mFar = sceneSize * 2; 
     311        mWidth = sceneSize; 
     312 
     313        ComputeLookAt(alpha,  
     314                                  beta, 
     315                                  mEyeVec,  
     316                                  mUpVec, 
     317                                  mLeftVec); 
     318         
     319        mViewPoint = midPoint - 0.5f * sceneSize * mEyeVec; 
     320 
    398321        cout << "mid point: " << midPoint << endl; 
    399322        cout << "view point: " << mViewPoint << endl; 
    400323        cout << "scene: " << bbox << endl; 
    401324 
    402         mNear = 1; 
    403         mFar = sceneSize * 2; 
    404         mWidth = sceneSize; 
    405  
    406         mEyeVec = Normalize(midPoint - mViewPoint); 
    407         mEyeVec.RightHandedBase(mUpVec, mLeftVec); 
    408  
    409         /*gluLookAt(mViewPoint.x, mViewPoint.y, mViewPoint.z,  
    410                           midPoint.x, midPoint.y, midPoint.z,  
    411                           0, 1, 0); 
    412 */ 
    413         gluLookAt(0, 0, 3, 0, 0, 0, 0, 1, 0); 
    414  
    415         //glDisable(GL_CULL_FACE); 
    416         glEnable(GL_CULL_FACE); 
    417         glDisable(GL_LIGHTING); 
    418         glDisable(GL_COLOR_MATERIAL); 
    419         glEnable(GL_DEPTH_TEST);  
    420         glClearColor(0.1, 0.2, 0.3, 1); 
    421          
    422         // A square, mipmapped, anisotropically filtered 8-bit RGBA texture with 
    423         // depth and stencil. 
    424         // Note that RT_COPY_TO_TEXTURE is required for depth textures on ATI hardware 
    425          
    426         mNewTexture = new RenderTexture(texWidth, texHeight, true, true); 
    427         //mNewTexture->Initialize(true, true, false, true, true, 8, 8, 8, 8);//, RenderTexture::RT_COPY_TO_TEXTURE); 
    428         mNewTexture->Initialize(true, true, false, true, true, 8, 8, 8, 8, RenderTexture::RT_COPY_TO_TEXTURE); 
    429          
    430         mOldTexture = new RenderTexture(texWidth, texHeight, true, true); 
    431         //mOldTexture ->Initialize(true, true, false, true, true, 8, 8, 8, 8);//, RenderTexture::RT_COPY_TO_TEXTURE); 
    432         mOldTexture ->Initialize(true, true, false, true, true, 8, 8, 8, 8, RenderTexture::RT_COPY_TO_TEXTURE); 
    433  
    434         // Setup Cg 
    435         cgSetErrorCallback(cgErrorCallback); 
    436  
    437         // Create cgContext. 
    438         sCgContext = cgCreateContext(); 
    439  
    440         // get the best profile for this hardware 
    441         sCgFragmentProfile = cgGLGetLatestProfile(CG_GL_FRAGMENT); 
    442          
    443         //assert(sCgFragmentProfile != CG_PROFILE_UNKNOWN); 
    444         cgGLSetOptimalOptions(sCgFragmentProfile); 
    445  
    446         sCgDepthPeelingProgram =  
    447                 cgCreateProgramFromFile(sCgContext,  
    448                                                                 CG_SOURCE, 
    449                                                                 mNewTexture->IsRectangleTexture() ?  
    450                                                                 "../src/depth_peelingRect.cg" : "../src/depth_peeling2d.cg",  
    451                                                                 GLEW_ARB_fragment_program ? CG_PROFILE_ARBFP1 : CG_PROFILE_FP30, 
    452                                                                 NULL, 
    453                                                                 NULL); 
    454  
    455         if(sCgDepthPeelingProgram != NULL) 
    456         { 
    457                 cgGLLoadProgram(sCgDepthPeelingProgram); 
    458                 sTextureParam = cgGetNamedParameter(sCgDepthPeelingProgram, "depthTex");   
    459         } 
    460  
    461         sCgPassThroughProgram =  
    462                 cgCreateProgramFromFile(sCgContext,  
    463                                                                 CG_SOURCE, 
    464                                                                 "../src/passthrough.cg",  
    465                                                                 GLEW_ARB_fragment_program ? CG_PROFILE_ARBFP1 : CG_PROFILE_FP30, 
    466                                                                 NULL, 
    467                                                                 NULL); 
    468  
    469         if(sCgPassThroughProgram != NULL) 
    470         { 
    471                 cgGLLoadProgram(sCgPassThroughProgram); 
    472         } 
    473  
    474     // setup the rendering context for the RenderTexture 
     325         // setup the rendering context for the RenderTexture 
    475326        mNewTexture->BeginCapture(); 
    476327        { 
    477                 //Reshape(texWidth, texHeight); 
    478                 glViewport(0, 0, texWidth, texHeight); 
     328                //Reshape(mTexWidth, mTexHeight); 
     329                glViewport(0, 0, mTexWidth, mTexHeight); 
    479330                SetFrustum(mWidth, mWidth, mNear, mFar); 
    480331 
     
    496347                gluLookAt(mViewPoint.x, mViewPoint.y, mViewPoint.z,  
    497348                                  midPoint.x, midPoint.y, midPoint.z,  
    498                                   0, 1, 0); 
     349                                  mUpVec.x, mUpVec.y, mUpVec.z); 
    499350 
    500351        } 
     
    507358                glClearColor(1, 1, 1, 1); 
    508359        
    509                 //Reshape(texWidth, texHeight); 
    510                 glViewport(0, 0, texWidth, texHeight); 
     360                //Reshape(mTexWidth, mTexHeight); 
     361                glViewport(0, 0, mTexWidth, mTexHeight); 
    511362                SetFrustum(mWidth, mWidth, mNear, mFar); 
    512363 
     
    525376                gluLookAt(mViewPoint.x, mViewPoint.y, mViewPoint.z,  
    526377                                  midPoint.x, midPoint.y, midPoint.z,  
    527                                   0, 1, 0); 
    528  
    529                 //SetFrustum(sceneSize, sceneSize, 1, sceneSize); 
     378                                  mUpVec.x, mUpVec.y, mUpVec.z); 
    530379        } 
    531380        mOldTexture->EndCapture(); 
     381 
     382        cout << "eye: " << mEyeVec << " left: " << mLeftVec << " up: " << mUpVec << endl; 
     383} 
     384 
     385 
     386void GlobalLinesRenderer::CastGlobalLines(const float alpha,  
     387                                                                                  const float beta,  
     388                                                                                  //const int samples, 
     389                                                                                  VssRayContainer &rays) 
     390{ 
     391        InitScene(alpha, beta); 
     392 
     393        // bind pixel shader implementing the front depth buffer functionality 
     394        ApplyDepthPeeling(rays); 
     395} 
     396 
     397 
     398void GlobalLinesRenderer::RenderObject(Intersectable *obj) 
     399{ 
     400        mRenderer->RenderIntersectable(obj); 
     401} 
     402 
     403 
     404void GlobalLinesRenderer::DrawGeometry() 
     405{  
     406        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 
     407        glMatrixMode(GL_MODELVIEW); 
     408 
     409        glPushMatrix(); 
     410        {  
     411                //glLoadIdentity(); 
     412                ObjectContainer::const_iterator oit, oit_end = mPreprocessor->mObjects.end(); 
     413 
     414                Intersectable::NewMail(); 
     415 
     416                for (oit = mPreprocessor->mObjects.begin(); oit != oit_end; ++ oit) 
     417                { 
     418                        //cout << (*oit)->GetId() << " "; 
     419                        RenderObject(*oit); 
     420                } 
     421        } 
     422        glPopMatrix(); 
     423} 
     424 
     425 
     426void GlobalLinesRenderer::SwitchRenderTextures() 
     427{ 
     428        RenderTexture *buffer = mOldTexture; 
     429        mOldTexture = mNewTexture; 
     430        mNewTexture = buffer; 
     431} 
     432 
     433 
     434void GlobalLinesRenderer::ComputeLookAt(const float alpha,  
     435                                                                                const float beta, 
     436                                                                                Vector3 &eye,  
     437                                                                                Vector3 &up,  
     438                                                                                Vector3 &left) 
     439{ 
     440        //float x = cos(alpha); 
     441        //float y = sin(alpha); 
     442        eye.x = sin(alpha) * cos(beta); 
     443        eye.y = sin(alpha) * sin(beta); 
     444        eye.z = cos(alpha); 
     445 
     446        //eye = Normalize(eye); 
     447        eye.RightHandedBase(up, left); 
     448} 
     449 
     450 
     451void GlobalLinesRenderer::InitGl() 
     452{ 
     453        InitDevIl(); 
     454 
     455    glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE); 
     456        glutInitWindowPosition(50, 50); 
     457        glutInitWindowSize(512, 512); 
     458        glutCreateWindow("TestRenderDepthTexture");   
     459 
     460        int err = glewInit(); 
     461        if (GLEW_OK != err) 
     462        { 
     463                // problem: glewInit failed, something is seriously wrong 
     464                fprintf(stderr, "GLEW Error: %s\n", glewGetErrorString(err)); 
     465                exit(-1); 
     466        }   
     467         
     468        glutKeyboardFunc(Keyboard); 
     469        glutDisplayFunc(Display); 
     470        glutIdleFunc(Idle); 
     471        glutReshapeFunc(Reshape); 
     472 
     473        Reshape(512, 512); 
     474        glMatrixMode(GL_MODELVIEW); 
     475        glLoadIdentity(); 
     476 
     477        // initialise the receiving buffers 
     478        mNewDepthBuffer = new float[mTexWidth * mTexHeight]; 
     479        mNewItemBuffer = new unsigned char[mTexWidth * mTexHeight * 4]; 
     480 
     481        mOldDepthBuffer = new float[mTexWidth * mTexHeight]; 
     482    mOldItemBuffer = new unsigned char[mTexWidth * mTexHeight * 4]; 
     483 
     484        for (int i = 0; i < mTexWidth * mTexHeight; ++ i) 
     485        { 
     486                mNewDepthBuffer[i] = 1; 
     487                mOldDepthBuffer[i] = 1; 
     488 
     489                mNewItemBuffer[i * 4]     = 255; 
     490                mNewItemBuffer[i * 4 + 1] = 255; 
     491                mNewItemBuffer[i * 4 + 2] = 255; 
     492                mNewItemBuffer[i * 4 + 3] = 255; 
     493 
     494                mOldItemBuffer[i * 4]     = 255; 
     495                mOldItemBuffer[i * 4 + 1] = 255; 
     496                mOldItemBuffer[i * 4 + 2] = 255; 
     497                mOldItemBuffer[i * 4 + 3] = 255; 
     498        } 
     499 
     500        /*gluLookAt(mViewPoint.x, mViewPoint.y, mViewPoint.z,  
     501                          midPoint.x, midPoint.y, midPoint.z,  
     502                          0, 1, 0); 
     503*/ 
     504        gluLookAt(0, 0, 3, 0, 0, 0, 0, 1, 0); 
     505 
     506        //glDisable(GL_CULL_FACE); 
     507        glEnable(GL_CULL_FACE); 
     508        glDisable(GL_LIGHTING); 
     509        glDisable(GL_COLOR_MATERIAL); 
     510        glEnable(GL_DEPTH_TEST);  
     511        glClearColor(0.1, 0.2, 0.3, 1); 
     512         
     513        // A square, mipmapped, anisotropically filtered 8-bit RGBA texture with 
     514        // depth and stencil. 
     515        // Note that RT_COPY_TO_TEXTURE is required for depth textures on ATI hardware 
     516         
     517        mNewTexture = new RenderTexture(mTexWidth, mTexHeight, true, true); 
     518#ifdef ATI 
     519        mNewTexture->Initialize(true, true, false, true, true, 8, 8, 8, 8, RenderTexture::RT_COPY_TO_TEXTURE); 
     520#else 
     521        mNewTexture->Initialize(true, true, false, true, true, 8, 8, 8, 8);//, RenderTexture::RT_COPY_TO_TEXTURE); 
     522#endif 
     523 
     524        mOldTexture = new RenderTexture(mTexWidth, mTexHeight, true, true); 
     525 
     526#ifdef ATI 
     527        mOldTexture ->Initialize(true, true, false, true, true, 8, 8, 8, 8, RenderTexture::RT_COPY_TO_TEXTURE); 
     528#else 
     529        mOldTexture ->Initialize(true, true, false, true, true, 8, 8, 8, 8);//, RenderTexture::RT_COPY_TO_TEXTURE); 
     530#endif 
     531 
     532        // Setup Cg 
     533        cgSetErrorCallback(cgErrorCallback); 
     534 
     535        // Create cgContext. 
     536        sCgContext = cgCreateContext(); 
     537 
     538        // get the best profile for this hardware 
     539        sCgFragmentProfile = cgGLGetLatestProfile(CG_GL_FRAGMENT); 
     540         
     541        //assert(sCgFragmentProfile != CG_PROFILE_UNKNOWN); 
     542        cgGLSetOptimalOptions(sCgFragmentProfile); 
     543 
     544        sCgDepthPeelingProgram =  
     545                cgCreateProgramFromFile(sCgContext,  
     546                                                                CG_SOURCE, 
     547                                                                mNewTexture->IsRectangleTexture() ?  
     548                                                                "../src/depth_peelingRect.cg" : "../src/depth_peeling2d.cg",  
     549                                                                GLEW_ARB_fragment_program ? CG_PROFILE_ARBFP1 : CG_PROFILE_FP30, 
     550                                                                NULL, 
     551                                                                NULL); 
     552 
     553        if(sCgDepthPeelingProgram != NULL) 
     554        { 
     555                cgGLLoadProgram(sCgDepthPeelingProgram); 
     556                sTextureParam = cgGetNamedParameter(sCgDepthPeelingProgram, "depthTex");   
     557                 
     558                // we need size of texture for scaling 
     559                if (!mNewTexture->IsRectangleTexture())  
     560                { 
     561                        sTexWidthParam = cgGetNamedParameter(sCgDepthPeelingProgram, "texWidth"); 
     562                } 
     563 
     564                sStepSizeParam = cgGetNamedParameter(sCgDepthPeelingProgram, "stepSize");  
     565 
     566                cgGLSetParameter1f(sTexWidthParam, (float)mTexWidth); 
     567                cgGLSetParameter1f(sStepSizeParam, mEpsilon); 
     568        } 
     569 
     570        sCgPassThroughProgram =  
     571                cgCreateProgramFromFile(sCgContext,  
     572                                                                CG_SOURCE, 
     573                                                                "../src/passthrough.cg",  
     574                                                                GLEW_ARB_fragment_program ? CG_PROFILE_ARBFP1 : CG_PROFILE_FP30, 
     575                                                                NULL, 
     576                                                                NULL); 
     577 
     578        if(sCgPassThroughProgram != NULL) 
     579        { 
     580                cgGLLoadProgram(sCgPassThroughProgram); 
     581        } 
     582 
     583        const float alpha = 1.1; 
     584        const float beta = 0.9; 
     585        InitScene(alpha, beta); 
    532586 
    533587        PrintGLerror("init"); 
     
    542596                                                                                                           const bool isFrontBuffer) const 
    543597{ 
    544         const int depthIndex = x + texWidth * y; 
     598        const int depthIndex = x + mTexWidth * y; 
    545599        const int itemIndex = 4 * depthIndex; 
    546600 
     
    548602        const float eyeDist = mNear + (mFar - mNear) * depth; 
    549603         
    550         const float leftDist = 0.5f * mWidth - mWidth * ((float)x + 0.5f) / texWidth; 
    551         //const float upDist = 0.5f * mWidth - (float)mWidth * ((float)y + 0.5f) / texHeight; 
    552         const float upDist = -0.5f * mWidth + mWidth * ((float)y + 0.5f) / texHeight; 
    553          
     604        const float leftDist = -0.5f * mWidth + mWidth * ((float)x + 0.5f) / mTexWidth; 
     605        //const float leftDist = 0.5f * mWidth - mWidth * ((float)x + 0.5f) / mTexWidth; 
     606         
     607        const float upDist = -0.5f * mWidth + mWidth * ((float)y + 0.5f) / mTexHeight; 
     608        //const float upDist = 0.5f * mWidth - mWidth * ((float)y + 0.5f) / mTexHeight; 
     609 
    554610        hitPoint = mViewPoint +  
    555611                       eyeDist * mEyeVec +  
    556                            leftDist * mUpVec +  
    557                            upDist * mLeftVec; 
     612                           upDist * mUpVec + 
     613                           leftDist * mLeftVec; 
    558614                                 
    559615        unsigned char r = itemBuffer[itemIndex]; 
     
    595651        else 
    596652        { 
    597                 for (int i = 0; i < texWidth * texHeight; ++ i) 
     653                for (int i = 0; i < mTexWidth * mTexHeight; ++ i) 
    598654                { 
    599655                        mOldDepthBuffer[i] = 0; 
     
    606662        } 
    607663 
    608         //cout << "vp: " << "eye: " << mEyeVec << " left: " << mLeftVec << " up: " << mUpVec << endl; 
    609  
    610         for (int y = 0; y < texHeight; ++ y) 
    611         { 
    612                 for (int x = 0; x < texWidth; ++ x) 
     664        for (int y = 0; y < mTexHeight; ++ y) 
     665        { 
     666                for (int x = 0; x < mTexWidth; ++ x) 
    613667                { 
    614668                        Vector3 newPt, oldPt; 
     
    724778                } 
    725779 
    726                 if (ray->mPass == 4) 
     780                //if (ray->mPass == 4) 
    727781                        outRays.push_back(ray); 
    728782        }        
     
    738792        rt->BindDepth(); 
    739793        rt->EnableTextureTarget(); 
    740         //cout << "depth: " << mNewTexture->GetDepthBits() << endl; 
    741794 
    742795        const int texFormat = GL_DEPTH_COMPONENT; 
     
    751804        rt->Bind(); 
    752805        rt->EnableTextureTarget(); 
    753         //cout << "depth: " << mNewTexture->GetDepthBits() << endl; 
    754806 
    755807        const int texFormat = GL_RGBA; 
     
    768820        const int components = 1;//mNewTexture->GetDepthBits() / 8; 
    769821 
    770         float *data = new float[texWidth * texHeight * components]; 
     822        float *data = new float[mTexWidth * mTexHeight * components]; 
    771823        //const int texFormat = WGL_TEXTURE_DEPTH_COMPONENT_NV; 
    772824        const int texFormat = GL_DEPTH_COMPONENT; 
     
    780832        const int bpp = components; 
    781833 
    782         ilTexImage(texWidth, texHeight, depth, bpp, IL_LUMINANCE, IL_FLOAT, data); 
     834        ilTexImage(mTexWidth, mTexHeight, depth, bpp, IL_LUMINANCE, IL_FLOAT, data); 
    783835        ilSaveImage((char *const)filename.c_str()); 
    784836 
     
    799851        const int components = 4;//mNewTexture->GetDepthBits() / 8; 
    800852 
    801         unsigned char *data = new unsigned char [texWidth * texHeight * components]; 
     853        unsigned char *data = new unsigned char [mTexWidth * mTexHeight * components]; 
    802854        //const int texFormat = WGL_TEXTURE_DEPTH_COMPONENT_NV; 
    803855        const int texFormat = GL_RGBA; 
     
    810862        const int bpp = components; 
    811863 
    812         ilTexImage(texWidth, texHeight, depth, bpp, IL_RGBA, IL_UNSIGNED_BYTE, data); 
     864        ilTexImage(mTexWidth, mTexHeight, depth, bpp, IL_RGBA, IL_UNSIGNED_BYTE, data); 
    813865        ilSaveImage((char *const)filename.c_str()); 
    814866 
     
    821873 
    822874 
    823 void GlobalLinesRenderer::ApplyDepthPeeling(VssRayContainer &rays, 
    824                                                                                         Beam &beam,  
    825                                                                                         const int samples) 
     875void GlobalLinesRenderer::ApplyDepthPeeling(VssRayContainer &rays) 
    826876{ 
    827877        mNewTexture->BeginCapture(); 
Note: See TracChangeset for help on using the changeset viewer.