Ignore:
Timestamp:
02/20/06 19:06:03 (18 years ago)
Author:
mattausch
Message:

added ogre dependencies and patched ogre sources

Location:
OGRE/trunk/ogre_changes/RenderSystems/GL/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • OGRE/trunk/ogre_changes/RenderSystems/GL/src/OgreGLHardwareOcclusionQuery.cpp

    r343 r657  
    3838  * Updated on 12/7/2004 by Chris McGuirk 
    3939  * - Implemented ARB_occlusion_query 
     40  * Updated on 4/8/2005 by Tuan Kuranes email: tuan.kuranes@free.fr 
    4041  */ 
    4142 
     
    154155#endif // GTP_VIBILITY_MODIFIED_OGRE 
    155156} 
     157 
     158 
  • OGRE/trunk/ogre_changes/RenderSystems/GL/src/OgreGLRenderSystem.cpp

    r350 r657  
    257257            delete mTextureManager; 
    258258 
    259         delete mCapabilities; 
    260259        delete mGLSupport; 
    261260    } 
     
    894893            case Light::LT_SPOTLIGHT: 
    895894                glLightf( gl_index, GL_SPOT_CUTOFF, 0.5f * lt->getSpotlightOuterAngle().valueDegrees() ); 
     895                glLightf(gl_index, GL_SPOT_EXPONENT, lt->getSpotlightFalloff()); 
    896896                break; 
    897897            default: 
     
    10901090                        if(!tex.isNull()) 
    10911091                                glBindTexture( mTextureTypes[stage], tex->getGLID() ); 
    1092  
     1092                        else 
     1093                                glBindTexture( mTextureTypes[stage], static_cast<GLTextureManager*>(mTextureManager)->getWarningTextureID() ); 
    10931094        } 
    10941095        else 
     
    12381239 
    12391240            // Set scale and translation matrix for projective textures 
    1240             projectionBias = Matrix4::ZERO; 
    1241             projectionBias[0][0] = 0.5; projectionBias[1][1] = -0.5;  
    1242             projectionBias[2][2] = 1.0; projectionBias[0][3] = 0.5;  
    1243             projectionBias[1][3] = 0.5; projectionBias[3][3] = 1.0; 
     1241            projectionBias = Matrix4::CLIPSPACE2DTOIMAGESPACE; 
    12441242 
    12451243            projectionBias = projectionBias * frustum->getProjectionMatrix(); 
     
    12601258        switch(tam) 
    12611259        { 
     1260        default: 
    12621261        case TextureUnitState::TAM_WRAP: 
    12631262            type = GL_REPEAT; 
     
    12951294                        mat[12] = mat[8]; 
    12961295                        mat[13] = mat[9]; 
     1296            mat[8] = 0; 
     1297            mat[9] = 0; 
    12971298                } 
    12981299//        mat[14] = mat[10]; 
     
    13121313        glMatrixMode(GL_TEXTURE); 
    13131314 
     1315        // Load this matrix in 
     1316        glLoadMatrixf(mat); 
     1317 
    13141318        if (mUseAutoTextureMatrix) 
    13151319        { 
    1316             // Load auto matrix in 
    1317             glLoadMatrixf(mAutoTextureMatrix); 
    1318             // Concat new matrix 
    1319             glMultMatrixf(mat); 
    1320  
    1321         } 
    1322         else 
    1323         { 
    1324             // Just load this matrix 
    1325             glLoadMatrixf(mat); 
     1320            // Concat auto matrix 
     1321            glMultMatrixf(mAutoTextureMatrix); 
    13261322        } 
    13271323 
     
    14031399              h = vp->getActualHeight(); 
    14041400              x = vp->getActualLeft(); 
    1405               y = target->getHeight() - vp->getActualTop() - h; 
    1406    
     1401              y = vp->getActualTop(); 
     1402              if (!target->requiresTextureFlipping()) 
     1403              { 
     1404                  // Convert "upper-left" corner to "lower-left" 
     1405                  y = target->getHeight() - h - y; 
     1406              } 
    14071407              glViewport(x, y, w, h); 
    14081408   
     
    23442344            glDisableVertexAttribArrayARB_ptr(1); // disable weights 
    23452345        } 
    2346  
     2346        glColor4f(1,1,1,1); 
    23472347        glSecondaryColor3fEXT_ptr(0.0f, 0.0f, 0.0f); 
    23482348 
     
    24152415            const Plane& plane = clipPlanes[i]; 
    24162416 
    2417             if (i >= GL_MAX_CLIP_PLANES) 
     2417            if (i >= 6/*GL_MAX_CLIP_PLANES*/) 
    24182418            { 
    24192419                OGRE_EXCEPT(0, "Unable to set clip plane",  
     
    24242424            clipPlane[1] = plane.normal.y; 
    24252425            clipPlane[2] = plane.normal.z; 
    2426             clipPlane[3] = -plane.d; 
     2426            clipPlane[3] = plane.d; 
    24272427 
    24282428            glClipPlane(clipPlaneId, clipPlane); 
     
    24402440        size_t top, size_t right, size_t bottom) 
    24412441    { 
     2442        // If request texture flipping, use "upper-left", otherwise use "lower-left" 
     2443        bool flipping = mActiveRenderTarget->requiresTextureFlipping(); 
    24422444        //  GL measures from the bottom, not the top 
    24432445        size_t targetHeight = mActiveRenderTarget->getHeight(); 
     
    24502452            // NB GL uses width / height rather than right / bottom 
    24512453            x = left; 
     2454            if (flipping) 
     2455                y = top; 
     2456            else 
    24522457            y = targetHeight - bottom; 
    24532458            w = right - left; 
     
    24622467            h = mActiveViewport->getActualHeight(); 
    24632468            x = mActiveViewport->getActualLeft(); 
     2469            if (flipping) 
     2470                y = mActiveViewport->getActualTop(); 
     2471            else 
    24642472            y = targetHeight - mActiveViewport->getActualTop() - h; 
    24652473            glScissor(x, y, w, h); 
     
    25752583    HardwareOcclusionQuery* GLRenderSystem::createHardwareOcclusionQuery(void) 
    25762584    { 
    2577         return new GLHardwareOcclusionQuery();  
     2585        GLHardwareOcclusionQuery* ret = new GLHardwareOcclusionQuery();  
     2586                mHwOcclusionQueries.push_back(ret); 
     2587                return ret; 
    25782588    } 
    25792589    //--------------------------------------------------------------------- 
     
    26392649    } 
    26402650    //--------------------------------------------------------------------- 
     2651    void GLRenderSystem::_switchContext(GLContext *context) 
     2652    { 
     2653        // Unbind GPU programs and rebind to new context later, because 
     2654        // scene manager treat render system as ONE 'context' ONLY, and it 
     2655        // cached the GPU programs using state. 
     2656        if (mCurrentVertexProgram) 
     2657            mCurrentVertexProgram->unbindProgram(); 
     2658        if (mCurrentFragmentProgram) 
     2659            mCurrentFragmentProgram->unbindProgram(); 
     2660 
     2661        // It's ready to switching 
     2662            mCurrentContext->endCurrent(); 
     2663        mCurrentContext = context; 
     2664        mCurrentContext->setCurrent(); 
     2665         
     2666            // Check if the context has already done one-time initialisation 
     2667        if(!mCurrentContext->getInitialized())  
     2668        { 
     2669               _oneTimeContextInitialization(); 
     2670               mCurrentContext->setInitialized(); 
     2671            } 
     2672 
     2673        // Rebind GPU programs to new context 
     2674        if (mCurrentVertexProgram) 
     2675            mCurrentVertexProgram->bindProgram(); 
     2676        if (mCurrentFragmentProgram) 
     2677            mCurrentFragmentProgram->bindProgram(); 
     2678 
     2679        // Must reset depth/colour write mask to according with user desired, otherwise, 
     2680        // clearFrameBuffer would be wrong because the value we are recorded may be 
     2681        // difference with the really state stored in GL context. 
     2682        glDepthMask(mDepthWrite); 
     2683        glColorMask(mColourWrite[0], mColourWrite[1], mColourWrite[2], mColourWrite[3]); 
     2684 
     2685    } 
     2686    //--------------------------------------------------------------------- 
    26412687    void GLRenderSystem::_setRenderTarget(RenderTarget *target) 
    26422688    { 
     
    26452691        ContextMap::iterator i = mContextMap.find(target); 
    26462692        if(i != mContextMap.end() && mCurrentContext != i->second) { 
    2647             mCurrentContext->endCurrent(); 
    2648             mCurrentContext = i->second; 
    2649             // Check if the context has already done one-time initialisation 
    2650             if(!mCurrentContext->getInitialized()) { 
    2651                _oneTimeContextInitialization(); 
    2652                mCurrentContext->setInitialized(); 
    2653             } 
    2654             mCurrentContext->setCurrent(); 
     2693            _switchContext(i->second); 
    26552694        } 
    26562695    } 
     
    26692708            // we set the main context to 0. 
    26702709            if(mCurrentContext != mMainContext) { 
    2671                 mCurrentContext->endCurrent(); 
    2672                 mCurrentContext = mMainContext; 
    2673                 mCurrentContext->setCurrent(); 
     2710                _switchContext(mMainContext); 
    26742711            } else { 
    26752712                mMainContext = 0; 
  • OGRE/trunk/ogre_changes/RenderSystems/GL/src/OgreGLTexture.cpp

    r193 r657  
    6969        // have to call this here reather than in Resource destructor 
    7070        // since calling virtual methods in base destructors causes crash 
     71                if (mIsLoaded) 
     72                { 
    7173        unload();  
     74    } 
     75                else 
     76                { 
     77                        freeInternalResources(); 
     78                } 
    7279    } 
    7380 
     
    9097 
    9198        //* Creation / loading methods ******************************************** 
    92         void GLTexture::createInternalResources(void) 
     99        void GLTexture::createInternalResourcesImpl(void) 
    93100    { 
    94101                // Adjust requested parameters to capabilities 
     
    131138                // Zero means create mip levels until 1x1 
    132139                size_t maxMips = GLPixelUtil::getMaxMipmaps(mWidth, mHeight, mDepth, mFormat); 
     140                mNumMipmaps = mNumRequestedMipmaps; 
    133141                if(mNumMipmaps>maxMips) 
    134142                        mNumMipmaps = maxMips; 
     
    144152                 
    145153                // If we can do automip generation and the user desires this, do so 
     154                mMipmapsHardwareGenerated =  
     155                        Root::getSingleton().getRenderSystem()->getCapabilities()->hasCapability(RSC_AUTOMIPMAP); 
    146156                if((mUsage & TU_AUTOMIPMAP) && 
    147                     mNumMipmaps && 
    148                         Root::getSingleton().getRenderSystem()->getCapabilities()->hasCapability(RSC_AUTOMIPMAP)) 
     157                    mNumRequestedMipmaps && mMipmapsHardwareGenerated) 
    149158        { 
    150159            glTexParameteri( getGLTextureTarget(), GL_GENERATE_MIPMAP, GL_TRUE ); 
     
    242251                // Get final internal format 
    243252                mFormat = getBuffer(0,0)->getFormat(); 
    244                 mIsLoaded = true; 
    245253        } 
    246254         
     
    326334        //************************************************************************* 
    327335     
    328     void GLTexture::unloadImpl() 
     336    void GLTexture::freeInternalResourcesImpl() 
    329337    { 
    330338                mSurfaceList.clear(); 
     
    337345        { 
    338346                mSurfaceList.clear(); 
    339                 // Make our understanding of the number of mips matches the GL one 
    340                 glBindTexture( getGLTextureTarget(), mTextureID ); 
    341                 GLint value; 
    342                 glGetTexParameteriv( getGLTextureTarget(), GL_TEXTURE_MAX_LEVEL, &value ); 
    343                 mNumMipmaps = value; 
    344347                 
    345348                // For all faces and mipmaps, store surfaces as HardwarePixelBufferSharedPtr 
    346349                bool wantGeneratedMips = (mUsage & TU_AUTOMIPMAP)!=0; 
    347                 bool canMip = Root::getSingleton().getRenderSystem()->getCapabilities()->hasCapability(RSC_AUTOMIPMAP); 
    348350                 
    349351                // Do mipmapping in software? (uses GLU) For some cards, this is still needed. Of course, 
    350352                // only when mipmap generation is desired. 
    351                 bool doSoftware = wantGeneratedMips && !canMip && getNumMipmaps();  
     353                bool doSoftware = wantGeneratedMips && !mMipmapsHardwareGenerated && getNumMipmaps();  
    352354                 
    353355                for(int face=0; face<getNumFaces(); face++) 
  • OGRE/trunk/ogre_changes/RenderSystems/GL/src/OgreWin32Window.cpp

    r193 r657  
    226226                    } 
    227227 
     228                HDC old_hdc = wglGetCurrentDC(); 
     229                HGLRC old_context = wglGetCurrentContext(); 
     230 
    228231                        RECT rc; 
    229232                // top and left represent outer window position 
     
    255258                 
    256259                wglSwapIntervalEXT(vsync? 1 : 0); 
     260 
     261        if (old_context) 
     262        { 
     263            // Restore old context 
     264                    if (!wglMakeCurrent(old_hdc, old_context)) 
     265                            OGRE_EXCEPT(0, "wglMakeCurrent() failed", "Win32Window::create"); 
     266 
     267            // Share lists with old context 
     268                    if (!wglShareLists(old_context, mGlrc)) 
     269                            OGRE_EXCEPT(0, "wglShareLists() failed", " Win32Window::create"); 
     270        } 
    257271 
    258272        // Create RenderSystem context 
Note: See TracChangeset for help on using the changeset viewer.