Steve Streeting avatar Steve Streeting committed 1a80648 Merge

Merged v1-7 into default

Comments (0)

Files changed (6)

OgreMain/include/OgreRectangle2D.h

 
     public:
 
-        Rectangle2D(bool includeTextureCoordinates = false);
+        Rectangle2D(bool includeTextureCoordinates = false, HardwareBuffer::Usage vBufUsage = HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY);
         ~Rectangle2D();
 
         /** Sets the corners of the rectangle, in relative coordinates.

OgreMain/src/OgreCompositorInstance.cpp

 	LocalMRTMap::iterator mi = mLocalMRTs.find(name);
 	if (mi != mLocalMRTs.end())
 		return mi->second;
-	else
-		OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS, "Non-existent local texture name", 
-			"CompositorInstance::getTargetForTex");
+	
+	//Try reference : Find the instance and check if it is before us
+	CompositionTechnique::TextureDefinition* texDef = mTechnique->getTextureDefinition(name);
+	if (texDef != 0 && !texDef->refCompName.empty()) 
+	{
+		//This is a reference - find the compositor and referenced texture definition
+		const CompositorPtr& refComp = CompositorManager::getSingleton().getByName(texDef->refCompName);
+		if (refComp.isNull())
+		{
+			OGRE_EXCEPT(Exception::ERR_ITEM_NOT_FOUND, "Referencing non-existent compositor",
+				"CompositorInstance::getTargetForTex");
+		}
+		CompositionTechnique::TextureDefinition* refTexDef = refComp->getSupportedTechnique()->getTextureDefinition(texDef->refTexName);
+		if (refTexDef == 0)
+		{
+			OGRE_EXCEPT(Exception::ERR_ITEM_NOT_FOUND, "Referencing non-existent compositor texture",
+				"CompositorInstance::getTargetForTex");
+		}
+
+		switch (refTexDef->scope) 
+		{
+			case CompositionTechnique::TS_CHAIN: 
+			{
+				//Find the instance and check if it is before us
+				CompositorInstance* refCompInst = 0;
+				CompositorChain::InstanceIterator it = mChain->getCompositors();
+				bool beforeMe = true;
+				while (it.hasMoreElements())
+				{
+					CompositorInstance* nextCompInst = it.getNext();
+					if (nextCompInst->getCompositor()->getName() == texDef->refCompName)
+					{
+						refCompInst = nextCompInst;
+						break;
+					}
+					if (nextCompInst == this)
+					{
+						//We encountered ourselves while searching for the compositor -
+						//we are earlier in the chain.
+						beforeMe = false;
+					}
+				}
+				
+				if (refCompInst == 0 || !refCompInst->getEnabled()) 
+				{
+					OGRE_EXCEPT(Exception::ERR_INVALID_STATE, "Referencing inactive compositor texture",
+						"CompositorInstance::getTargetForTex");
+				}
+				if (!beforeMe)
+				{
+					OGRE_EXCEPT(Exception::ERR_INVALID_STATE, "Referencing compositor that is later in the chain",
+						"CompositorInstance::getTargetForTex");
+				}
+				return refCompInst->getRenderTarget(texDef->refTexName);
+			}
+			case CompositionTechnique::TS_GLOBAL:
+				//Chain and global case - the referenced compositor will know how to handle
+				return refComp->getRenderTarget(texDef->refTexName);
+			case CompositionTechnique::TS_LOCAL:
+			default:
+				OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS, "Referencing local compositor texture",
+					"CompositorInstance::getTargetForTex");
+		}
+	}
+
+	OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS, "Non-existent local texture name", 
+		"CompositorInstance::getTargetForTex");
 
 }
 //-----------------------------------------------------------------------

OgreMain/src/OgreCompositorManager.cpp

 	if(!mRectangle)
 	{
 		/// 2D rectangle, to use for render_quad passes
-		mRectangle = OGRE_NEW Rectangle2D(true);
+		mRectangle = OGRE_NEW Rectangle2D(true, HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY_DISCARDABLE);
 	}
 	RenderSystem* rs = Root::getSingleton().getRenderSystem();
 	Viewport* vp = rs->_getViewport();

OgreMain/src/OgreRectangle2D.cpp

 #define NORMAL_BINDING 1
 #define TEXCOORD_BINDING 2
 
-    Rectangle2D::Rectangle2D(bool includeTextureCoords) 
+	Rectangle2D::Rectangle2D(bool includeTextureCoords, Ogre::HardwareBuffer::Usage vBufUsage) 
     {
         // use identity projection and view matrices
         mUseIdentityProjection = true;
             HardwareBufferManager::getSingleton().createVertexBuffer(
             decl->getVertexSize(POSITION_BINDING),
             mRenderOp.vertexData->vertexCount,
-            HardwareBuffer::HBU_STATIC_WRITE_ONLY);
+            vBufUsage);
 
         // Bind buffer
         bind->setBinding(POSITION_BINDING, vbuf);
 			HardwareBufferManager::getSingleton().createVertexBuffer(
             decl->getVertexSize(NORMAL_BINDING),
             mRenderOp.vertexData->vertexCount,
-            HardwareBuffer::HBU_STATIC_WRITE_ONLY);
+            vBufUsage);
 
 		bind->setBinding(NORMAL_BINDING, vbuf);
 
                 HardwareBufferManager::getSingleton().createVertexBuffer(
                 decl->getVertexSize(TEXCOORD_BINDING),
                 mRenderOp.vertexData->vertexCount,
-                HardwareBuffer::HBU_STATIC_WRITE_ONLY);
+                vBufUsage);
 
             // Bind buffer
             bind->setBinding(TEXCOORD_BINDING, tvbuf);

RenderSystems/GL/src/OSX/OgreOSXCarbonWindow.cpp

             
             // Remove our event handler
             if(mEventHandlerRef)
-                RemoveEventHandler(mEventHandlerRef);        
+                RemoveEventHandler(mEventHandlerRef);
+            
+            // Also tell the OS that we no longer need this window
+            DisposeWindow(mWindow);
         }
     }
 
 //-------------------------------------------------------------------------------------------------//
 void OSXCarbonWindow::reposition(int left, int top)
 {
-	//LogManager::getSingleton().logMessage( "OSXCarbonWindow::reposition()" );
+	LogManager::getSingleton().logMessage( "OSXCarbonWindow::reposition()" );
 	if(mWindow)
 		MoveWindow(mWindow, left, top, true);
 }
 //-------------------------------------------------------------------------------------------------//
 void OSXCarbonWindow::resize(unsigned int width, unsigned int height)
 {
-	//LogManager::getSingleton().logMessage( "OSXCarbonWindow::resize()" );
+	LogManager::getSingleton().logMessage( "OSXCarbonWindow::resize()" );
 	if(!mWindow)
 		return;
 

Samples/DeferredShading/src/DeferredShading.cpp

 	mInstance[DSM_SHOWDSP] = compMan.addCompositor(mViewport, "DeferredShading/ShowDepthSpecular");
 	mInstance[DSM_SHOWCOLOUR] = compMan.addCompositor(mViewport, "DeferredShading/ShowColour");
 
-	mInstance[DSM_SHOWCOLOUR] = compMan.addCompositor(mViewport, "DeferredShading/ShowColour");
 	mSSAOInstance =  compMan.addCompositor(mViewport, "DeferredShading/SSAO");
 }
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.