Просмотр исходного кода

Fixed an issue with OpenGL scissor and viewport coordinates
Scene picking works on OpenGL

Marko Pintera 11 лет назад
Родитель
Сommit
fbf0e9a5a1

+ 0 - 10
BansheeCore/Include/BsRenderTarget.h

@@ -169,16 +169,6 @@ namespace BansheeEngine
 		 */
 		 */
 		virtual void swapBuffers() {};
 		virtual void swapBuffers() {};
 
 
-		/**
-		 * @brief	Copy data from the render target into the provided pixel buffer.
-		 *
-		 * @param	dst		Destination buffer to copy the data to. Caller must ensure the buffer is of adequate size.
-		 * @param	buffer	Which buffer is data taken from. This is irrelevant for single buffer render targets.
-		 *
-		 * @note	Core thread only.
-		 */
-		virtual void copyToMemory(PixelData &dst, FrameBuffer buffer = FB_AUTO) = 0;
-
 		/**
 		/**
 		 * @brief	Queries the render target for a custom attribute. This may be anything and is
 		 * @brief	Queries the render target for a custom attribute. This may be anything and is
 		 *			implementation specific.
 		 *			implementation specific.

+ 0 - 5
BansheeCore/Include/BsRenderTexture.h

@@ -40,11 +40,6 @@ namespace BansheeEngine
 			const RENDER_SURFACE_DESC& depthStencilSurfaceDesc);
 			const RENDER_SURFACE_DESC& depthStencilSurfaceDesc);
 		virtual ~RenderTextureCore();
 		virtual ~RenderTextureCore();
 
 
-		/**
-		 * @copydoc	RenderTargetCore::copyToMemory
-		 */
-		virtual void copyToMemory(PixelData &dst, FrameBuffer buffer = FB_AUTO);
-
 		/**
 		/**
 		 * @brief	Returns properties that describe the render texture.
 		 * @brief	Returns properties that describe the render texture.
 		 */
 		 */

+ 0 - 5
BansheeCore/Source/BsRenderTexture.cpp

@@ -84,11 +84,6 @@ namespace BansheeEngine
 		}
 		}
 	}
 	}
 
 
-	void RenderTextureCore::copyToMemory(PixelData &dst, FrameBuffer buffer)
-	{
-		throw std::exception("The method or operation is not implemented.");
-	}
-
 	RenderTexture* RenderTextureCore::getNonCore() const
 	RenderTexture* RenderTextureCore::getNonCore() const
 	{
 	{
 		return static_cast<RenderTexture*>(mParent);
 		return static_cast<RenderTexture*>(mParent);

+ 36 - 11
BansheeEditor/Source/BsScenePicking.cpp

@@ -311,21 +311,46 @@ namespace BansheeEngine
 		UINT32 maxWidth = std::min((UINT32)(position.x + area.x), outputPixelData->getWidth());
 		UINT32 maxWidth = std::min((UINT32)(position.x + area.x), outputPixelData->getWidth());
 		UINT32 maxHeight = std::min((UINT32)(position.y + area.y), outputPixelData->getHeight());
 		UINT32 maxHeight = std::min((UINT32)(position.y + area.y), outputPixelData->getHeight());
 
 
-		for (UINT32 y = (UINT32)position.y; y < maxHeight; y++)
+		if (rt->requiresTextureFlipping())
 		{
 		{
-			for (UINT32 x = (UINT32)position.x; x < maxWidth; x++)
+			UINT32 vertOffset = outputPixelData->getHeight() - 1;
+
+			for (UINT32 y = maxHeight; y > (UINT32)position.y; y--)
 			{
 			{
-				Color color = outputPixelData->getColorAt(x, y);
-				UINT32 index = decodeIndex(color);
+				for (UINT32 x = (UINT32)position.x; x < maxWidth; x++)
+				{
+					Color color = outputPixelData->getColorAt(x, vertOffset - y);
+					UINT32 index = decodeIndex(color);
 
 
-				if (index == 0x00FFFFFF) // Nothing selected
-					continue;
+					if (index == 0x00FFFFFF) // Nothing selected
+						continue;
 
 
-				auto iterFind = selectionScores.find(index);
-				if (iterFind == selectionScores.end())
-					selectionScores[index] = 1;
-				else
-					iterFind->second++;
+					auto iterFind = selectionScores.find(index);
+					if (iterFind == selectionScores.end())
+						selectionScores[index] = 1;
+					else
+						iterFind->second++;
+				}
+			}
+		}
+		else
+		{
+			for (UINT32 y = (UINT32)position.y; y < maxHeight; y++)
+			{
+				for (UINT32 x = (UINT32)position.x; x < maxWidth; x++)
+				{
+					Color color = outputPixelData->getColorAt(x, y);
+					UINT32 index = decodeIndex(color);
+
+					if (index == 0x00FFFFFF) // Nothing selected
+						continue;
+
+					auto iterFind = selectionScores.find(index);
+					if (iterFind == selectionScores.end())
+						selectionScores[index] = 1;
+					else
+						iterFind->second++;
+				}
 			}
 			}
 		}
 		}
 
 

+ 9 - 8
BansheeGLRenderSystem/Source/BsGLRenderSystem.cpp

@@ -545,10 +545,10 @@ namespace BansheeEngine
 		mViewportWidth = (UINT32)(rtProps.getWidth() * vp.getNormalizedWidth());
 		mViewportWidth = (UINT32)(rtProps.getWidth() * vp.getNormalizedWidth());
 		mViewportHeight = (UINT32)(rtProps.getHeight() * vp.getNormalizedHeight());
 		mViewportHeight = (UINT32)(rtProps.getHeight() * vp.getNormalizedHeight());
 
 
-		if (!target->requiresTextureFlipping())
+		if (target->requiresTextureFlipping())
 		{
 		{
 			// Convert "upper-left" corner to "lower-left"
 			// Convert "upper-left" corner to "lower-left"
-			mViewportTop = target->getCore()->getProperties().getHeight() - mViewportHeight - mViewportTop;
+			mViewportTop = target->getCore()->getProperties().getHeight() - (mViewportTop + mViewportHeight) - 1;
 		}
 		}
 
 
 		glViewport(mViewportLeft, mViewportTop, mViewportWidth, mViewportHeight);
 		glViewport(mViewportLeft, mViewportTop, mViewportWidth, mViewportHeight);
@@ -1019,25 +1019,26 @@ namespace BansheeEngine
 			glEnable(GL_SCISSOR_TEST);
 			glEnable(GL_SCISSOR_TEST);
 			// GL uses width / height rather than right / bottom
 			// GL uses width / height rather than right / bottom
 			x = mScissorLeft;
 			x = mScissorLeft;
+
 			if (flipping)
 			if (flipping)
-				y = mScissorTop;
+				y = targetHeight - mScissorBottom - 1;
 			else
 			else
-				y = targetHeight - mScissorBottom;
+				y = mScissorTop;
+
 			w = mScissorRight - mScissorLeft;
 			w = mScissorRight - mScissorLeft;
 			h = mScissorBottom - mScissorTop;
 			h = mScissorBottom - mScissorTop;
+
 			glScissor(x, y, w, h);
 			glScissor(x, y, w, h);
 		}
 		}
 		else
 		else
 		{
 		{
 			glDisable(GL_SCISSOR_TEST);
 			glDisable(GL_SCISSOR_TEST);
+
 			// GL requires you to reset the scissor when disabling
 			// GL requires you to reset the scissor when disabling
 			w = mViewportWidth;
 			w = mViewportWidth;
 			h = mViewportHeight;
 			h = mViewportHeight;
 			x = mViewportLeft;
 			x = mViewportLeft;
-			if (flipping)
-				y = mViewportTop;
-			else
-				y = targetHeight - mViewportTop - h;
+			y = mViewportTop; 
 
 
 			glScissor(x, y, w, h);
 			glScissor(x, y, w, h);
 		}
 		}