Changeset 657 for OGRE/trunk/ogre_changes/RenderSystems/GL/src
- Timestamp:
- 02/20/06 19:06:03 (19 years ago)
- 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 38 38 * Updated on 12/7/2004 by Chris McGuirk 39 39 * - Implemented ARB_occlusion_query 40 * Updated on 4/8/2005 by Tuan Kuranes email: tuan.kuranes@free.fr 40 41 */ 41 42 … … 154 155 #endif // GTP_VIBILITY_MODIFIED_OGRE 155 156 } 157 158 -
OGRE/trunk/ogre_changes/RenderSystems/GL/src/OgreGLRenderSystem.cpp
r350 r657 257 257 delete mTextureManager; 258 258 259 delete mCapabilities;260 259 delete mGLSupport; 261 260 } … … 894 893 case Light::LT_SPOTLIGHT: 895 894 glLightf( gl_index, GL_SPOT_CUTOFF, 0.5f * lt->getSpotlightOuterAngle().valueDegrees() ); 895 glLightf(gl_index, GL_SPOT_EXPONENT, lt->getSpotlightFalloff()); 896 896 break; 897 897 default: … … 1090 1090 if(!tex.isNull()) 1091 1091 glBindTexture( mTextureTypes[stage], tex->getGLID() ); 1092 1092 else 1093 glBindTexture( mTextureTypes[stage], static_cast<GLTextureManager*>(mTextureManager)->getWarningTextureID() ); 1093 1094 } 1094 1095 else … … 1238 1239 1239 1240 // 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; 1244 1242 1245 1243 projectionBias = projectionBias * frustum->getProjectionMatrix(); … … 1260 1258 switch(tam) 1261 1259 { 1260 default: 1262 1261 case TextureUnitState::TAM_WRAP: 1263 1262 type = GL_REPEAT; … … 1295 1294 mat[12] = mat[8]; 1296 1295 mat[13] = mat[9]; 1296 mat[8] = 0; 1297 mat[9] = 0; 1297 1298 } 1298 1299 // mat[14] = mat[10]; … … 1312 1313 glMatrixMode(GL_TEXTURE); 1313 1314 1315 // Load this matrix in 1316 glLoadMatrixf(mat); 1317 1314 1318 if (mUseAutoTextureMatrix) 1315 1319 { 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); 1326 1322 } 1327 1323 … … 1403 1399 h = vp->getActualHeight(); 1404 1400 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 } 1407 1407 glViewport(x, y, w, h); 1408 1408 … … 2344 2344 glDisableVertexAttribArrayARB_ptr(1); // disable weights 2345 2345 } 2346 2346 glColor4f(1,1,1,1); 2347 2347 glSecondaryColor3fEXT_ptr(0.0f, 0.0f, 0.0f); 2348 2348 … … 2415 2415 const Plane& plane = clipPlanes[i]; 2416 2416 2417 if (i >= GL_MAX_CLIP_PLANES)2417 if (i >= 6/*GL_MAX_CLIP_PLANES*/) 2418 2418 { 2419 2419 OGRE_EXCEPT(0, "Unable to set clip plane", … … 2424 2424 clipPlane[1] = plane.normal.y; 2425 2425 clipPlane[2] = plane.normal.z; 2426 clipPlane[3] = -plane.d;2426 clipPlane[3] = plane.d; 2427 2427 2428 2428 glClipPlane(clipPlaneId, clipPlane); … … 2440 2440 size_t top, size_t right, size_t bottom) 2441 2441 { 2442 // If request texture flipping, use "upper-left", otherwise use "lower-left" 2443 bool flipping = mActiveRenderTarget->requiresTextureFlipping(); 2442 2444 // GL measures from the bottom, not the top 2443 2445 size_t targetHeight = mActiveRenderTarget->getHeight(); … … 2450 2452 // NB GL uses width / height rather than right / bottom 2451 2453 x = left; 2454 if (flipping) 2455 y = top; 2456 else 2452 2457 y = targetHeight - bottom; 2453 2458 w = right - left; … … 2462 2467 h = mActiveViewport->getActualHeight(); 2463 2468 x = mActiveViewport->getActualLeft(); 2469 if (flipping) 2470 y = mActiveViewport->getActualTop(); 2471 else 2464 2472 y = targetHeight - mActiveViewport->getActualTop() - h; 2465 2473 glScissor(x, y, w, h); … … 2575 2583 HardwareOcclusionQuery* GLRenderSystem::createHardwareOcclusionQuery(void) 2576 2584 { 2577 return new GLHardwareOcclusionQuery(); 2585 GLHardwareOcclusionQuery* ret = new GLHardwareOcclusionQuery(); 2586 mHwOcclusionQueries.push_back(ret); 2587 return ret; 2578 2588 } 2579 2589 //--------------------------------------------------------------------- … … 2639 2649 } 2640 2650 //--------------------------------------------------------------------- 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 //--------------------------------------------------------------------- 2641 2687 void GLRenderSystem::_setRenderTarget(RenderTarget *target) 2642 2688 { … … 2645 2691 ContextMap::iterator i = mContextMap.find(target); 2646 2692 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); 2655 2694 } 2656 2695 } … … 2669 2708 // we set the main context to 0. 2670 2709 if(mCurrentContext != mMainContext) { 2671 mCurrentContext->endCurrent(); 2672 mCurrentContext = mMainContext; 2673 mCurrentContext->setCurrent(); 2710 _switchContext(mMainContext); 2674 2711 } else { 2675 2712 mMainContext = 0; -
OGRE/trunk/ogre_changes/RenderSystems/GL/src/OgreGLTexture.cpp
r193 r657 69 69 // have to call this here reather than in Resource destructor 70 70 // since calling virtual methods in base destructors causes crash 71 if (mIsLoaded) 72 { 71 73 unload(); 74 } 75 else 76 { 77 freeInternalResources(); 78 } 72 79 } 73 80 … … 90 97 91 98 //* Creation / loading methods ******************************************** 92 void GLTexture::createInternalResources (void)99 void GLTexture::createInternalResourcesImpl(void) 93 100 { 94 101 // Adjust requested parameters to capabilities … … 131 138 // Zero means create mip levels until 1x1 132 139 size_t maxMips = GLPixelUtil::getMaxMipmaps(mWidth, mHeight, mDepth, mFormat); 140 mNumMipmaps = mNumRequestedMipmaps; 133 141 if(mNumMipmaps>maxMips) 134 142 mNumMipmaps = maxMips; … … 144 152 145 153 // If we can do automip generation and the user desires this, do so 154 mMipmapsHardwareGenerated = 155 Root::getSingleton().getRenderSystem()->getCapabilities()->hasCapability(RSC_AUTOMIPMAP); 146 156 if((mUsage & TU_AUTOMIPMAP) && 147 mNumMipmaps && 148 Root::getSingleton().getRenderSystem()->getCapabilities()->hasCapability(RSC_AUTOMIPMAP)) 157 mNumRequestedMipmaps && mMipmapsHardwareGenerated) 149 158 { 150 159 glTexParameteri( getGLTextureTarget(), GL_GENERATE_MIPMAP, GL_TRUE ); … … 242 251 // Get final internal format 243 252 mFormat = getBuffer(0,0)->getFormat(); 244 mIsLoaded = true;245 253 } 246 254 … … 326 334 //************************************************************************* 327 335 328 void GLTexture:: unloadImpl()336 void GLTexture::freeInternalResourcesImpl() 329 337 { 330 338 mSurfaceList.clear(); … … 337 345 { 338 346 mSurfaceList.clear(); 339 // Make our understanding of the number of mips matches the GL one340 glBindTexture( getGLTextureTarget(), mTextureID );341 GLint value;342 glGetTexParameteriv( getGLTextureTarget(), GL_TEXTURE_MAX_LEVEL, &value );343 mNumMipmaps = value;344 347 345 348 // For all faces and mipmaps, store surfaces as HardwarePixelBufferSharedPtr 346 349 bool wantGeneratedMips = (mUsage & TU_AUTOMIPMAP)!=0; 347 bool canMip = Root::getSingleton().getRenderSystem()->getCapabilities()->hasCapability(RSC_AUTOMIPMAP);348 350 349 351 // Do mipmapping in software? (uses GLU) For some cards, this is still needed. Of course, 350 352 // only when mipmap generation is desired. 351 bool doSoftware = wantGeneratedMips && ! canMip&& getNumMipmaps();353 bool doSoftware = wantGeneratedMips && !mMipmapsHardwareGenerated && getNumMipmaps(); 352 354 353 355 for(int face=0; face<getNumFaces(); face++) -
OGRE/trunk/ogre_changes/RenderSystems/GL/src/OgreWin32Window.cpp
r193 r657 226 226 } 227 227 228 HDC old_hdc = wglGetCurrentDC(); 229 HGLRC old_context = wglGetCurrentContext(); 230 228 231 RECT rc; 229 232 // top and left represent outer window position … … 255 258 256 259 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 } 257 271 258 272 // Create RenderSystem context
Note: See TracChangeset
for help on using the changeset viewer.