Explorar o código

Fixed an issue where OpenGL draw calls would take longer and longer due to a vector that was never cleared
Fixed a problem with OpenGL rendering to render textures where the cull mode would be reversed
Fixed an OpenGL warning where anisotropy was set to 0 but minimum allowed value is 1
Hooked up OpenGL error callbacks (Not working ATM)
Removed unused mVertexWinding attribute from RenderSystem

Marko Pintera %!s(int64=12) %!d(string=hai) anos
pai
achega
644a56c379

+ 2 - 2
CamelotClient/CamelotClient.cpp

@@ -35,9 +35,9 @@
 #include "CmRTTIType.h"
 #include "CmPlatform.h"
 
-#define DX11
+//#define DX11
 //#define DX9
-//#define GL
+#define GL
 
 using namespace CamelotFramework;
 using namespace BansheeEditor;

+ 1 - 1
CamelotCore/Include/CmCommandQueue.h

@@ -237,7 +237,7 @@ namespace CamelotFramework
 	};
 
 	/**
-	 * @copydoc CommandQueue
+	 * @copydoc CommandQueueBase
 	 */
 	template<class SyncPolicy = CommandQueueNoSync>
 	class CM_EXPORT CommandQueue : public CommandQueueBase, public SyncPolicy

+ 0 - 2
CamelotCore/Include/CmRenderSystem.h

@@ -369,8 +369,6 @@ namespace CamelotFramework
 
 		CullingMode mCullingMode;
 
-		bool mInvertVertexWinding;
-
 		/// Texture units from this upwards are disabled
 		UINT16 mDisabledTexUnitsFrom;
 

+ 0 - 1
CamelotCore/Source/CmRenderSystem.cpp

@@ -50,7 +50,6 @@ namespace CamelotFramework {
 
     RenderSystem::RenderSystem()
         : mCullingMode(CULL_COUNTERCLOCKWISE)
-        , mInvertVertexWinding(false)
         , mDisabledTexUnitsFrom(0)
         , mVertexProgramBound(false)
 		, mGeometryProgramBound(false)

+ 7 - 9
CamelotD3D9Renderer/Source/CmD3D9RenderSystem.cpp

@@ -843,11 +843,9 @@ namespace CamelotFramework
 
 		mCullingMode = mode;
 		HRESULT hr;
-		bool flip = ((mActiveRenderTarget->requiresTextureFlipping() && !mInvertVertexWinding) ||
-			(!mActiveRenderTarget->requiresTextureFlipping() && mInvertVertexWinding));
 
 		if( FAILED (hr = __SetRenderState(D3DRS_CULLMODE, 
-			D3D9Mappings::get(mode, flip))) )
+			D3D9Mappings::get(mode, false))) )
 			CM_EXCEPT(RenderingAPIException, "Failed to set culling mode");
 	}
 	//---------------------------------------------------------------------
@@ -984,34 +982,34 @@ namespace CamelotFramework
 		if (ccw)
 		{
 			// fail op
-			hr = __SetRenderState(D3DRS_CCW_STENCILFAIL, D3D9Mappings::get(stencilFailOp, mInvertVertexWinding));
+			hr = __SetRenderState(D3DRS_CCW_STENCILFAIL, D3D9Mappings::get(stencilFailOp));
 			if (FAILED(hr))
 				CM_EXCEPT(RenderingAPIException, "Error setting stencil fail operation (ccw).");
 
 			// depth fail op
-			hr = __SetRenderState(D3DRS_CCW_STENCILZFAIL, D3D9Mappings::get(depthFailOp, mInvertVertexWinding));
+			hr = __SetRenderState(D3DRS_CCW_STENCILZFAIL, D3D9Mappings::get(depthFailOp));
 			if (FAILED(hr))
 				CM_EXCEPT(RenderingAPIException, "Error setting stencil depth fail operation (ccw).");
 
 			// pass op
-			hr = __SetRenderState(D3DRS_CCW_STENCILPASS, D3D9Mappings::get(passOp, mInvertVertexWinding));
+			hr = __SetRenderState(D3DRS_CCW_STENCILPASS, D3D9Mappings::get(passOp));
 			if (FAILED(hr))
 				CM_EXCEPT(RenderingAPIException, "Error setting stencil pass operation (ccw).");
 		}
 		else
 		{
 			// fail op
-			hr = __SetRenderState(D3DRS_STENCILFAIL, D3D9Mappings::get(stencilFailOp, !mInvertVertexWinding));
+			hr = __SetRenderState(D3DRS_STENCILFAIL, D3D9Mappings::get(stencilFailOp, true));
 			if (FAILED(hr))
 				CM_EXCEPT(RenderingAPIException, "Error setting stencil fail operation (cw).");
 
 			// depth fail op
-			hr = __SetRenderState(D3DRS_STENCILZFAIL, D3D9Mappings::get(depthFailOp, !mInvertVertexWinding));
+			hr = __SetRenderState(D3DRS_STENCILZFAIL, D3D9Mappings::get(depthFailOp, true));
 			if (FAILED(hr))
 				CM_EXCEPT(RenderingAPIException, "Error setting stencil depth fail operation (cw).");
 
 			// pass op
-			hr = __SetRenderState(D3DRS_STENCILPASS, D3D9Mappings::get(passOp, !mInvertVertexWinding));
+			hr = __SetRenderState(D3DRS_STENCILPASS, D3D9Mappings::get(passOp, true));
 			if (FAILED(hr))
 				CM_EXCEPT(RenderingAPIException, "Error setting stencil pass operation (cw).");
 		}

+ 28 - 28
CamelotGLRenderer/Source/CmGLRenderSystem.cpp

@@ -708,8 +708,6 @@ namespace CamelotFramework
 		glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 
 			static_cast<GLIndexBuffer*>(mBoundIndexBuffer.get())->getGLBufferId());
 
-		void* pBufferData = VBO_BUFFER_OFFSET(startIndex * mBoundIndexBuffer->getIndexSize());
-
 		GLenum indexType = (mBoundIndexBuffer->getType() == IndexBuffer::IT_16BIT) ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT;
 
 		glDrawElements(primType, indexCount, indexType, 0);
@@ -1071,28 +1069,10 @@ namespace CamelotFramework
 			return;
 		default:
 		case CULL_CLOCKWISE:
-			if (mActiveRenderTarget && 
-				((mActiveRenderTarget->requiresTextureFlipping() && !mInvertVertexWinding) ||
-				(!mActiveRenderTarget->requiresTextureFlipping() && mInvertVertexWinding)))
-			{
-				cullMode = GL_FRONT;
-			}
-			else
-			{
-				cullMode = GL_BACK;
-			}
+			cullMode = GL_BACK;
 			break;
 		case CULL_COUNTERCLOCKWISE:
-			if (mActiveRenderTarget && 
-				((mActiveRenderTarget->requiresTextureFlipping() && !mInvertVertexWinding) ||
-				(!mActiveRenderTarget->requiresTextureFlipping() && mInvertVertexWinding)))
-			{
-				cullMode = GL_BACK;
-			}
-			else
-			{
-				cullMode = GL_FRONT;
-			}
+			cullMode = GL_FRONT;
 			break;
 		}
 
@@ -1190,16 +1170,16 @@ namespace CamelotFramework
 		if (front)
 		{
 			glStencilOpSeparate(GL_FRONT, 
-				convertStencilOp(stencilFailOp, mInvertVertexWinding),
-				convertStencilOp(depthFailOp, mInvertVertexWinding), 
-				convertStencilOp(passOp, mInvertVertexWinding));
+				convertStencilOp(stencilFailOp),
+				convertStencilOp(depthFailOp), 
+				convertStencilOp(passOp));
 		}
 		else
 		{
 			glStencilOpSeparate(GL_BACK, 
-				convertStencilOp(stencilFailOp, !mInvertVertexWinding), 
-				convertStencilOp(depthFailOp, !mInvertVertexWinding), 
-				convertStencilOp(passOp, !mInvertVertexWinding));
+				convertStencilOp(stencilFailOp, true), 
+				convertStencilOp(depthFailOp, true), 
+				convertStencilOp(passOp, true));
 		}
 	}
 	//---------------------------------------------------------------------
@@ -1295,6 +1275,10 @@ namespace CamelotFramework
 		if (maxAnisotropy > largest_supported_anisotropy)
 			maxAnisotropy = largest_supported_anisotropy ? 
 			static_cast<UINT32>(largest_supported_anisotropy) : 1;
+
+		if(maxAnisotropy < 1)
+			maxAnisotropy = 1;
+
 		if (_getCurrentAnisotropy(unit) != maxAnisotropy)
 			glTexParameterf(mTextureTypes[unit], GL_TEXTURE_MAX_ANISOTROPY_EXT, (float)maxAnisotropy);
 
@@ -1353,6 +1337,11 @@ namespace CamelotFramework
 		glPopMatrix();
 	}
 	//---------------------------------------------------------------------
+	void openGlErrorCallback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *message, GLvoid *userParam)
+	{
+		// TODO - Actually hook this up to Log or something
+	}
+	//---------------------------------------------------------------------
 	void GLRenderSystem::oneTimeContextInitialization()
 	{
 		// Check for FSAA
@@ -1366,6 +1355,15 @@ namespace CamelotFramework
 				glEnable(GL_MULTISAMPLE_ARB);
 			}            
 		}
+
+		// TODO - Replace with OpenGL 4.3 built-in functionality (GL_DEBUG_OUTPUT_SYNCHRONOUS)
+#if CM_DEBUG_MODE
+		if (mGLSupport->checkExtension("GL_ARB_debug_output"))
+		{
+			glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB);
+			glDebugMessageCallbackARB(&openGlErrorCallback, 0);
+		}
+#endif
 	}
 	//---------------------------------------------------------------------
 	void GLRenderSystem::switchContext(GLContext *context)
@@ -1698,6 +1696,8 @@ namespace CamelotFramework
 		}
 
 		glColor4f(1,1,1,1);
+
+		mBoundAttributes.clear();
 	}
 	//-----------------------------------------------------------------------
 	bool GLRenderSystem::checkForErrors() const

+ 17 - 0
CamelotGLRenderer/Source/CmWin32Window.cpp

@@ -349,7 +349,24 @@ namespace CamelotFramework
 		{
 			if (!mIsExternalGLContext)
 			{
+#if CM_DEBUG_MODE
+				if (wglewIsSupported("WGL_ARB_create_context"))
+				{
+					int contextAttribs[] =
+					{
+						WGL_CONTEXT_FLAGS_ARB,
+						WGL_CONTEXT_DEBUG_BIT_ARB,
+						0
+					};
+
+					mGlrc = wglCreateContextAttribsARB(mHDC, 0, contextAttribs);
+				}
+				else
+					mGlrc = wglCreateContext(mHDC);
+#else
 				mGlrc = wglCreateContext(mHDC);
+#endif
+
 
 				if (!mGlrc)
 				{

+ 0 - 12
Localization.txt

@@ -1,12 +0,0 @@
-Test HString:
- - Test parameters
- - Test changing language
- - Test changing string
- - Test removing string
-
- Exception happens when changing languages
-
- Update MenuBar, ContextMenu, ListBox and GUIDropDownBox so they handle HString properly
-  - GUIDropDownData also accepts an array of localized strings
-  - MenuBar/ContextMenu/ListBox need to properly fill that array and forward it
-  - That array is then used for naming of menu entries (if it exists, otherwise we just use the name from the menu string)

+ 6 - 5
TODO.txt

@@ -10,11 +10,12 @@ LONGTERM TODO:
 
 PROFILER:
  TODO: Profiler is right now including windows.h. I need to work around that but don't feel like bothering with it atm
-  - Easy way would be to move CPUProfiler outside of Utility and into Core
- - When rendering GUI in front of scene view it seems to be rendering before the actual scene!?
- - Generating a report only generates it on the active thread. I need a way to generate profiler 
-   reports on the render thread as well. Maybe extend CoreThreadAccessor?
-
+  - Easy way would be to move CPUProfiler outside of Utility and into Core (PROBABLY THE WAY TO DO IT - No point in wasting time on this)
+  - Complex way would be to edit Timer and remove all the excess crap from it and just leave basic begin/end queries
+ - When rendering GUI in front of scene view it seems to be rendering before the actual scene
+  - This probably because the render texture alpha is less than 1, which makes it blend with the surface below it
+ - In OpenGL rendering GUI to texture doesn't seem to work!?
+ - Main window renders before the GUI render texture!
 
 TODO: Viewport can be modified from the sim thread, but is used on the core thread without any syncronization mechanisms. Maybe add a method that returns VIEWPORT_DATA, and have that used on the core thread.