Changeset 657 for OGRE/trunk/ogre_changes/RenderSystems
- Timestamp:
- 02/20/06 19:06:03 (19 years ago)
- Location:
- OGRE/trunk/ogre_changes/RenderSystems
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
OGRE/trunk/ogre_changes/RenderSystems/Direct3D7/include/OgreD3D7RenderWindow.h
r153 r657 119 119 */ 120 120 void writeContentsToFile(const String& filename); 121 121 // DirectDraw Methods 122 void createDDSurfaces(void); 123 void releaseDDSurfaces(void); 124 void restoreDDSurfaces(void); 125 void createDepthBuffer(void); 122 126 #ifdef GTP_VISIBILITY_MODIFIED_OGRE 123 127 uchar *getBufferContents(int &dimx, int &dimy); … … 159 163 LPDIRECT3DDEVICE7 mlpD3DDevice; 160 164 161 // DirectDraw Methods162 void createDDSurfaces(void);163 void releaseDDSurfaces(void);164 void restoreDDSurfaces(void);165 void createDepthBuffer(void);166 165 167 166 // Method for dealing with resize / move & 3d library -
OGRE/trunk/ogre_changes/RenderSystems/Direct3D7/include/OgreD3D7Texture.h
r154 r657 53 53 LPDIRECTDRAWSURFACE7 getDDSurface(void); 54 54 55 /// @copydoc Texture::createInternalResources56 void createInternalResources(void);57 58 55 /// @copydoc Texture::getBuffer 59 56 HardwarePixelBufferSharedPtr getBuffer(size_t face, size_t mipmap); … … 63 60 static PixelFormat closestD3DXFormat( PixelFormat format ); 64 61 static bool OgreFormat_to_DDPixelFormat( PixelFormat format, DDPIXELFORMAT & out ); 62 63 /// Restore this texture from a lost device 64 void restoreFromLostDevice(void); 65 65 66 protected: 66 67 IDirect3DDevice7 * mD3DDevice; ///< A pointer to the Direct3D device. … … 71 72 typedef std::vector<HardwarePixelBufferSharedPtr> SurfaceList; 72 73 SurfaceList mSurfaceList; 74 /// Are we restoring from a lost device? 75 bool mRestoring; 76 73 77 74 78 75 79 /// @copydoc Resource::loadImpl 76 80 void loadImpl(void); 77 /// @copydoc Resource::unloadImpl 78 void unloadImpl(void); 81 /// @copydoc Texture::createInternalResourcesImpl 82 void createInternalResourcesImpl(void); 83 /// @copydoc Resource::freeInternalResourcesImpl 84 void freeInternalResourcesImpl(void); 79 85 80 86 void createSurface2D(void); -
OGRE/trunk/ogre_changes/RenderSystems/Direct3D7/src/OgreD3D7RenderWindow.cpp
r153 r657 96 96 break; 97 97 98 case WM_MOVE:99 // Move messages need to be tracked to update the screen rects100 // used for blitting the backbuffer to the primary.101 if(win->mActive && win->mReady)102 win->windowMovedOrResized();103 break;104 105 98 case WM_ENTERSIZEMOVE: 106 99 // Prevent rendering while moving / sizing … … 113 106 break; 114 107 108 case WM_MOVE: 115 109 case WM_SIZE: 116 110 // Check to see if we are losing or gaining our window. Set the … … 391 385 void D3D7RenderWindow::swapBuffers(bool waitForVSync) 392 386 { 387 if (!mlpDDSFront) 388 return; 389 393 390 HRESULT hr; 394 391 DWORD flags; … … 423 420 { 424 421 // Restore surfaces 425 restoreDDSurfaces();422 //restoreDDSurfaces(); 426 423 } 427 424 else if (FAILED(hr)) … … 539 536 ddscaps.dwCaps = DDSCAPS_ZBUFFER; 540 537 538 if (!mlpDDSBack->IsLost()) 539 { 541 540 LPDIRECTDRAWSURFACE7 zBufSurface; 542 541 … … 546 545 zBufSurface->Release(); 547 546 zBufSurface->Release(); 547 } 548 548 549 549 // Release std buffers … … 563 563 564 564 if( FAILED( hr ) ) 565 { 566 if (hr == DDERR_WRONGMODE) 567 { 568 // Fullscreen exclusive mode problem 569 // Need to release & recreate 570 releaseDDSurfaces(); 571 createDDSurfaces(); 572 createDepthBuffer(); 573 return; 574 } 575 else 576 { 577 char szBuffer[512]; 578 D3DXGetErrorString( hr, 512, szBuffer ); 565 579 OGRE_EXCEPT( 566 580 Exception::ERR_INTERNAL_ERROR, 567 "Error restoring lost primary surface.",581 "Error restoring lost primary surface." + String(szBuffer), 568 582 "D3D7RenderWindow - restoreDDSurfaces" ); 569 583 } 584 } 585 } 570 586 571 587 if( mlpDDSBack->IsLost() ) … … 574 590 575 591 if( FAILED( hr ) ) 592 { 593 char szBuffer[512]; 594 D3DXGetErrorString( hr, 512, szBuffer ); 576 595 OGRE_EXCEPT( 577 596 Exception::ERR_INTERNAL_ERROR, 578 "Error restoring lost back buffer surface." ,597 "Error restoring lost back buffer surface." + String(szBuffer), 579 598 "D3D7RenderWindow - restoreDDSurfaces" ); 580 599 } 600 } 581 601 } 582 602 … … 592 612 ClientToScreen( mHWnd, (POINT*)&rcCheck.left ); 593 613 ClientToScreen( mHWnd, (POINT*)&rcCheck.right ); 614 615 if ((rcCheck.right - rcCheck.left) == 0 || 616 (rcCheck.bottom - rcCheck.top) == 0) 617 { 618 return; 619 } 594 620 595 621 // Has the window resized? If so, we need to recreate surfaces -
OGRE/trunk/ogre_changes/RenderSystems/Direct3D9/include/OgreD3D9HardwareOcclusionQuery.h
r115 r657 34 34 35 35 // If you use multiple rendering passes you can test only the first pass and all other passes don't have to be rendered 36 // if the first pass result ethas too few pixels visible.36 // if the first pass results has too few pixels visible. 37 37 38 // Be sure to render all occlluder first and whats out so the RenderQue don't switch places on38 // Be sure to render all occluder first and whats out so the RenderQue don't switch places on 39 39 // the occluding objects and the tested objects because it thinks it's more effective.. 40 40 … … 46 46 * 47 47 * Updated on 12/7/2004 by Chris McGuirk 48 * Updated on 4/8/2005 by Tuan Kuranes email: tuan.kuranes@free.fr 48 49 */ 49 50 class D3D9HardwareOcclusionQuery : public HardwareOcclusionQuery … … 73 74 bool pullOcclusionQuery( unsigned int* NumOfFragments, const HW_OCCLUSIONQUERY flag = HWOCCLUSIONQUERY_FLUSH); 74 75 unsigned int getLastQuerysPixelcount() { return mPixelCount; } 76 bool isStillOutstanding(void); 75 77 76 78 // These functions are optional, it's a simple filter that simply skips some hardware occlusion tests on visible objects only … … 82 84 * 83 85 * Remarks This function allows you to set how often the hardware occlusion query is sent to the driver 84 * if you set it to 0 every hw occlusion test is acctually made. If you set it to 1 only the half of your queries are sent85 * 2 will result in 25% of all queries to acctualy be sent.86 * if you set it to 0 every hardware occlusion test is actually made. If you set it to 1 only the half of your queries are sent 87 * 2 will result in 25% of all queries to factually be sent. 86 88 * This functionality is here because this class can keep track on visible and none visible objects for you. 87 89 * Once you you set the SkipRate for any hardware occlusion instance it effects all others. 88 90 */ 89 91 90 void setSkipRate( int skip ) { mSkipInterval = skip; } // Using 2 only 50 % of the tests are actu lly made and 3 results in only 33% of the tests. So on.92 void setSkipRate( int skip ) { mSkipInterval = skip; } // Using 2 only 50 % of the tests are actually made and 3 results in only 33% of the tests. So on. 91 93 int getSkipRate() { return mSkipInterval; } 92 94 … … 105 107 int mSkipInterval; 106 108 bool mHasOcclusionSupport; 109 bool mIsQueryResultStillOutstanding; 107 110 }; 108 111 -
OGRE/trunk/ogre_changes/RenderSystems/Direct3D9/include/OgreD3D9Texture.h
r193 r657 68 68 /// device capabilities pointer 69 69 D3DCAPS9 mDevCaps; 70 // Auto-generated mipmaps?71 bool mAutoGenMipmaps;72 70 // Dynamic textures? 73 71 bool mDynamicTextures; … … 95 93 D3DFORMAT _chooseD3DFormat(); 96 94 97 /// internal method, free D3D9 resources 98 void _freeResources(); 95 /// @copydoc Texture::createInternalResourcesImpl 96 void createInternalResourcesImpl(void); 97 /// free internal resources 98 void freeInternalResourcesImpl(void); 99 99 /// internal method, set Texture class source image protected attributes 100 100 void _setSrcAttributes(unsigned long width, unsigned long height, unsigned long depth, PixelFormat format); … … 116 116 /// internal method, create D3D9HardwarePixelBuffers for every face and 117 117 /// mipmap level. This method must be called after the D3D texture object was created 118 void _createSurfaceList( bool updateOldList=false);118 void _createSurfaceList(void); 119 119 120 120 /// overriden from Resource 121 121 void loadImpl(); 122 /// overriden from Resource123 void unloadImpl();124 122 public: 125 123 /// constructor … … 135 133 void loadImage( const Image &img ); 136 134 137 /// @copydoc Texture::createInternalResources138 void createInternalResources(void);139 135 140 136 /// @copydoc Texture::getBuffer -
OGRE/trunk/ogre_changes/RenderSystems/Direct3D9/src/OgreD3D9HardwareOcclusionQuery.cpp
r193 r657 113 113 // This version of pullOcclusionQuery causes the DX9 API/Driver to not flush all commands to the 3D card 114 114 // to allow a fast result from the query, but the batching of API calls to the card will be normal. 115 // But the query wont be processed until the card rec ives the query in the next batch.115 // But the query wont be processed until the card receives the query in the next batch. 116 116 // Note: OpenGL dosn't use this flag at all so the application running OpenGL won't display any different behaviour. 117 117 //-- -
OGRE/trunk/ogre_changes/RenderSystems/Direct3D9/src/OgreD3D9RenderWindow.cpp
r193 r657 110 110 D3D9RenderWindow::~D3D9RenderWindow() 111 111 { 112 // access and update device through driver, realse only primary 113 if (!mIsSwapChain) 114 { 115 LPDIRECT3DDEVICE9 mpD3DDevice = mDriver->getD3DDevice(); 116 SAFE_RELEASE( mpD3DDevice ); 117 mDriver->setD3DDevice( NULL ); 118 } 112 destroyD3DResources(); 119 113 } 120 114 … … 342 336 md3dpp.BackBufferHeight = mHeight; 343 337 344 #ifdef GTP_VISIBILITY_MODIFIED_OGRE345 //md3dpp.Flags |= D3DPRESENTFLAG_LOCKABLE_BACKBUFFER;346 #endif347 338 if (mVSync) 348 339 md3dpp.PresentationInterval = D3DPRESENT_INTERVAL_ONE; … … 493 484 // ignore depth buffer, access device through driver 494 485 mpRenderZBuffer = 0; 495 LPDIRECT3DDEVICE9 mpD3DDevice = mDriver->getD3DDevice();496 SAFE_RELEASE(mpD3DDevice);497 mDriver->setD3DDevice(NULL);498 486 } 499 487 } … … 727 715 } 728 716 729 if (!mIsFullScreen) 730 { 731 POINT pt={0, 0}; 717 D3DLOCKED_RECT lockedRect; 718 if(mIsFullScreen) 719 { 720 if (FAILED(hr = pTempSurf->LockRect(&lockedRect, NULL, 721 D3DLOCK_READONLY | D3DLOCK_NOSYSLOCK))) 722 { 723 OGRE_EXCEPT(hr, "can't lock rect!", "D3D9RenderWindow::writeContentsToFile"); 724 } 725 } 726 else 727 { 732 728 RECT srcRect; 733 729 GetWindowRect(mHWnd, &srcRect); … … 735 731 desc.Width = srcRect.right - srcRect.left; 736 732 desc.Height = srcRect.bottom - srcRect.top; 737 desc.Format = D3DFMT_A8R8G8B8; // this is what we get from the screen, so stick with it 738 739 // NB we can't lock the back buffer direct because it's no created that way 740 // and to do so hits performance, so copy to another surface 741 // Must be the same format as the source surface 742 if (FAILED(hr = mpD3DDevice->CreateOffscreenPlainSurface( 743 desc.Width, 744 desc.Height, 745 desc.Format, 746 D3DPOOL_DEFAULT, 747 &pSurf, 748 NULL))) 749 { 750 SAFE_RELEASE(pSurf); 751 OGRE_EXCEPT(hr, "Cannot create offscreen buffer 2!", "D3D9RenderWindow::writeContentsToFile"); 752 } 753 754 // Copy 755 if (FAILED(hr = mpD3DDevice->UpdateSurface(pTempSurf, &srcRect, pSurf, &pt))) 756 { 757 SAFE_RELEASE(pTempSurf); 758 SAFE_RELEASE(pSurf); 759 OGRE_EXCEPT(hr, "Cannot update surface!", "D3D9RenderWindow::writeContentsToFile"); 760 } 761 762 SAFE_RELEASE(pTempSurf); 763 pTempSurf = pSurf; 764 pSurf = NULL; 765 } 766 767 D3DLOCKED_RECT lockedRect; 768 if (FAILED(hr = pTempSurf->LockRect(&lockedRect, NULL, 733 734 if (FAILED(hr = pTempSurf->LockRect(&lockedRect, &srcRect, 735 769 736 D3DLOCK_READONLY | D3DLOCK_NOSYSLOCK))) 770 737 { 771 738 OGRE_EXCEPT(hr, "can't lock rect!", "D3D9RenderWindow::writeContentsToFile"); 772 739 } 740 } 773 741 774 742 ImageCodec::ImageData *imgData = new ImageCodec::ImageData(); -
OGRE/trunk/ogre_changes/RenderSystems/GL/include/OgreGLHardwareOcclusionQuery.h
r343 r657 53 53 54 54 // If you use multiple rendering passes you can test only the first pass and all other passes don't have to be rendered 55 // if the first pass result et has too few pixels visable.55 // if the first pass result has too few pixels visible. 56 56 57 // Be sure to render all occl luder first and whats out so the RenderQue don't switch places on57 // Be sure to render all occluder first and whats out so the RenderQue don't switch places on 58 58 // the occluding objects and the tested objects because it thinks it's more effective.. 59 59 … … 64 64 * 65 65 * @author Lee Sandberg email: lee@abcmedia.se 66 * Updated on 4/8/2005 by Tuan Kuranes email: tuan.kuranes@free.fr 66 67 */ 67 68 … … 91 92 unsigned int getLastQuerysPixelcount() { return mPixelCount; } 92 93 93 // This functions are optional, it's a simple filter that simply skip ps some hardware occlusion tests on visable objects only94 // It's easy to use if you don't have to keep track on which objects are vis able (can be skipped) and what objects arn't visable..95 // (None vis able objects and object you introduce for the first time have allways to be tested allthough the cheepest possible96 // LOD (Level Of Detail) mesh and material wi ze).94 // This functions are optional, it's a simple filter that simply skips some hardware occlusion tests on visible objects only 95 // It's easy to use if you don't have to keep track on which objects are visible (can be skipped) and what objects arn't visible.. 96 // (None visible objects and object you introduce for the first time have always to be tested although the cheapest possible 97 // LOD (Level Of Detail) mesh and material wise). 97 98 98 99 /** 99 100 * 100 101 * Remarks This function allows you to set how often the hardware occlusion really sent to the driver 101 * if you set it to 0 every h w occlusion test is acctually made. If you set it to 2 only 50% of your queries are sent.102 * for all vis able objects. 3 will result in 33% of all queries to acctualy be sent and so on.103 * New and none vis able objects will be tested all the time.104 * This functionality is here because this class can keep track on vis able and none visable objects for you.102 * if you set it to 0 every hardware occlusion test is actually made. If you set it to 2 only 50% of your queries are sent. 103 * for all visible objects. 3 will result in 33% of all queries to actually be sent and so on. 104 * New and none visible objects will be tested all the time. 105 * This functionality is here because this class can keep track on visible and none visible objects for you. 105 106 * Once you you set the SkipRate for any hardware occlusion instance it effects all others. 106 107 */ 107 108 108 void setSkipRate( int skip ) { mSkipInterval = skip; } // Using 2 only 50 % of the tests are actu lly made and 3 results in only 33% of the tests. So on.109 void setSkipRate( int skip ) { mSkipInterval = skip; } // Using 2 only 50 % of the tests are actually made and 3 results in only 33% of the tests. So on. 109 110 int getSkipRate() { return mSkipInterval; } 110 111 -
OGRE/trunk/ogre_changes/RenderSystems/GL/include/OgreGLTexture.h
r153 r657 46 46 virtual ~GLTexture(); 47 47 48 /// @copydoc Texture::createInternalResources49 void createInternalResources(void);50 48 void loadImage( const Image& img ); 51 49 void createRenderTexture(); … … 61 59 62 60 protected: 61 /// @copydoc Texture::createInternalResourcesImpl 62 void createInternalResourcesImpl(void); 63 63 /// @copydoc Resource::loadImpl 64 64 void loadImpl(void); 65 /// @copydoc Resource:: unloadImpl66 void unloadImpl(void);65 /// @copydoc Resource::freeInternalResourcesImpl 66 void freeInternalResourcesImpl(void); 67 67 68 68 /** internal method, create GLHardwarePixelBuffers for every face and -
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.