Browse Source

OpenGL finally works again
Added documentation and refactored some stuff

Marko Pintera 11 years ago
parent
commit
75b0d168ec

+ 1 - 8
BoostPort.txt

@@ -9,14 +9,7 @@
 cm_shared_ptr should use && for parameter forwarding?
 cm_shared_ptr should use && for parameter forwarding?
 cm_core_ptr too
 cm_core_ptr too
 
 
-Refactor GLRenderSystem:
-createRenderSystemCapabilities
-initialiseFromRenderSystemCapabilities
-initializeContext
-switchContext
-oneTimeContextInitialization
-
-and update its docs
+Update GLRenderSystem docs
 
 
 Perform refactor mentioned in the documentation e-mail
 Perform refactor mentioned in the documentation e-mail
 
 

+ 1 - 1
CamelotCore/Include/CmCommonEnums.h

@@ -108,7 +108,7 @@ namespace BansheeEngine {
         TAM_MIRROR,
         TAM_MIRROR,
         /// Texture clamps at 1.0
         /// Texture clamps at 1.0
         TAM_CLAMP,
         TAM_CLAMP,
-        /// Texture coordinates outside the range [0.0, 1.0] are set to the border colour
+        /// Texture coordinates outside the range [0.0, 1.0] are set to the border color
         TAM_BORDER
         TAM_BORDER
     };
     };
 
 

+ 2 - 2
CamelotCore/Include/CmGpuResourceData.h

@@ -66,14 +66,14 @@ namespace BansheeEngine
 		 *
 		 *
 		 * @note	Internal method.
 		 * @note	Internal method.
 		 */
 		 */
-		void lock() const;
+		void _lock() const;
 
 
 		/**
 		/**
 		 * @brief	Unlocks the data and makes it available to all threads. 
 		 * @brief	Unlocks the data and makes it available to all threads. 
 		 *
 		 *
 		 * @note	Internal method.
 		 * @note	Internal method.
 		 */
 		 */
-		void unlock() const;
+		void _unlock() const;
 
 
 	protected:
 	protected:
 		/**
 		/**

+ 2 - 2
CamelotCore/Include/CmMesh.h

@@ -63,12 +63,12 @@ namespace BansheeEngine
 		/**
 		/**
 		 * @copydoc MeshBase::getVertexData
 		 * @copydoc MeshBase::getVertexData
 		 */
 		 */
-		virtual std::shared_ptr<VertexData> getVertexData() const;
+		virtual std::shared_ptr<VertexData> _getVertexData() const;
 
 
 		/**
 		/**
 		 * @copydoc MeshBase::getIndexData
 		 * @copydoc MeshBase::getIndexData
 		 */
 		 */
-		virtual std::shared_ptr<IndexData> getIndexData() const;
+		virtual std::shared_ptr<IndexData> _getIndexData() const;
 
 
 		/**
 		/**
 		 * @brief	Returns a dummy mesh, containing just one triangle. Don't modify the returned mesh.
 		 * @brief	Returns a dummy mesh, containing just one triangle. Don't modify the returned mesh.

+ 5 - 5
CamelotCore/Include/CmMeshBase.h

@@ -83,14 +83,14 @@ namespace BansheeEngine
 		 *  
 		 *  
 		 * @note	Core thread only. Internal method.
 		 * @note	Core thread only. Internal method.
 		 */
 		 */
-		virtual std::shared_ptr<VertexData> getVertexData() const = 0;
+		virtual std::shared_ptr<VertexData> _getVertexData() const = 0;
 
 
 		/**
 		/**
 		 * @brief	Get index data used for rendering.
 		 * @brief	Get index data used for rendering.
 		 *  
 		 *  
 		 * @note	Core thread only. Internal method.
 		 * @note	Core thread only. Internal method.
 		 */
 		 */
-		virtual std::shared_ptr<IndexData> getIndexData() const = 0;
+		virtual std::shared_ptr<IndexData> _getIndexData() const = 0;
 
 
 		/**
 		/**
 		 * @brief	Returns an offset into the vertex buffers that is returned
 		 * @brief	Returns an offset into the vertex buffers that is returned
@@ -101,7 +101,7 @@ namespace BansheeEngine
 		 * 			
 		 * 			
 		 *			Core thread only. Internal method.
 		 *			Core thread only. Internal method.
 		 */
 		 */
-		virtual UINT32 getVertexOffset() const { return 0; }
+		virtual UINT32 _getVertexOffset() const { return 0; }
 
 
 		/**
 		/**
 		 * @brief	Returns an offset into the index buffer that is returned
 		 * @brief	Returns an offset into the index buffer that is returned
@@ -112,7 +112,7 @@ namespace BansheeEngine
 		 * 			
 		 * 			
 		 *			Core thread only. Internal method.
 		 *			Core thread only. Internal method.
 		 */
 		 */
-		virtual UINT32 getIndexOffset() const { return 0; }
+		virtual UINT32 _getIndexOffset() const { return 0; }
 
 
 		/**
 		/**
 		 * @brief	Called whenever this mesh starts being used on the GPU.
 		 * @brief	Called whenever this mesh starts being used on the GPU.
@@ -122,7 +122,7 @@ namespace BansheeEngine
 		 * 			
 		 * 			
 		 *			Core thread only. Internal method.
 		 *			Core thread only. Internal method.
 		 */
 		 */
-		virtual void notifyUsedOnGPU() { }
+		virtual void _notifyUsedOnGPU() { }
 
 
 	protected:
 	protected:
 		Vector<SubMesh> mSubMeshes; // Sim thread
 		Vector<SubMesh> mSubMeshes; // Sim thread

+ 4 - 10
CamelotCore/Include/CmRenderSystemCapabilities.h

@@ -65,8 +65,9 @@ namespace BansheeEngine
 		CAPS_CATEGORY_D3D9 = 2,
 		CAPS_CATEGORY_D3D9 = 2,
 		CAPS_CATEGORY_GL = 3,
 		CAPS_CATEGORY_GL = 3,
 		CAPS_CATEGORY_COMMON_3 = 4,
 		CAPS_CATEGORY_COMMON_3 = 4,
+		CAPS_CATEGORY_D3D11 = 5,
 		/// Placeholder for max value
 		/// Placeholder for max value
-		CAPS_CATEGORY_COUNT = 5
+		CAPS_CATEGORY_COUNT = 6
 	};
 	};
 
 
 	/// Enum describing the different hardware capabilities we want to check for
 	/// Enum describing the different hardware capabilities we want to check for
@@ -220,18 +221,11 @@ namespace BansheeEngine
 	{
 	{
 		GPU_UNKNOWN = 0,
 		GPU_UNKNOWN = 0,
 		GPU_NVIDIA = 1,
 		GPU_NVIDIA = 1,
-		GPU_ATI = 2, 
+		GPU_AMD = 2, 
 		GPU_INTEL = 3,
 		GPU_INTEL = 3,
-		GPU_S3 = 4,
-		GPU_MATROX = 5,
-		GPU_3DLABS = 6,
-		GPU_SIS = 7,
-        GPU_IMAGINATION_TECHNOLOGIES = 8,
-        GPU_APPLE = 9,  // Apple Software Renderer
-        GPU_NOKIA = 10,
 
 
 		/// placeholder
 		/// placeholder
-		GPU_VENDOR_COUNT = 11
+		GPU_VENDOR_COUNT = 4
 	};
 	};
 
 
 	/** singleton class for storing the capabilities of the graphics card. 
 	/** singleton class for storing the capabilities of the graphics card. 

+ 2 - 2
CamelotCore/Include/CmTextureRTTI.h

@@ -39,7 +39,7 @@ namespace BansheeEngine
 			GpuResourcePtr sharedTexPtr = std::static_pointer_cast<GpuResource>(obj->getThisPtr());
 			GpuResourcePtr sharedTexPtr = std::static_pointer_cast<GpuResource>(obj->getThisPtr());
 
 
 			// We want the data right away so queue directly to main core thread queue and block until we get it
 			// We want the data right away so queue directly to main core thread queue and block until we get it
-			pixelData->lock();
+			pixelData->_lock();
 			gCoreThread().queueReturnCommand(
 			gCoreThread().queueReturnCommand(
 				std::bind(&RenderSystem::readSubresource, RenderSystem::instancePtr(), sharedTexPtr, subresourceIdx, 
 				std::bind(&RenderSystem::readSubresource, RenderSystem::instancePtr(), sharedTexPtr, subresourceIdx, 
 				std::static_pointer_cast<GpuResourceData>(pixelData), std::placeholders::_1), true);
 				std::static_pointer_cast<GpuResourceData>(pixelData), std::placeholders::_1), true);
@@ -115,7 +115,7 @@ namespace BansheeEngine
 
 
 				GpuResourcePtr sharedTexPtr = std::static_pointer_cast<GpuResource>(texture->getThisPtr());
 				GpuResourcePtr sharedTexPtr = std::static_pointer_cast<GpuResource>(texture->getThisPtr());
 
 
-				pixelData->at(i)->lock();
+				pixelData->at(i)->_lock();
 				gCoreThread().queueReturnCommand(std::bind(&RenderSystem::writeSubresource, RenderSystem::instancePtr(), 
 				gCoreThread().queueReturnCommand(std::bind(&RenderSystem::writeSubresource, RenderSystem::instancePtr(), 
 					sharedTexPtr, subresourceIdx, pixelData->at(i), false, std::placeholders::_1));
 					sharedTexPtr, subresourceIdx, pixelData->at(i), false, std::placeholders::_1));
 			}
 			}

+ 5 - 5
CamelotCore/Include/CmTransientMesh.h

@@ -23,27 +23,27 @@ namespace BansheeEngine
 		 /**
 		 /**
 		 * @copydoc MeshBase::getVertexData
 		 * @copydoc MeshBase::getVertexData
 		 */
 		 */
-		std::shared_ptr<VertexData> getVertexData() const;
+		std::shared_ptr<VertexData> _getVertexData() const;
 
 
 		 /**
 		 /**
 		 * @copydoc MeshBase::getIndexData
 		 * @copydoc MeshBase::getIndexData
 		 */
 		 */
-		std::shared_ptr<IndexData> getIndexData() const;
+		std::shared_ptr<IndexData> _getIndexData() const;
 
 
 		/**
 		/**
 		 * @copydoc MeshBase::getVertexOffset
 		 * @copydoc MeshBase::getVertexOffset
 		 */
 		 */
-		virtual UINT32 getVertexOffset() const;
+		virtual UINT32 _getVertexOffset() const;
 
 
 		 /**
 		 /**
 		 * @copydoc MeshBase::getIndexOffset
 		 * @copydoc MeshBase::getIndexOffset
 		 */
 		 */
-		virtual UINT32 getIndexOffset() const;
+		virtual UINT32 _getIndexOffset() const;
 
 
 		 /**
 		 /**
 		 * @copydoc MeshBase::notifyUsedOnGPU
 		 * @copydoc MeshBase::notifyUsedOnGPU
 		 */
 		 */
-		virtual void notifyUsedOnGPU();
+		virtual void _notifyUsedOnGPU();
 
 
 	protected:
 	protected:
 		friend class MeshHeap;
 		friend class MeshHeap;

+ 2 - 2
CamelotCore/Source/CmCoreThreadAccessor.cpp

@@ -221,7 +221,7 @@ namespace BansheeEngine
 
 
 	AsyncOp CoreThreadAccessorBase::writeSubresource(GpuResourcePtr resource, UINT32 subresourceIdx, const GpuResourceDataPtr& data, bool discardEntireBuffer)
 	AsyncOp CoreThreadAccessorBase::writeSubresource(GpuResourcePtr resource, UINT32 subresourceIdx, const GpuResourceDataPtr& data, bool discardEntireBuffer)
 	{
 	{
-		data->lock();
+		data->_lock();
 
 
 		return mCommandQueue->queueReturn(std::bind(&RenderSystem::writeSubresource, RenderSystem::instancePtr(), resource, 
 		return mCommandQueue->queueReturn(std::bind(&RenderSystem::writeSubresource, RenderSystem::instancePtr(), resource, 
 			subresourceIdx, data, discardEntireBuffer, std::placeholders::_1));
 			subresourceIdx, data, discardEntireBuffer, std::placeholders::_1));
@@ -229,7 +229,7 @@ namespace BansheeEngine
 
 
 	AsyncOp CoreThreadAccessorBase::readSubresource(GpuResourcePtr resource, UINT32 subresourceIdx, const GpuResourceDataPtr& data)
 	AsyncOp CoreThreadAccessorBase::readSubresource(GpuResourcePtr resource, UINT32 subresourceIdx, const GpuResourceDataPtr& data)
 	{
 	{
-		data->lock();
+		data->_lock();
 
 
 		return mCommandQueue->queueReturn(std::bind(&RenderSystem::readSubresource, RenderSystem::instancePtr(), 
 		return mCommandQueue->queueReturn(std::bind(&RenderSystem::readSubresource, RenderSystem::instancePtr(), 
 			resource, subresourceIdx, data, std::placeholders::_1));
 			resource, subresourceIdx, data, std::placeholders::_1));

+ 2 - 2
CamelotCore/Source/CmGpuResourceData.cpp

@@ -90,12 +90,12 @@ namespace BansheeEngine
 		mOwnsData = false;
 		mOwnsData = false;
 	}
 	}
 
 
-	void GpuResourceData::lock() const
+	void GpuResourceData::_lock() const
 	{
 	{
 		mLocked = true;
 		mLocked = true;
 	}
 	}
 
 
-	void GpuResourceData::unlock() const
+	void GpuResourceData::_unlock() const
 	{
 	{
 		mLocked = false;
 		mLocked = false;
 	}
 	}

+ 2 - 2
CamelotCore/Source/CmMesh.cpp

@@ -264,14 +264,14 @@ namespace BansheeEngine
 		return AABox::BOX_EMPTY;
 		return AABox::BOX_EMPTY;
 	}
 	}
 
 
-	std::shared_ptr<VertexData> Mesh::getVertexData() const
+	std::shared_ptr<VertexData> Mesh::_getVertexData() const
 	{
 	{
 		THROW_IF_NOT_CORE_THREAD;
 		THROW_IF_NOT_CORE_THREAD;
 
 
 		return mVertexData;
 		return mVertexData;
 	}
 	}
 
 
-	std::shared_ptr<IndexData> Mesh::getIndexData() const
+	std::shared_ptr<IndexData> Mesh::_getIndexData() const
 	{
 	{
 		THROW_IF_NOT_CORE_THREAD;
 		THROW_IF_NOT_CORE_THREAD;
 
 

+ 1 - 1
CamelotCore/Source/CmMeshRTTI.h

@@ -25,7 +25,7 @@ namespace BansheeEngine
 			MeshDataPtr meshData = obj->allocateSubresourceBuffer(0);
 			MeshDataPtr meshData = obj->allocateSubresourceBuffer(0);
 			GpuResourcePtr sharedMeshPtr = std::static_pointer_cast<GpuResource>(obj->getThisPtr());
 			GpuResourcePtr sharedMeshPtr = std::static_pointer_cast<GpuResource>(obj->getThisPtr());
 
 
-			meshData->lock();
+			meshData->_lock();
 			gCoreThread().queueReturnCommand(std::bind(&RenderSystem::readSubresource, RenderSystem::instancePtr(), 
 			gCoreThread().queueReturnCommand(std::bind(&RenderSystem::readSubresource, RenderSystem::instancePtr(), 
 				sharedMeshPtr, 0, std::static_pointer_cast<GpuResourceData>(meshData), std::placeholders::_1), true);
 				sharedMeshPtr, 0, std::static_pointer_cast<GpuResourceData>(meshData), std::placeholders::_1), true);
 
 

+ 7 - 7
CamelotCore/Source/CmRenderSystem.cpp

@@ -216,7 +216,7 @@ namespace BansheeEngine {
 			mClipPlanesDirty = false;
 			mClipPlanesDirty = false;
 		}
 		}
 
 
-		std::shared_ptr<VertexData> vertexData = mesh->getVertexData();
+		std::shared_ptr<VertexData> vertexData = mesh->_getVertexData();
 
 
 		setVertexDeclaration(vertexData->vertexDeclaration);
 		setVertexDeclaration(vertexData->vertexDeclaration);
 		auto vertexBuffers = vertexData->getBuffers();
 		auto vertexBuffers = vertexData->getBuffers();
@@ -248,18 +248,18 @@ namespace BansheeEngine {
 
 
 		if (useIndices)
 		if (useIndices)
 		{
 		{
-			std::shared_ptr<IndexData> indexData = mesh->getIndexData();
+			std::shared_ptr<IndexData> indexData = mesh->_getIndexData();
 
 
 			if(indexCount == 0)
 			if(indexCount == 0)
 				indexCount = indexData->indexCount;
 				indexCount = indexData->indexCount;
 
 
 			setIndexBuffer(indexData->indexBuffer);
 			setIndexBuffer(indexData->indexBuffer);
-			drawIndexed(indexOffset + mesh->getIndexOffset(), indexCount, mesh->getVertexOffset(), vertexData->vertexCount);
+			drawIndexed(indexOffset + mesh->_getIndexOffset(), indexCount, mesh->_getVertexOffset(), vertexData->vertexCount);
 		}
 		}
 		else
 		else
-			draw(mesh->getVertexOffset(), vertexData->vertexCount);
+			draw(mesh->_getVertexOffset(), vertexData->vertexCount);
 
 
-		mesh->notifyUsedOnGPU();
+		mesh->_notifyUsedOnGPU();
 
 
 		gProfiler().endSample("render");
 		gProfiler().endSample("render");
 	}
 	}
@@ -284,7 +284,7 @@ namespace BansheeEngine {
 
 
 		gProfiler().beginSample("writeSubresourceB");
 		gProfiler().beginSample("writeSubresourceB");
 
 
-		data->unlock();
+		data->_unlock();
 		asyncOp._completeOperation();
 		asyncOp._completeOperation();
 
 
 		gProfiler().endSample("writeSubresourceB");
 		gProfiler().endSample("writeSubresourceB");
@@ -297,7 +297,7 @@ namespace BansheeEngine {
 		gProfiler().beginSample("readSubresource");
 		gProfiler().beginSample("readSubresource");
 
 
 		resource->readSubresource(subresourceIdx, *data);
 		resource->readSubresource(subresourceIdx, *data);
-		data->unlock();
+		data->_unlock();
 		asyncOp._completeOperation();
 		asyncOp._completeOperation();
 
 
 		gProfiler().endSample("readSubresource");
 		gProfiler().endSample("readSubresource");

+ 11 - 45
CamelotCore/Source/CmRenderSystemCapabilities.cpp

@@ -1,37 +1,11 @@
-/*
------------------------------------------------------------------------------
-This source file is part of OGRE
-(Object-oriented Graphics Rendering Engine)
-For the latest info, see http://www.ogre3d.org/
-
-Copyright (c) 2000-2011 Torus Knot Software Ltd
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
------------------------------------------------------------------------------
-*/
 #include "CmRenderSystemCapabilities.h"
 #include "CmRenderSystemCapabilities.h"
 #include "CmException.h"
 #include "CmException.h"
 #include "CmString.h"
 #include "CmString.h"
 
 
-namespace BansheeEngine {
+namespace BansheeEngine 
+{
+	Vector<BansheeEngine::String> RenderSystemCapabilities::msGPUVendorStrings;
 
 
-	//-----------------------------------------------------------------------
 	RenderSystemCapabilities::RenderSystemCapabilities()
 	RenderSystemCapabilities::RenderSystemCapabilities()
 		: mVendor(GPU_UNKNOWN)
 		: mVendor(GPU_UNKNOWN)
 		, mNumWorldMatrices(0)
 		, mNumWorldMatrices(0)
@@ -50,7 +24,8 @@ namespace BansheeEngine {
 		}
 		}
 		mCategoryRelevant[CAPS_CATEGORY_COMMON] = true;
 		mCategoryRelevant[CAPS_CATEGORY_COMMON] = true;
 		mCategoryRelevant[CAPS_CATEGORY_COMMON_2] = true;
 		mCategoryRelevant[CAPS_CATEGORY_COMMON_2] = true;
-		// each rendersystem should enable these
+
+		mCategoryRelevant[CAPS_CATEGORY_D3D11] = false;
 		mCategoryRelevant[CAPS_CATEGORY_D3D9] = false;
 		mCategoryRelevant[CAPS_CATEGORY_D3D9] = false;
 		mCategoryRelevant[CAPS_CATEGORY_GL] = false;
 		mCategoryRelevant[CAPS_CATEGORY_GL] = false;
 
 
@@ -68,13 +43,11 @@ namespace BansheeEngine {
 		mNumUniformBlocksPerStage[GPT_DOMAIN_PROGRAM] = 0;
 		mNumUniformBlocksPerStage[GPT_DOMAIN_PROGRAM] = 0;
 		mNumUniformBlocksPerStage[GPT_COMPUTE_PROGRAM] = 0;
 		mNumUniformBlocksPerStage[GPT_COMPUTE_PROGRAM] = 0;
 	}
 	}
-	//-----------------------------------------------------------------------
+
 	RenderSystemCapabilities::~RenderSystemCapabilities()
 	RenderSystemCapabilities::~RenderSystemCapabilities()
 	{
 	{
 	}
 	}
-	//---------------------------------------------------------------------
-	Vector<BansheeEngine::String> RenderSystemCapabilities::msGPUVendorStrings;
-	//---------------------------------------------------------------------
+
 	GPUVendor RenderSystemCapabilities::vendorFromString(const String& vendorString)
 	GPUVendor RenderSystemCapabilities::vendorFromString(const String& vendorString)
 	{
 	{
 		initVendorStrings();
 		initVendorStrings();
@@ -94,30 +67,23 @@ namespace BansheeEngine {
 		return ret;
 		return ret;
 		
 		
 	}
 	}
-	//---------------------------------------------------------------------
+
 	String RenderSystemCapabilities::vendorToString(GPUVendor v)
 	String RenderSystemCapabilities::vendorToString(GPUVendor v)
 	{
 	{
 		initVendorStrings();
 		initVendorStrings();
 		return msGPUVendorStrings[v];
 		return msGPUVendorStrings[v];
 	}
 	}
-	//---------------------------------------------------------------------
+
 	void RenderSystemCapabilities::initVendorStrings()
 	void RenderSystemCapabilities::initVendorStrings()
 	{
 	{
 		if (msGPUVendorStrings.empty())
 		if (msGPUVendorStrings.empty())
 		{
 		{
-			// Always lower case!
+			// Always lower case
 			msGPUVendorStrings.resize(GPU_VENDOR_COUNT);
 			msGPUVendorStrings.resize(GPU_VENDOR_COUNT);
 			msGPUVendorStrings[GPU_UNKNOWN] = "unknown";
 			msGPUVendorStrings[GPU_UNKNOWN] = "unknown";
 			msGPUVendorStrings[GPU_NVIDIA] = "nvidia";
 			msGPUVendorStrings[GPU_NVIDIA] = "nvidia";
-			msGPUVendorStrings[GPU_ATI] = "ati";
+			msGPUVendorStrings[GPU_AMD] = "amd";
 			msGPUVendorStrings[GPU_INTEL] = "intel";
 			msGPUVendorStrings[GPU_INTEL] = "intel";
-			msGPUVendorStrings[GPU_3DLABS] = "3dlabs";
-			msGPUVendorStrings[GPU_S3] = "s3";
-			msGPUVendorStrings[GPU_MATROX] = "matrox";
-			msGPUVendorStrings[GPU_SIS] = "sis";
-			msGPUVendorStrings[GPU_IMAGINATION_TECHNOLOGIES] = "imagination technologies";
-			msGPUVendorStrings[GPU_APPLE] = "apple";    // iPhone Simulator
 		}
 		}
 	}
 	}
-
 }
 }

+ 1 - 1
CamelotCore/Source/CmTextureManager.cpp

@@ -59,7 +59,7 @@ namespace BansheeEngine
 
 
 		AsyncOp op;
 		AsyncOp op;
 
 
-		data->lock();
+		data->_lock();
 		RenderSystem::instance().writeSubresource(mDummyTexture.getInternalPtr(), mDummyTexture->mapToSubresourceIdx(0, 0), data, false, op);
 		RenderSystem::instance().writeSubresource(mDummyTexture.getInternalPtr(), mDummyTexture->mapToSubresourceIdx(0, 0), data, false, op);
 	}
 	}
 
 

+ 5 - 5
CamelotCore/Source/CmTransientMesh.cpp

@@ -30,27 +30,27 @@ namespace BansheeEngine
 		CM_EXCEPT(InvalidStateException, "Reading is not supported on a transient mesh.");
 		CM_EXCEPT(InvalidStateException, "Reading is not supported on a transient mesh.");
 	}
 	}
 
 
-	std::shared_ptr<VertexData> TransientMesh::getVertexData() const
+	std::shared_ptr<VertexData> TransientMesh::_getVertexData() const
 	{
 	{
 		return mParentHeap->getVertexData();
 		return mParentHeap->getVertexData();
 	}
 	}
 
 
-	std::shared_ptr<IndexData> TransientMesh::getIndexData() const
+	std::shared_ptr<IndexData> TransientMesh::_getIndexData() const
 	{
 	{
 		return mParentHeap->getIndexData();
 		return mParentHeap->getIndexData();
 	}
 	}
 
 
-	UINT32 TransientMesh::getVertexOffset() const
+	UINT32 TransientMesh::_getVertexOffset() const
 	{
 	{
 		return mParentHeap->getVertexOffset(mId);
 		return mParentHeap->getVertexOffset(mId);
 	}
 	}
 
 
-	UINT32 TransientMesh::getIndexOffset() const
+	UINT32 TransientMesh::_getIndexOffset() const
 	{
 	{
 		return mParentHeap->getIndexOffset(mId);
 		return mParentHeap->getIndexOffset(mId);
 	}
 	}
 
 
-	void TransientMesh::notifyUsedOnGPU()
+	void TransientMesh::_notifyUsedOnGPU()
 	{
 	{
 		mParentHeap->notifyUsedOnGPU(mId);
 		mParentHeap->notifyUsedOnGPU(mId);
 	}
 	}

+ 2 - 10
CamelotD3D11RenderSystem/Source/CmD3D11RenderSystem.cpp

@@ -699,6 +699,7 @@ namespace BansheeEngine
 
 
 		RenderSystemCapabilities* rsc = cm_new<RenderSystemCapabilities>();
 		RenderSystemCapabilities* rsc = cm_new<RenderSystemCapabilities>();
 
 
+		rsc->setCategoryRelevant(CAPS_CATEGORY_D3D11, true);
 		rsc->setDriverVersion(mDriverVersion);
 		rsc->setDriverVersion(mDriverVersion);
 		rsc->setDeviceName(mActiveD3DDriver->getDriverDescription());
 		rsc->setDeviceName(mActiveD3DDriver->getDriverDescription());
 		rsc->setRenderSystemName(getName());
 		rsc->setRenderSystemName(getName());
@@ -816,21 +817,12 @@ namespace BansheeEngine
 			rsc->setVendor(GPU_NVIDIA);
 			rsc->setVendor(GPU_NVIDIA);
 			break;
 			break;
 		case 0x1002:
 		case 0x1002:
-			rsc->setVendor(GPU_ATI);
+			rsc->setVendor(GPU_AMD);
 			break;
 			break;
 		case 0x163C:
 		case 0x163C:
 		case 0x8086:
 		case 0x8086:
 			rsc->setVendor(GPU_INTEL);
 			rsc->setVendor(GPU_INTEL);
 			break;
 			break;
-		case 0x5333:
-			rsc->setVendor(GPU_S3);
-			break;
-		case 0x3D3D:
-			rsc->setVendor(GPU_3DLABS);
-			break;
-		case 0x102B:
-			rsc->setVendor(GPU_MATROX);
-			break;
 		default:
 		default:
 			rsc->setVendor(GPU_UNKNOWN);
 			rsc->setVendor(GPU_UNKNOWN);
 			break;
 			break;

+ 3 - 15
CamelotD3D9Renderer/Source/CmD3D9RenderSystem.cpp

@@ -804,7 +804,7 @@ namespace BansheeEngine
 				}
 				}
 
 
 			}
 			}
-			else if ((getCapabilities()->getVendor() == GPU_ATI))
+			else if ((getCapabilities()->getVendor() == GPU_AMD))
 			{
 			{
 				if (enable)
 				if (enable)
 				{
 				{
@@ -1862,24 +1862,12 @@ namespace BansheeEngine
 			rsc->setVendor(GPU_NVIDIA);
 			rsc->setVendor(GPU_NVIDIA);
 			break;
 			break;
 		case 0x1002:
 		case 0x1002:
-			rsc->setVendor(GPU_ATI);
+			rsc->setVendor(GPU_AMD);
 			break;
 			break;
 		case 0x163C:
 		case 0x163C:
 		case 0x8086:
 		case 0x8086:
 			rsc->setVendor(GPU_INTEL);
 			rsc->setVendor(GPU_INTEL);
 			break;
 			break;
-		case 0x5333:
-			rsc->setVendor(GPU_S3);
-			break;
-		case 0x3D3D:
-			rsc->setVendor(GPU_3DLABS);
-			break;
-		case 0x102B:
-			rsc->setVendor(GPU_MATROX);
-			break;
-		case 0x1039:
-			rsc->setVendor(GPU_SIS);
-			break;
 		default:
 		default:
 			rsc->setVendor(GPU_UNKNOWN);
 			rsc->setVendor(GPU_UNKNOWN);
 			break;
 			break;
@@ -1958,7 +1946,7 @@ namespace BansheeEngine
 				}
 				}
 
 
 			}
 			}
-			else if (rsc->getVendor() == GPU_ATI)
+			else if (rsc->getVendor() == GPU_AMD)
 			{
 			{
 				// There is no check on ATI, we have to assume SM3 == support
 				// There is no check on ATI, we have to assume SM3 == support
 				rsc->setCapability(RSC_ALPHA_TO_COVERAGE);
 				rsc->setCapability(RSC_ALPHA_TO_COVERAGE);

+ 2 - 2
CamelotFontImporter/Source/CmFontImporter.cpp

@@ -283,13 +283,13 @@ namespace BansheeEngine
 					PixelDataPtr temp = newTex->allocateSubresourceBuffer(subresourceIdx);
 					PixelDataPtr temp = newTex->allocateSubresourceBuffer(subresourceIdx);
 					PixelUtil::bulkPixelConversion(*pixelData, *temp);
 					PixelUtil::bulkPixelConversion(*pixelData, *temp);
 
 
-					temp->lock();
+					temp->_lock();
 					gCoreThread().queueReturnCommand(std::bind(&RenderSystem::writeSubresource, 
 					gCoreThread().queueReturnCommand(std::bind(&RenderSystem::writeSubresource, 
 						RenderSystem::instancePtr(), newTex.getInternalPtr(), subresourceIdx, temp, false, _1));
 						RenderSystem::instancePtr(), newTex.getInternalPtr(), subresourceIdx, temp, false, _1));
 				}
 				}
 				else
 				else
 				{
 				{
-					pixelData->lock();
+					pixelData->_lock();
 					gCoreThread().queueReturnCommand(std::bind(&RenderSystem::writeSubresource, 
 					gCoreThread().queueReturnCommand(std::bind(&RenderSystem::writeSubresource, 
 						RenderSystem::instancePtr(), newTex.getInternalPtr(), subresourceIdx, pixelData, false, _1));
 						RenderSystem::instancePtr(), newTex.getInternalPtr(), subresourceIdx, pixelData, false, _1));
 				}
 				}

+ 1 - 1
CamelotFreeImgImporter/Source/CmFreeImgImporter.cpp

@@ -140,7 +140,7 @@ namespace BansheeEngine
 
 
 			imgData->getPixels(mip, *src);
 			imgData->getPixels(mip, *src);
 
 
-			src->lock();
+			src->_lock();
 			gCoreThread().queueReturnCommand(std::bind(&RenderSystem::writeSubresource, RenderSystem::instancePtr(), newTexture, subresourceIdx, src, false, _1));
 			gCoreThread().queueReturnCommand(std::bind(&RenderSystem::writeSubresource, RenderSystem::instancePtr(), newTexture, subresourceIdx, src, false, _1));
 		}
 		}
 
 

+ 192 - 163
CamelotGLRenderer/Include/CmGLRenderSystem.h

@@ -136,27 +136,27 @@ namespace BansheeEngine
         /**
         /**
 		 * @copydoc RenderSystem::getColorVertexElementType()
 		 * @copydoc RenderSystem::getColorVertexElementType()
 		 */
 		 */
-        VertexElementType getColorVertexElementType(void) const;
+        VertexElementType getColorVertexElementType() const;
 
 
 		/**
 		/**
 		 * @copydoc RenderSystem::getHorizontalTexelOffset()
 		 * @copydoc RenderSystem::getHorizontalTexelOffset()
 		 */
 		 */
-        float getHorizontalTexelOffset(void);
+        float getHorizontalTexelOffset();
 
 
 		/**
 		/**
 		 * @copydoc RenderSystem::getVerticalTexelOffset()
 		 * @copydoc RenderSystem::getVerticalTexelOffset()
 		 */
 		 */
-        float getVerticalTexelOffset(void);
+        float getVerticalTexelOffset();
 
 
 		/**
 		/**
 		 * @copydoc RenderSystem::getMinimumDepthInputValue()
 		 * @copydoc RenderSystem::getMinimumDepthInputValue()
 		 */
 		 */
-        float getMinimumDepthInputValue(void);
+        float getMinimumDepthInputValue();
 
 
 		 /**
 		 /**
 		 * @copydoc RenderSystem::getMaximumDepthInputValue()
 		 * @copydoc RenderSystem::getMaximumDepthInputValue()
 		 */
 		 */
-        float getMaximumDepthInputValue(void);
+        float getMaximumDepthInputValue();
 
 
 		/**
 		/**
 		 * @copydoc RenderSystem::convertProjectionMatrix()
 		 * @copydoc RenderSystem::convertProjectionMatrix()
@@ -168,9 +168,19 @@ namespace BansheeEngine
 		/* 				Internal use by OpenGL RenderSystem only                */
 		/* 				Internal use by OpenGL RenderSystem only                */
 		/************************************************************************/
 		/************************************************************************/
 
 
-		bool isContextInitialized() const { return mGLInitialised; }
+		/**
+		 * @brief	Query has the main context been initialized.
+		 */
+		bool _isContextInitialized() const { return mGLInitialised; }
 
 
+		/**
+		 * @brief	Returns main context. Caller must ensure the context has been initialized.
+		 */
 		GLContext* getMainContext() const { return mMainContext; } 
 		GLContext* getMainContext() const { return mMainContext; } 
+
+		/**
+		 * @brief	Returns a support object you may use for creating
+		 */
 		GLSupport* getGLSupport() const { return mGLSupport; }
 		GLSupport* getGLSupport() const { return mGLSupport; }
 
 
 	protected:
 	protected:
@@ -194,20 +204,61 @@ namespace BansheeEngine
 		*/
 		*/
 		void endDraw();
 		void endDraw();
 
 
+		/**
+		 * @brief	Clear a part of a render target.
+		 */
 		void clearArea(UINT32 buffers, const Color& color = Color::Black, float depth = 1.0f, UINT16 stencil = 0, const RectI& clearArea = RectI::EMPTY);
 		void clearArea(UINT32 buffers, const Color& color = Color::Black, float depth = 1.0f, UINT16 stencil = 0, const RectI& clearArea = RectI::EMPTY);
 
 
+		/**
+		 * @brief	Set up clip planes against which all geometry will get clipped.
+		 */
 		void setClipPlanesImpl(const PlaneList& clipPlanes);
 		void setClipPlanesImpl(const PlaneList& clipPlanes);
-		bool activateGLTextureUnit(UINT16 unit);
 
 
+		/**
+		 * @brief	Set up a clip plane at a specific clip plane index. If enabled,
+		 *			geometry will be clipped against the positive side of the plane.
+		 *
+		 * @note	Valid index range is [0, 5].
+		 */
         void setClipPlane(UINT16 index, float A, float B, float C, float D);
         void setClipPlane(UINT16 index, float A, float B, float C, float D);
+
+		/**
+		 * @brief	Enable or disable clipping against a clip plane at the specified index.
+		 *
+		 * @note	Valid index range is [0, 5].
+		 */
         void enableClipPlane (UINT16 index, bool enable);
         void enableClipPlane (UINT16 index, bool enable);
 
 
+		/**
+		* @brief	Changes the currently active texture unit. Any texture related operations
+		*			will then be performed on this unit.
+		*/
+		bool activateGLTextureUnit(UINT16 unit);
+
+		/**
+		 * @brief	Changes the active GPU program.
+		 */
 		void setActiveProgram(GpuProgramType gptype, GLSLGpuProgramPtr program);
 		void setActiveProgram(GpuProgramType gptype, GLSLGpuProgramPtr program);
+
+		/**
+		 * @brief	Retrieves the active GPU program of the specified type.
+		 */
 		GLSLGpuProgramPtr getActiveProgram(GpuProgramType gptype) const;
 		GLSLGpuProgramPtr getActiveProgram(GpuProgramType gptype) const;
 
 
-		GLint getBlendMode(BlendFactor ogreBlend) const;
+		/**
+		 * @brief	Converts Banshee blend mode to OpenGL blend mode.
+		 */
+		GLint getBlendMode(BlendFactor blendMode) const;
+
+		/**
+		* @brief	Converts Banshee texture addressing mode to OpenGL texture addressing mode.
+		*/
 		GLint getTextureAddressingMode(TextureAddressingMode tam) const;
 		GLint getTextureAddressingMode(TextureAddressingMode tam) const;
-		GLfloat getCurrentAnisotropy(UINT16 unit);
+
+		/**
+		 * @brief	Gets a combined min/mip filter value usable by OpenGL from the currently
+		 *			set min and mip filters.
+		 */
 		GLuint getCombinedMinMipFilter() const;
 		GLuint getCombinedMinMipFilter() const;
 
 
 		/**
 		/**
@@ -230,222 +281,189 @@ namespace BansheeEngine
 		*/
 		*/
 		GLint getGLDrawMode() const;
 		GLint getGLDrawMode() const;
 
 
-		void initializeContext(GLContext* primary);
+		/**
+		 * @brief	Creates render system capabilities that specify which features are
+		 *			or aren't supported.
+		 */
 		RenderSystemCapabilities* createRenderSystemCapabilities() const;
 		RenderSystemCapabilities* createRenderSystemCapabilities() const;
-		void initialiseFromRenderSystemCapabilities(RenderSystemCapabilities* caps);
-		/** One time initialization for the RenderState of a context. Things that
-		only need to be set once, like the LightingModel can be defined here.
-		*/
-		void oneTimeContextInitialization();
-		/** Switch GL context, dealing with involved internal cached states too
-		*/
-		void switchContext(GLContext *context);
+
+		/**
+		 * @brief	Finish initialization by setting up any systems dependant on render system
+		 *			capabilities.
+		 */
+		void initFromCaps(RenderSystemCapabilities* caps);
+
+		/**
+		 * @brief	Switch the currently used OpenGL context. You will need to re-bind
+		 *			any previously bound values manually. (e.g. textures, gpu programs and such)
+		 */
+		void switchContext(GLContext* context);
 
 
 		/************************************************************************/
 		/************************************************************************/
 		/* 								Sampler states                     		*/
 		/* 								Sampler states                     		*/
 		/************************************************************************/
 		/************************************************************************/
 
 
-		/** Sets the texture addressing mode for a texture unit.*/
+		/**
+		 * @brief	Sets the texture addressing mode for a texture unit. This determines
+		 *			how are UV address values outside of [0, 1] range handled when sampling
+		 *			from texture.
+		 */
         void setTextureAddressingMode(UINT16 stage, const UVWAddressingMode& uvw);
         void setTextureAddressingMode(UINT16 stage, const UVWAddressingMode& uvw);
 
 
-		/** Sets the texture border color for a texture unit.*/
+		/**
+		 * @brief	Sets the texture border color for a texture unit. Border color
+		 *			determines color returned by the texture sampler when border addressing mode
+		 *			is used and texture address is outside of [0, 1] range.
+		 */
         void setTextureBorderColor(UINT16 stage, const Color& color);
         void setTextureBorderColor(UINT16 stage, const Color& color);
 
 
-		/** Sets the mipmap bias value for a given texture unit.
-		@remarks
-		This allows you to adjust the mipmap calculation up or down for a
-		given texture unit. Negative values force a larger mipmap to be used, 
-		positive values force a smaller mipmap to be used. Units are in numbers
-		of levels, so +1 forces the mipmaps to one smaller level.
-		@note Only does something if render system has capability RSC_MIPMAP_LOD_BIAS.
-		*/
+		/**
+		 * @brief	Sets the mipmap bias value for a given texture unit. Bias allows
+		 *			you to adjust the mipmap selection calculation. Negative values force a
+		 *			larger mipmap to be used, and positive values smaller. Units are in values
+		 *			of mip levels, so -1 means use a mipmap one level higher than default.
+		 */
 		void setTextureMipmapBias(UINT16 unit, float bias);
 		void setTextureMipmapBias(UINT16 unit, float bias);
 
 
-		/** Sets a single filter for a given texture unit.
-		@param unit The texture unit to set the filtering options for
-		@param ftype The filter type
-		@param filter The filter to be used
-		*/
+		/**
+		 * @brief	Allows you to specify how is the texture bound to the specified texture unit filtered.
+		 *			Different filter types are used for different situations like magnifying or minifying a texture.
+		 */
         void setTextureFiltering(UINT16 unit, FilterType ftype, FilterOptions filter);
         void setTextureFiltering(UINT16 unit, FilterType ftype, FilterOptions filter);
 
 
-		/** Sets the maximal anisotropy for the specified texture unit.*/
+		/**
+		 * @brief	Sets anisotropy value for the specified texture unit.
+		 */
 		void setTextureAnisotropy(UINT16 unit, UINT32 maxAnisotropy);
 		void setTextureAnisotropy(UINT16 unit, UINT32 maxAnisotropy);
 
 
+		/**
+		 * @brief	Gets anisotropy value for the specified texture unit.
+		 */
+		GLfloat getCurrentAnisotropy(UINT16 unit);
+
 		/************************************************************************/
 		/************************************************************************/
 		/* 								Blend states                      		*/
 		/* 								Blend states                      		*/
 		/************************************************************************/
 		/************************************************************************/
 
 
-		/** Sets the global blending factors for combining subsequent renders with the existing frame contents.
-		The result of the blending operation is:</p>
-		<p align="center">final = (texture * sourceFactor) + (pixel * destFactor)</p>
-		Each of the factors is specified as one of a number of options, as specified in the SceneBlendFactor
-		enumerated type.
-		By changing the operation you can change addition between the source and destination pixels to a different operator.
-		@param sourceFactor The source factor in the above calculation, i.e. multiplied by the texture colour components.
-		@param destFactor The destination factor in the above calculation, i.e. multiplied by the pixel colour components.
-		@param op The blend operation mode for combining pixels
-		*/
-		void setSceneBlending( BlendFactor sourceFactor, BlendFactor destFactor, BlendOperation op );
-
-		/** Sets the global blending factors for combining subsequent renders with the existing frame contents.
-		The result of the blending operation is:</p>
-		<p align="center">final = (texture * sourceFactor) + (pixel * destFactor)</p>
-		Each of the factors is specified as one of a number of options, as specified in the SceneBlendFactor
-		enumerated type.
-		@param sourceFactor The source factor in the above calculation, i.e. multiplied by the texture colour components.
-		@param destFactor The destination factor in the above calculation, i.e. multiplied by the pixel colour components.
-		@param sourceFactorAlpha The source factor in the above calculation for the alpha channel, i.e. multiplied by the texture alpha components.
-		@param destFactorAlpha The destination factor in the above calculation for the alpha channel, i.e. multiplied by the pixel alpha components.
-		@param op The blend operation mode for combining pixels
-		@param alphaOp The blend operation mode for combining pixel alpha values
-		*/
-		void setSceneBlending( BlendFactor sourceFactor, BlendFactor destFactor, BlendFactor sourceFactorAlpha, 
-			BlendFactor destFactorAlpha, BlendOperation op, BlendOperation alphaOp );
+		/**
+		 * @brief	Sets up blending mode that allows you to combine new pixels with pixels already in the render target.
+		 *			Final pixel value = (renderTargetPixel * sourceFactor) op (pixel * destFactor).
+		 */
+		void setSceneBlending(BlendFactor sourceFactor, BlendFactor destFactor, BlendOperation op);
 
 
-		/** Sets the global alpha rejection approach for future renders.
-		By default images are rendered regardless of texture alpha. This method lets you change that.
-		@param func The comparison function which must pass for a pixel to be written.
-		@param val The value to compare each pixels alpha value to (0-255)
+		/**
+		* @brief	Sets up blending mode that allows you to combine new pixels with pixels already in the render target.
+		*			Allows you to set up separate blend operations for alpha values.
+		*	
+		*			Final pixel value = (renderTargetPixel * sourceFactor) op (pixel * destFactor). (And the same for alpha)
 		*/
 		*/
+		void setSceneBlending(BlendFactor sourceFactor, BlendFactor destFactor, BlendFactor sourceFactorAlpha, 
+			BlendFactor destFactorAlpha, BlendOperation op, BlendOperation alphaOp);
+
+		/**
+		 * @brief	Sets alpha test that allows you to reject pixels that fail the comparison function
+		 *			versus the provided reference value.
+		 */
 		void setAlphaTest(CompareFunction func, unsigned char value);
 		void setAlphaTest(CompareFunction func, unsigned char value);
 
 
 		/**
 		/**
-		 * @brief	Enable alpha coverage if supported.
+		 * @brief	Enable alpha to coverage. Alpha to coverage allows you to perform blending without needing 
+		 *			to worry about order of rendering like regular blending does. It requires multi-sampling to 
+		 *			be active in order to work, and you need to supply an alpha texture that determines object transparency.
 		 */
 		 */
 		void setAlphaToCoverage(bool enabled);
 		void setAlphaToCoverage(bool enabled);
 
 
-		/** Sets whether or not colour buffer writing is enabled, and for which channels. 
-		@remarks
-		For some advanced effects, you may wish to turn off the writing of certain colour
-		channels, or even all of the colour channels so that only the depth buffer is updated
-		in a rendering pass. However, the chances are that you really want to use this option
-		through the Material class.
-		@param red, green, blue, alpha Whether writing is enabled for each of the 4 colour channels. */
+		/**
+		 * @brief	Enables or disables writing to certain color channels of the render target.
+		 */
 		void setColorBufferWriteEnabled(bool red, bool green, bool blue, bool alpha);
 		void setColorBufferWriteEnabled(bool red, bool green, bool blue, bool alpha);
 
 
 		/************************************************************************/
 		/************************************************************************/
 		/* 								Rasterizer states                  		*/
 		/* 								Rasterizer states                  		*/
 		/************************************************************************/
 		/************************************************************************/
 
 
-		/** Sets the culling mode for the render system based on the 'vertex winding'.
-		A typical way for the rendering engine to cull triangles is based on the
-		'vertex winding' of triangles. Vertex winding refers to the direction in
-		which the vertices are passed or indexed to in the rendering operation as viewed
-		from the camera, and will wither be clockwise or anticlockwise (that's 'counterclockwise' for
-		you Americans out there ;) The default is CULL_CLOCKWISE i.e. that only triangles whose vertices
-		are passed/indexed in anticlockwise order are rendered - this is a common approach and is used in 3D studio models
-		for example. You can alter this culling mode if you wish but it is not advised unless you know what you are doing.
-		You may wish to use the CULL_NONE option for mesh data that you cull yourself where the vertex
-		winding is uncertain.
-		*/
+		/**
+		 * @brief	Sets vertex winding order. Normally you would use this to cull back facing
+		 *			polygons.
+		 */
 		void setCullingMode(CullingMode mode);
 		void setCullingMode(CullingMode mode);
 
 
-		/** Sets how to rasterise triangles, as points, wireframe or solid polys. */
+		/**
+		 * @brief	Sets the polygon rasterization mode. Determines how are polygons interpreted.
+		 */
 		void setPolygonMode(PolygonMode level);
 		void setPolygonMode(PolygonMode level);
 
 
-		/** Sets the depth bias, NB you should use the Material version of this. 
-		@remarks
-		When polygons are coplanar, you can get problems with 'depth fighting' where
-		the pixels from the two polys compete for the same screen pixel. This is particularly
-		a problem for decals (polys attached to another surface to represent details such as
-		bulletholes etc.).
-		@par
-		A way to combat this problem is to use a depth bias to adjust the depth buffer value
-		used for the decal such that it is slightly higher than the true value, ensuring that
-		the decal appears on top.
-		@note
-		The final bias value is a combination of a constant bias and a bias proportional
-		to the maximum depth slope of the polygon being rendered. The final bias
-		is constantBias + slopeScaleBias * maxslope. Slope scale biasing is
-		generally preferable but is not available on older hardware.
-		@param constantBias The constant bias value, expressed as a value in 
-		homogeneous depth coordinates.
-		@param slopeScaleBias The bias value which is factored by the maximum slope
-		of the polygon, see the description above. This is not supported by all
-		cards.
-
-		*/
+		/**
+		 * @brief	Sets a depth bias that will offset the depth values of new pixels by the specified amount.
+		 *			Final depth bias value is a combination of the constant depth bias and slope depth bias.
+		 *			Slope depth bias has more effect the higher the slope of the rendered polygon.
+		 *
+		 * @note	This is useful if you want to avoid z fighting for objects at the same or similar depth.
+		 */
 		void setDepthBias(float constantBias, float slopeScaleBias);
 		void setDepthBias(float constantBias, float slopeScaleBias);
 
 
 		/**
 		/**
-		* @brief	Scissor test allows you to 'mask off' rendering in all but a given rectangular area
-		* 			identified by the rectangle set by setScissorRect().
-		*/
+		 * @brief	Scissor test allows you to mask off rendering in all but a given rectangular area
+		 * 			identified by the rectangle set by setScissorRect().
+		 */
 		void setScissorTestEnable(bool enable);
 		void setScissorTestEnable(bool enable);
 
 
 		/************************************************************************/
 		/************************************************************************/
 		/* 						Depth stencil state                      		*/
 		/* 						Depth stencil state                      		*/
 		/************************************************************************/
 		/************************************************************************/
 		
 		
-		/** Sets the mode of operation for depth buffer tests from this point onwards.
-		Sometimes you may wish to alter the behaviour of the depth buffer to achieve
-		special effects. Because it's unlikely that you'll set these options for an entire frame,
-		but rather use them to tweak settings between rendering objects, this is an internal
-		method (indicated by the '_' prefix) which will be used by a SceneManager implementation
-		rather than directly from the client application.
-		If this method is never called the settings are automatically the same as the default parameters.
-		@param depthTest If true, the depth buffer is tested for each pixel and the frame buffer is only updated
-		if the depth function test succeeds. If false, no test is performed and pixels are always written.
-		@param depthWrite If true, the depth buffer is updated with the depth of the new pixel if the depth test succeeds.
-		If false, the depth buffer is left unchanged even if a new pixel is written.
-		@param depthFunction Sets the function required for the depth test.
-		*/
-		void setDepthBufferParams(bool depthTest = true, bool depthWrite = true, CompareFunction depthFunction = CMPF_LESS_EQUAL);
-
-		/** Sets whether or not the depth buffer check is performed before a pixel write.
-		@param enabled If true, the depth buffer is tested for each pixel and the frame buffer is only updated
-		if the depth function test succeeds. If false, no test is performed and pixels are always written.
-		*/
+		/**
+		 * @brief	Should new pixels perform depth testing using the set depth comparison function before
+		 *			being written.
+		 */
 		void setDepthBufferCheckEnabled(bool enabled = true);
 		void setDepthBufferCheckEnabled(bool enabled = true);
 
 
-		/** Sets whether or not the depth buffer is updated after a pixel write.
-		@param enabled If true, the depth buffer is updated with the depth of the new pixel if the depth test succeeds.
-		If false, the depth buffer is left unchanged even if a new pixel is written.
-		*/
+		/**
+		 * @brief	Should new pixels write to the depth buffer.
+		 */
 		void setDepthBufferWriteEnabled(bool enabled = true);
 		void setDepthBufferWriteEnabled(bool enabled = true);
 
 
-		/** Sets the comparison function for the depth buffer check.
-		Advanced use only - allows you to choose the function applied to compare the depth values of
-		new and existing pixels in the depth buffer. Only an issue if the deoth buffer check is enabled
-		(see _setDepthBufferCheckEnabled)
-		@param  func The comparison between the new depth and the existing depth which must return true
-		for the new pixel to be written.
-		*/
+		/**
+		 * @brief	Sets comparison function used for depth testing. Determines how are new and existing
+		 *			pixel values compared - if comparison function returns true the new pixel is written.
+		 */
 		void setDepthBufferFunction(CompareFunction func = CMPF_LESS_EQUAL);
 		void setDepthBufferFunction(CompareFunction func = CMPF_LESS_EQUAL);
 
 
-		/** Turns stencil buffer checking on or off.
-		@remarks
-		Stencilling (masking off areas of the rendering target based on the stencil
-		buffer) can be turned on or off using this method. By default, stencilling is
-		disabled.
-		*/
+		/**
+		 * @brief	Turns stencil tests on or off. By default this is disabled.
+		 *			Stencil testing allow you to mask out a part of the rendered image by using
+		 *			various stencil operations provided.
+		 */
 		void setStencilCheckEnabled(bool enabled);
 		void setStencilCheckEnabled(bool enabled);
 
 
-		/** This method allows you to set stencil buffer operations in one call.
-		@param stencilFailOp The action to perform when the stencil check fails
-		@param depthFailOp The action to perform when the stencil check passes, but the
-		depth buffer check still fails
-		@param passOp The action to take when both the stencil and depth check pass.
-		@param ccw If set to true, the stencil operations will be applied to counterclockwise
-		faces. Otherwise they will be applied to clockwise faces.
-		*/
+		/**
+		 * @brief	Allows you to set stencil operations that are performed when stencil test passes or fails.
+		 *
+		 * @param	stencilFailOp	Operation executed when stencil test fails.
+		 * @param	depthFailOp		Operation executed when stencil test succeeds but depth test fails.
+		 * @param	passOp			Operation executed when stencil test succeeds and depth test succeeds.
+		 * @param	front			Should the stencil operations be applied to front or back facing polygons.
+		 */
 		void setStencilBufferOperations(StencilOperation stencilFailOp = SOP_KEEP,
 		void setStencilBufferOperations(StencilOperation stencilFailOp = SOP_KEEP,
 			StencilOperation depthFailOp = SOP_KEEP, StencilOperation passOp = SOP_KEEP,
 			StencilOperation depthFailOp = SOP_KEEP, StencilOperation passOp = SOP_KEEP,
 			bool front = true);
 			bool front = true);
 
 
 		/**
 		/**
-		* @brief	Sets a stencil buffer comparison function. The result of this will cause one of 3 actions depending on whether the test fails,
-		*		succeeds but with the depth buffer check still failing, or succeeds with the
-		*		depth buffer check passing too.
-		* @param mask The bitmask applied to both the stencil value and the reference value
-		*		before comparison
-		* @param ccw If set to true, the stencil operations will be applied to counterclockwise
-		*		faces. Otherwise they will be applied to clockwise faces.
+		 * @brief	Sets a stencil buffer comparison function. The result of this will cause one of 3 actions 
+		 *			depending on whether the test fails, succeeds but with the depth buffer check still failing, 
+		 *			or succeeds with the depth buffer check passing too.
+		 *
+		 * @param func	Comparison function that determines whether a stencil test fails or passes. Reference value
+		 *				gets compared to the value already in the buffer using this function.
+		 * @param mask	The bitmask applied to both the stencil value and the reference value
+		 *				before comparison
+		 * @param ccw	If set to true, the stencil operations will be applied to counterclockwise
+		 *				faces. Otherwise they will be applied to clockwise faces.
 		 */
 		 */
 		void setStencilBufferFunc(CompareFunction func = CMPF_ALWAYS_PASS, UINT32 mask = 0xFFFFFFFF, bool front = true);
 		void setStencilBufferFunc(CompareFunction func = CMPF_ALWAYS_PASS, UINT32 mask = 0xFFFFFFFF, bool front = true);
 
 
 		/**
 		/**
-		* @brief	The bitmask applied to the stencil value before writing it to the stencil buffer.
+		 * @brief	The bitmask applied to the stencil value before writing it to the stencil buffer.
 		 */
 		 */
 		void setStencilBufferWriteMask(UINT32 mask = 0xFFFFFFFF);
 		void setStencilBufferWriteMask(UINT32 mask = 0xFFFFFFFF);
 
 
@@ -459,14 +477,25 @@ namespace BansheeEngine
 		/* 							UTILITY METHODS                      		*/
 		/* 							UTILITY METHODS                      		*/
 		/************************************************************************/
 		/************************************************************************/
 
 
+		/**
+		 * @brief	Converts the provided matrix m into a representation usable by OpenGL.
+		 */
 		void makeGLMatrix(GLfloat gl_matrix[16], const Matrix4& m);
 		void makeGLMatrix(GLfloat gl_matrix[16], const Matrix4& m);
 
 
+		/**
+		 * @brief	Converts the engine depth/stencil compare function into OpenGL representation.
+		 */
 		GLint convertCompareFunction(CompareFunction func) const;
 		GLint convertCompareFunction(CompareFunction func) const;
+
+		/**
+		 * @brief	Convers the engine stencil operation in OpenGL representation. Optionally inverts
+		 *			the operation (increment becomes decrement, etc.).
+		 */
 		GLint convertStencilOp(StencilOperation op, bool invert = false) const;
 		GLint convertStencilOp(StencilOperation op, bool invert = false) const;
 
 
 		/**
 		/**
-		* @brief	Checks if there are any OpenGL errors and prints them to the log.
-		*/
+		 * @brief	Checks if there are any OpenGL errors and prints them to the log.
+		 */
 		bool checkForErrors() const;
 		bool checkForErrors() const;
 
 
 	private:
 	private:

+ 1 - 1
CamelotGLRenderer/Include/CmGLSupport.h

@@ -58,7 +58,7 @@ namespace BansheeEngine
 		/** Initialises GL extensions, must be done AFTER the GL context has been
 		/** Initialises GL extensions, must be done AFTER the GL context has been
 			established.
 			established.
 		*/
 		*/
-		virtual void initialiseExtensions();
+		virtual void initializeExtensions();
 
 
 	protected:
 	protected:
 		Set<String> extensionList;
 		Set<String> extensionList;

+ 1 - 1
CamelotGLRenderer/Include/CmWin32GLSupport.h

@@ -32,7 +32,7 @@ namespace BansheeEngine
 		/**
 		/**
 		 * Initialize extensions
 		 * Initialize extensions
 		 */
 		 */
-		virtual void initialiseExtensions();
+		virtual void initializeExtensions();
 		
 		
 		Win32Context* createContext(HDC hdc, HGLRC externalGlrc = 0);
 		Win32Context* createContext(HDC hdc, HGLRC externalGlrc = 0);
 
 

+ 1 - 1
CamelotGLRenderer/Source/CmGLHardwareBufferManager.cpp

@@ -67,7 +67,7 @@ namespace BansheeEngine {
 		// Win32 machines with ATI GPU are having issues glMapBuffer, looks like buffer corruption
 		// Win32 machines with ATI GPU are having issues glMapBuffer, looks like buffer corruption
 		// disable for now until we figure out where the problem lies			
 		// disable for now until we figure out where the problem lies			
 #	if CM_PLATFORM == CM_PLATFORM_WIN32
 #	if CM_PLATFORM == CM_PLATFORM_WIN32
-		if (BansheeEngine::RenderSystem::instancePtr()->getCapabilities()->getVendor() == GPU_ATI) 
+		if (BansheeEngine::RenderSystem::instancePtr()->getCapabilities()->getVendor() == GPU_AMD) 
 		{
 		{
 			mMapBufferThreshold = 0xffffffffUL  /* maximum unsigned long value */;
 			mMapBufferThreshold = 0xffffffffUL  /* maximum unsigned long value */;
 		}
 		}

+ 61 - 141
CamelotGLRenderer/Source/CmGLRenderSystem.cpp

@@ -119,9 +119,17 @@ namespace BansheeEngine
 		// Get the context from the window and finish initialization
 		// Get the context from the window and finish initialization
 		GLContext *context = nullptr;
 		GLContext *context = nullptr;
 		primaryWindow->getCustomAttribute("GLCONTEXT", &context);
 		primaryWindow->getCustomAttribute("GLCONTEXT", &context);
-		initializeContext(context);
 
 
-		checkForErrors();
+		// Set main and current context
+		mMainContext = context;
+		mCurrentContext = mMainContext;
+
+		// Set primary context as active
+		if (mCurrentContext)
+			mCurrentContext->setCurrent();
+
+		// Setup GLSupport
+		mGLSupport->initializeExtensions();
 
 
 		Vector<BansheeEngine::String> tokens = StringUtil::split(mGLSupport->getGLVersion(), ".");
 		Vector<BansheeEngine::String> tokens = StringUtil::split(mGLSupport->getGLVersion(), ".");
 
 
@@ -136,15 +144,7 @@ namespace BansheeEngine
 		mDriverVersion.build = 0;
 		mDriverVersion.build = 0;
 
 
 		mCurrentCapabilities = createRenderSystemCapabilities();
 		mCurrentCapabilities = createRenderSystemCapabilities();
-		checkForErrors();
-
-		initialiseFromRenderSystemCapabilities(mCurrentCapabilities);
-		checkForErrors();
-
-		// Initialise the main context
-		oneTimeContextInitialization();
-		checkForErrors();
-
+		initFromCaps(mCurrentCapabilities);
 		mGLInitialised = true;
 		mGLInitialised = true;
 
 
 		RenderSystem::initialize_internal(asyncOp);
 		RenderSystem::initialize_internal(asyncOp);
@@ -304,7 +304,7 @@ namespace BansheeEngine
 			if(iter->second.slot == 0)
 			if(iter->second.slot == 0)
 			{
 			{
 				// 0 means uniforms are not in block, in which case we handle it specially
 				// 0 means uniforms are not in block, in which case we handle it specially
-				if(uniformBufferData == nullptr)
+				if (uniformBufferData == nullptr && paramBlockBuffer->getSize() > 0)
 				{
 				{
 					uniformBufferData = (UINT8*)cm_alloc<ScratchAlloc>(paramBlockBuffer->getSize());
 					uniformBufferData = (UINT8*)cm_alloc<ScratchAlloc>(paramBlockBuffer->getSize());
 					paramBlockBuffer->readData(uniformBufferData);
 					paramBlockBuffer->readData(uniformBufferData);
@@ -815,7 +815,7 @@ namespace BansheeEngine
 		GLfloat border[4] = { colour.r, colour.g, colour.b, colour.a };
 		GLfloat border[4] = { colour.r, colour.g, colour.b, colour.a };
 		if (activateGLTextureUnit(stage))
 		if (activateGLTextureUnit(stage))
 		{
 		{
-			glTexParameterfv( mTextureTypes[stage], GL_TEXTURE_BORDER_COLOR, border);
+			glTexParameterfv(mTextureTypes[stage], GL_TEXTURE_BORDER_COLOR, border);
 			activateGLTextureUnit(0);
 			activateGLTextureUnit(0);
 		}
 		}
 	}
 	}
@@ -826,7 +826,7 @@ namespace BansheeEngine
 		{
 		{
 			if (activateGLTextureUnit(stage))
 			if (activateGLTextureUnit(stage))
 			{
 			{
-				glTexEnvf(GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, bias);
+				glTexParameterf(mTextureTypes[stage], GL_TEXTURE_LOD_BIAS, bias);
 				activateGLTextureUnit(0);
 				activateGLTextureUnit(0);
 			}
 			}
 		}
 		}
@@ -1034,13 +1034,6 @@ namespace BansheeEngine
 		glCullFace( cullMode );
 		glCullFace( cullMode );
 	}
 	}
 
 
-	void GLRenderSystem::setDepthBufferParams(bool depthTest, bool depthWrite, CompareFunction depthFunction)
-	{
-		setDepthBufferCheckEnabled(depthTest);
-		setDepthBufferWriteEnabled(depthWrite);
-		setDepthBufferFunction(depthFunction);
-	}
-
 	void GLRenderSystem::setDepthBufferCheckEnabled(bool enabled)
 	void GLRenderSystem::setDepthBufferCheckEnabled(bool enabled)
 	{
 	{
 		if (enabled)
 		if (enabled)
@@ -1233,15 +1226,6 @@ namespace BansheeEngine
 		size_t numClipPlanes;
 		size_t numClipPlanes;
 		GLdouble clipPlane[4];
 		GLdouble clipPlane[4];
 
 
-		// Save previous modelview
-		glMatrixMode(GL_MODELVIEW);
-		glPushMatrix();
-
-		// Just load view matrix (identity world)
-		GLfloat mat[16];
-		makeGLMatrix(mat, mViewMatrix);
-		glLoadMatrixf(mat);
-
 		numClipPlanes = clipPlanes.size();
 		numClipPlanes = clipPlanes.size();
 		for (i = 0; i < numClipPlanes; ++i)
 		for (i = 0; i < numClipPlanes; ++i)
 		{
 		{
@@ -1267,9 +1251,6 @@ namespace BansheeEngine
 		{
 		{
 			glDisable(static_cast<GLenum>(GL_CLIP_PLANE0 + i));
 			glDisable(static_cast<GLenum>(GL_CLIP_PLANE0 + i));
 		}
 		}
-
-		// Restore matrices
-		glPopMatrix();
 	}
 	}
 
 
 	bool GLRenderSystem::activateGLTextureUnit(UINT16 unit)
 	bool GLRenderSystem::activateGLTextureUnit(UINT16 unit)
@@ -1336,6 +1317,10 @@ namespace BansheeEngine
 
 
 		const VertexDeclaration::VertexElementList& inputAttributes = mCurrentVertexProgram->getGLSLProgram()->getInputAttributes().getElements();
 		const VertexDeclaration::VertexElementList& inputAttributes = mCurrentVertexProgram->getGLSLProgram()->getInputAttributes().getElements();
 
 
+		GLuint VAOID[1];
+		glGenVertexArrays(1, &VAOID[0]);
+		glBindVertexArray(VAOID[0]);
+
 		for (elem = decl.begin(); elem != elemEnd; ++elem)
 		for (elem = decl.begin(); elem != elemEnd; ++elem)
 		{
 		{
 			auto iterFind = mBoundVertexBuffers.find(elem->getStreamIdx());
 			auto iterFind = mBoundVertexBuffers.find(elem->getStreamIdx());
@@ -1381,7 +1366,7 @@ namespace BansheeEngine
 				break;
 				break;
 			};
 			};
 
 
-			glVertexAttribPointerARB(
+			glVertexAttribPointer(
 				attribLocation,
 				attribLocation,
 				typeCount, 
 				typeCount, 
 				GLHardwareBufferManager::getGLType(elem->getType()), 
 				GLHardwareBufferManager::getGLType(elem->getType()), 
@@ -1408,8 +1393,6 @@ namespace BansheeEngine
 			glDisableVertexAttribArray(*ai); 
 			glDisableVertexAttribArray(*ai); 
 		}
 		}
 
 
-		glColor4f(1,1,1,1);
-
 		mBoundAttributes.clear();
 		mBoundAttributes.clear();
 	}
 	}
 
 
@@ -1556,7 +1539,6 @@ namespace BansheeEngine
 		case TAM_BORDER:
 		case TAM_BORDER:
 			return GL_CLAMP_TO_BORDER;
 			return GL_CLAMP_TO_BORDER;
 		}
 		}
-
 	}
 	}
 
 
 	GLint GLRenderSystem::getGLDrawMode() const
 	GLint GLRenderSystem::getGLDrawMode() const
@@ -1692,24 +1674,7 @@ namespace BansheeEngine
 		}
 		}
 	}
 	}
 
 
-	void GLRenderSystem::initializeContext(GLContext* primary)
-	{
-		// Set main and current context
-		mMainContext = primary;
-		mCurrentContext = mMainContext;
-
-		// Set primary context as active
-		if(mCurrentContext)
-			mCurrentContext->setCurrent();
-
-		// Setup GLSupport
-		mGLSupport->initialiseExtensions();
-
-		// Get extension function pointers
-		//glewContextInit(mGLSupport);
-	}
-
-	void GLRenderSystem::initialiseFromRenderSystemCapabilities(RenderSystemCapabilities* caps)
+	void GLRenderSystem::initFromCaps(RenderSystemCapabilities* caps)
 	{
 	{
 		if(caps->getRenderSystemName() != getName())
 		if(caps->getRenderSystemName() != getName())
 		{
 		{
@@ -1826,11 +1791,7 @@ namespace BansheeEngine
 			CM_EXCEPT(InternalErrorException, "Number of combined uniform block buffers less than the number of individual per-stage buffers!?");
 			CM_EXCEPT(InternalErrorException, "Number of combined uniform block buffers less than the number of individual per-stage buffers!?");
 
 
 		TextureManager::startUp(cm_new<GLTextureManager>(std::ref(*mGLSupport))); 
 		TextureManager::startUp(cm_new<GLTextureManager>(std::ref(*mGLSupport))); 
-		checkForErrors();
-	}
 
 
-	void GLRenderSystem::oneTimeContextInitialization()
-	{
 		// Check for FSAA
 		// Check for FSAA
 		// Enable the extension if it was enabled by the GLSupport
 		// Enable the extension if it was enabled by the GLSupport
 		if (mGLSupport->checkExtension("GL_ARB_multisample"))
 		if (mGLSupport->checkExtension("GL_ARB_multisample"))
@@ -1844,12 +1805,14 @@ namespace BansheeEngine
 		}
 		}
 
 
 #if CM_DEBUG_MODE
 #if CM_DEBUG_MODE
-		if (mGLSupport->checkExtension("GL_debug_output"))
+		if (mGLSupport->checkExtension("GL_ARB_debug_output"))
 		{
 		{
 			glDebugMessageCallback(&openGlErrorCallback, 0);
 			glDebugMessageCallback(&openGlErrorCallback, 0);
 			glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
 			glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
 		}
 		}
 #endif
 #endif
+
+		checkForErrors();
 	}
 	}
 
 
 	void GLRenderSystem::switchContext(GLContext *context)
 	void GLRenderSystem::switchContext(GLContext *context)
@@ -1876,7 +1839,6 @@ namespace BansheeEngine
 		glDepthMask(mDepthWrite);
 		glDepthMask(mDepthWrite);
 		glColorMask(mColorWrite[0], mColorWrite[1], mColorWrite[2], mColorWrite[3]);
 		glColorMask(mColorWrite[0], mColorWrite[1], mColorWrite[2], mColorWrite[3]);
 		glStencilMask(mStencilWriteMask);
 		glStencilMask(mStencilWriteMask);
-
 	}
 	}
 
 
 	RenderSystemCapabilities* GLRenderSystem::createRenderSystemCapabilities() const
 	RenderSystemCapabilities* GLRenderSystem::createRenderSystemCapabilities() const
@@ -1894,23 +1856,14 @@ namespace BansheeEngine
 		if (strstr(vendorName, "NVIDIA"))
 		if (strstr(vendorName, "NVIDIA"))
 			rsc->setVendor(GPU_NVIDIA);
 			rsc->setVendor(GPU_NVIDIA);
 		else if (strstr(vendorName, "ATI"))
 		else if (strstr(vendorName, "ATI"))
-			rsc->setVendor(GPU_ATI);
+			rsc->setVendor(GPU_AMD);
+		else if (strstr(vendorName, "AMD"))
+			rsc->setVendor(GPU_AMD);
 		else if (strstr(vendorName, "Intel"))
 		else if (strstr(vendorName, "Intel"))
 			rsc->setVendor(GPU_INTEL);
 			rsc->setVendor(GPU_INTEL);
-		else if (strstr(vendorName, "S3"))
-			rsc->setVendor(GPU_S3);
-		else if (strstr(vendorName, "Matrox"))
-			rsc->setVendor(GPU_MATROX);
-		else if (strstr(vendorName, "3DLabs"))
-			rsc->setVendor(GPU_3DLABS);
-		else if (strstr(vendorName, "SiS"))
-			rsc->setVendor(GPU_SIS);
 		else
 		else
 			rsc->setVendor(GPU_UNKNOWN);
 			rsc->setVendor(GPU_UNKNOWN);
 
 
-		// Supports fixed-function
-		rsc->setCapability(RSC_FIXED_FUNCTION);
-
 		// Check for hardware mipmapping support.
 		// Check for hardware mipmapping support.
 		if(GLEW_VERSION_1_4)
 		if(GLEW_VERSION_1_4)
 		{
 		{
@@ -1918,58 +1871,43 @@ namespace BansheeEngine
 		}
 		}
 
 
 		// Check for blending support
 		// Check for blending support
-		if(GLEW_VERSION_1_3 || 
-			GLEW_ARB_texture_env_combine || 
-			GLEW_EXT_texture_env_combine)
+		if(GLEW_VERSION_1_3 || getGLSupport()->checkExtension("GL_ARB_texture_env_combine") 
+			|| getGLSupport()->checkExtension("GL_EXT_texture_env_combine"))
 		{
 		{
 			rsc->setCapability(RSC_BLENDING);
 			rsc->setCapability(RSC_BLENDING);
 		}
 		}
 
 
 		// Check for Anisotropy support
 		// Check for Anisotropy support
-		if(GLEW_EXT_texture_filter_anisotropic)
+		if (getGLSupport()->checkExtension("GL_EXT_texture_filter_anisotropic"))
 		{
 		{
 			rsc->setCapability(RSC_ANISOTROPY);
 			rsc->setCapability(RSC_ANISOTROPY);
 		}
 		}
 
 
 		// Check for DOT3 support
 		// Check for DOT3 support
 		if(GLEW_VERSION_1_3 ||
 		if(GLEW_VERSION_1_3 ||
-			GLEW_ARB_texture_env_dot3 ||
-			GLEW_EXT_texture_env_dot3)
+			getGLSupport()->checkExtension("GL_ARB_texture_env_dot3") ||
+			getGLSupport()->checkExtension("GL_EXT_texture_env_dot3"))
 		{
 		{
 			rsc->setCapability(RSC_DOT3);
 			rsc->setCapability(RSC_DOT3);
 		}
 		}
 
 
 		// Check for cube mapping
 		// Check for cube mapping
 		if(GLEW_VERSION_1_3 || 
 		if(GLEW_VERSION_1_3 || 
-			GLEW_ARB_texture_cube_map ||
-			GLEW_EXT_texture_cube_map)
+			getGLSupport()->checkExtension("GL_ARB_texture_cube_map") ||
+			getGLSupport()->checkExtension("GL_EXT_texture_cube_map"))
 		{
 		{
 			rsc->setCapability(RSC_CUBEMAPPING);
 			rsc->setCapability(RSC_CUBEMAPPING);
 		}
 		}
 
 
-
 		// Point sprites
 		// Point sprites
-		if (GLEW_VERSION_2_0 ||	GLEW_ARB_point_sprite)
+		if (GLEW_VERSION_2_0 || getGLSupport()->checkExtension("GL_ARB_point_sprite"))
 		{
 		{
 			rsc->setCapability(RSC_POINT_SPRITES);
 			rsc->setCapability(RSC_POINT_SPRITES);
 		}
 		}
-		// Check for point parameters
-		if (GLEW_VERSION_1_4)
-		{
-			rsc->setCapability(RSC_POINT_EXTENDED_PARAMETERS);
-		}
-		if (GLEW_ARB_point_parameters)
-		{
-			rsc->setCapability(RSC_POINT_EXTENDED_PARAMETERS_ARB);
-		}
-		if (GLEW_EXT_point_parameters)
-		{
-			rsc->setCapability(RSC_POINT_EXTENDED_PARAMETERS_EXT);
-		}
 
 
 		// Check for hardware stencil support and set bit depth
 		// Check for hardware stencil support and set bit depth
 		GLint stencil;
 		GLint stencil;
-		glGetIntegerv(GL_STENCIL_BITS,&stencil);
+		glGetIntegerv(GL_STENCIL_BITS, &stencil);
 
 
 		if(stencil)
 		if(stencil)
 		{
 		{
@@ -1977,33 +1915,26 @@ namespace BansheeEngine
 			rsc->setStencilBufferBitDepth(stencil);
 			rsc->setStencilBufferBitDepth(stencil);
 		}
 		}
 
 
-		if(GLEW_VERSION_1_5 || GLEW_ARB_vertex_buffer_object)
+		if (GLEW_VERSION_1_5 || getGLSupport()->checkExtension("GL_ARB_vertex_buffer_object"))
 		{
 		{
-			if (!GLEW_ARB_vertex_buffer_object)
-			{
-				rsc->setCapability(RSC_GL1_5_NOVBO);
-			}
 			rsc->setCapability(RSC_VBO);
 			rsc->setCapability(RSC_VBO);
 		}
 		}
 
 
 		rsc->setCapability(RSC_VERTEX_PROGRAM);
 		rsc->setCapability(RSC_VERTEX_PROGRAM);
 		rsc->setCapability(RSC_FRAGMENT_PROGRAM);
 		rsc->setCapability(RSC_FRAGMENT_PROGRAM);
 
 
-		rsc->addShaderProfile("cg");
-
-		// NFZ - Check if GLSL is supported
-		if ( GLEW_VERSION_2_0 || 
-			(GLEW_ARB_shading_language_100 &&
-			GLEW_ARB_shader_objects &&
-			GLEW_ARB_fragment_shader &&
-			GLEW_ARB_vertex_shader) )
+		if (GLEW_VERSION_2_0 || 
+			(getGLSupport()->checkExtension("GL_ARB_shading_language_100") &&
+			getGLSupport()->checkExtension("GL_ARB_shader_objects") &&
+			getGLSupport()->checkExtension("GL_ARB_fragment_shader") &&
+			getGLSupport()->checkExtension("GL_ARB_vertex_shader")))
 		{
 		{
 			rsc->addShaderProfile("glsl");
 			rsc->addShaderProfile("glsl");
 		}
 		}
 
 
 		// Check if geometry shaders are supported
 		// Check if geometry shaders are supported
 		if (GLEW_VERSION_2_0 &&
 		if (GLEW_VERSION_2_0 &&
-			GLEW_EXT_geometry_shader4)
+			getGLSupport()->checkExtension("GL_EXT_geometry_shader4"))
 		{
 		{
 			rsc->setCapability(RSC_GEOMETRY_PROGRAM);
 			rsc->setCapability(RSC_GEOMETRY_PROGRAM);
 
 
@@ -2020,24 +1951,24 @@ namespace BansheeEngine
 		}
 		}
 
 
 		//Check if render to vertex buffer (transform feedback in OpenGL)
 		//Check if render to vertex buffer (transform feedback in OpenGL)
-		if (GLEW_VERSION_2_0 && 
-			GLEW_NV_transform_feedback)
+		if (GLEW_VERSION_2_0 && getGLSupport()->checkExtension("GL_EXT_transform_feedback"))
 		{
 		{
 			rsc->setCapability(RSC_HWRENDER_TO_VERTEX_BUFFER);
 			rsc->setCapability(RSC_HWRENDER_TO_VERTEX_BUFFER);
 		}
 		}
 
 
 		// Check for texture compression
 		// Check for texture compression
-		if(GLEW_VERSION_1_3 || GLEW_ARB_texture_compression)
+		if (GLEW_VERSION_1_3 || getGLSupport()->checkExtension("GL_ARB_texture_compression"))
 		{   
 		{   
 			rsc->setCapability(RSC_TEXTURE_COMPRESSION);
 			rsc->setCapability(RSC_TEXTURE_COMPRESSION);
 
 
 			// Check for dxt compression
 			// Check for dxt compression
-			if(GLEW_EXT_texture_compression_s3tc)
+			if (getGLSupport()->checkExtension("GL_EXT_texture_compression_s3tc"))
 			{
 			{
 				rsc->setCapability(RSC_TEXTURE_COMPRESSION_DXT);
 				rsc->setCapability(RSC_TEXTURE_COMPRESSION_DXT);
 			}
 			}
+
 			// Check for vtc compression
 			// Check for vtc compression
-			if(GLEW_NV_texture_compression_vtc)
+			if (getGLSupport()->checkExtension("GL_NV_texture_compression_vtc"))
 			{
 			{
 				rsc->setCapability(RSC_TEXTURE_COMPRESSION_VTC);
 				rsc->setCapability(RSC_TEXTURE_COMPRESSION_VTC);
 			}
 			}
@@ -2049,31 +1980,20 @@ namespace BansheeEngine
 		rsc->setCapability(RSC_USER_CLIP_PLANES);
 		rsc->setCapability(RSC_USER_CLIP_PLANES);
 
 
 		// 2-sided stencil?
 		// 2-sided stencil?
-		if (GLEW_VERSION_2_0 || GLEW_EXT_stencil_two_side)
+		if (GLEW_VERSION_2_0 || getGLSupport()->checkExtension("GL_EXT_stencil_two_side"))
 		{
 		{
 			rsc->setCapability(RSC_TWO_SIDED_STENCIL);
 			rsc->setCapability(RSC_TWO_SIDED_STENCIL);
 		}
 		}
+
 		// stencil wrapping?
 		// stencil wrapping?
-		if (GLEW_VERSION_1_4 || GLEW_EXT_stencil_wrap)
+		if (GLEW_VERSION_1_4 || getGLSupport()->checkExtension("GL_EXT_stencil_wrap"))
 		{
 		{
 			rsc->setCapability(RSC_STENCIL_WRAP);
 			rsc->setCapability(RSC_STENCIL_WRAP);
 		}
 		}
 
 
 		// Check for hardware occlusion support
 		// Check for hardware occlusion support
-		if(GLEW_VERSION_1_5 || GLEW_ARB_occlusion_query)
+		if (GLEW_VERSION_1_5 || getGLSupport()->checkExtension("GL_ARB_occlusion_query"))
 		{
 		{
-			// Some buggy driver claim that it is GL 1.5 compliant and
-			// not support ARB_occlusion_query
-			if (!GLEW_ARB_occlusion_query)
-			{
-				rsc->setCapability(RSC_GL1_5_NOHWOCCLUSION);
-			}
-
-			rsc->setCapability(RSC_HWOCCLUSION);
-		}
-		else if (GLEW_NV_occlusion_query)
-		{
-			// Support NV extension too for old hardware
 			rsc->setCapability(RSC_HWOCCLUSION);
 			rsc->setCapability(RSC_HWOCCLUSION);
 		}
 		}
 
 
@@ -2084,13 +2004,13 @@ namespace BansheeEngine
 		rsc->setCapability(RSC_INFINITE_FAR_PLANE);
 		rsc->setCapability(RSC_INFINITE_FAR_PLANE);
 
 
 		// Check for non-power-of-2 texture support
 		// Check for non-power-of-2 texture support
-		if(GLEW_ARB_texture_non_power_of_two)
+		if (getGLSupport()->checkExtension("GL_ARB_texture_non_power_of_two"))
 		{
 		{
 			rsc->setCapability(RSC_NON_POWER_OF_2_TEXTURES);
 			rsc->setCapability(RSC_NON_POWER_OF_2_TEXTURES);
 		}
 		}
 
 
 		// Check for Float textures
 		// Check for Float textures
-		if(GLEW_ATI_texture_float || GLEW_ARB_texture_float)
+		if (getGLSupport()->checkExtension("GL_ATI_texture_float") || getGLSupport()->checkExtension("GL_ARB_texture_float"))
 		{
 		{
 			rsc->setCapability(RSC_TEXTURE_FLOAT);
 			rsc->setCapability(RSC_TEXTURE_FLOAT);
 		}
 		}
@@ -2099,13 +2019,11 @@ namespace BansheeEngine
 		rsc->setCapability(RSC_TEXTURE_3D);
 		rsc->setCapability(RSC_TEXTURE_3D);
 
 
 		// Check for framebuffer object extension
 		// Check for framebuffer object extension
-		if(GLEW_EXT_framebuffer_object)
+		if (getGLSupport()->checkExtension("GL_ARB_framebuffer_object"))
 		{
 		{
 			// Probe number of draw buffers
 			// Probe number of draw buffers
 			// Only makes sense with FBO support, so probe here
 			// Only makes sense with FBO support, so probe here
-			if(GLEW_VERSION_2_0 || 
-				GLEW_ARB_draw_buffers ||
-				GLEW_ATI_draw_buffers)
+			if (GLEW_VERSION_2_0 || getGLSupport()->checkExtension("GL_ARB_draw_buffers") || getGLSupport()->checkExtension("GL_ATI_draw_buffers"))
 			{
 			{
 				GLint buffers;
 				GLint buffers;
 				glGetIntegerv(GL_MAX_DRAW_BUFFERS_ARB, &buffers);
 				glGetIntegerv(GL_MAX_DRAW_BUFFERS_ARB, &buffers);
@@ -2114,9 +2032,9 @@ namespace BansheeEngine
 				if(!GLEW_VERSION_2_0)
 				if(!GLEW_VERSION_2_0)
 				{
 				{
 					// Before GL version 2.0, we need to get one of the extensions
 					// Before GL version 2.0, we need to get one of the extensions
-					if(GLEW_ARB_draw_buffers)
+					if (getGLSupport()->checkExtension("GL_ARB_draw_buffers"))
 						rsc->setCapability(RSC_FBO_ARB);
 						rsc->setCapability(RSC_FBO_ARB);
-					if(GLEW_ATI_draw_buffers)
+					if (getGLSupport()->checkExtension("GL_ATI_draw_buffers"))
 						rsc->setCapability(RSC_FBO_ATI);
 						rsc->setCapability(RSC_FBO_ATI);
 				}
 				}
 				// Set FBO flag for all 3 'subtypes'
 				// Set FBO flag for all 3 'subtypes'
@@ -2197,7 +2115,9 @@ namespace BansheeEngine
 		rsc->setNumCombinedUniformBlockBuffers(static_cast<UINT16>(combinedUniformBlockUnits));
 		rsc->setNumCombinedUniformBlockBuffers(static_cast<UINT16>(combinedUniformBlockUnits));
 
 
 		// Mipmap LOD biasing
 		// Mipmap LOD biasing
-		rsc->setCapability(RSC_MIPMAP_LOD_BIAS);
+
+		if (mGLSupport->checkExtension("GL_EXT_texture_lod_bias"))
+			rsc->setCapability(RSC_MIPMAP_LOD_BIAS);
 
 
 		// Alpha to coverage?
 		// Alpha to coverage?
 		if (mGLSupport->checkExtension("GL_ARB_multisample"))
 		if (mGLSupport->checkExtension("GL_ARB_multisample"))
@@ -2286,6 +2206,6 @@ namespace BansheeEngine
 
 
 	void openGlErrorCallback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *message, GLvoid *userParam)
 	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
+		CM_EXCEPT(RenderingAPIException, "OpenGL error: " + String(message));
 	}
 	}
 }
 }

+ 7 - 12
CamelotGLRenderer/Source/CmGLSupport.cpp

@@ -6,7 +6,7 @@ GLenum GLEWAPIENTRY glewContextInit(BansheeEngine::GLSupport *glSupport);
 
 
 namespace BansheeEngine
 namespace BansheeEngine
 {
 {
-    void GLSupport::initialiseExtensions()
+    void GLSupport::initializeExtensions()
     {
     {
 		glewContextInit(this);
 		glewContextInit(this);
 
 
@@ -24,18 +24,13 @@ namespace BansheeEngine
         mVendor = tmpStr.substr(0, tmpStr.find(" "));
         mVendor = tmpStr.substr(0, tmpStr.find(" "));
 
 
         // Set extension list
         // Set extension list
-		StringStream ext;
-        String str;
+		int numExtensions = 0;
+		glGetIntegerv(GL_NUM_EXTENSIONS, &numExtensions);
 
 
-        const GLubyte* pcExt = glGetString(GL_EXTENSIONS);
-		assert(pcExt && "Problems getting GL extension string using glGetString");
-
-        ext << pcExt;
-
-        while(ext >> str)
-        {
-            extensionList.insert(str);
-        }
+		for (int i = 0; i < numExtensions; i++)
+		{
+			extensionList.insert(String((char*)glGetStringi(GL_EXTENSIONS, i)));
+		}
     }
     }
 
 
     bool GLSupport::checkMinGLVersion(const String& v) const
     bool GLSupport::checkMinGLVersion(const String& v) const

+ 4 - 4
CamelotGLRenderer/Source/CmWin32GLSupport.cpp

@@ -51,11 +51,11 @@ namespace BansheeEngine
 		mInitialWindow = nullptr;
 		mInitialWindow = nullptr;
 	}
 	}
 
 
-	void Win32GLSupport::initialiseExtensions()
+	void Win32GLSupport::initializeExtensions()
 	{
 	{
 		assert(mInitialWindow != nullptr);
 		assert(mInitialWindow != nullptr);
 		
 		
-		GLSupport::initialiseExtensions();
+		GLSupport::initializeExtensions();
 
 
 		wglewContextInit(this);
 		wglewContextInit(this);
 
 
@@ -83,7 +83,7 @@ namespace BansheeEngine
 		// If RenderSystem has initialized a context use that, otherwise we create our own
 		// If RenderSystem has initialized a context use that, otherwise we create our own
 		HGLRC glrc = externalGlrc;
 		HGLRC glrc = externalGlrc;
 		bool createdNew = false;
 		bool createdNew = false;
-		if (!rs->isContextInitialized())
+		if (!rs->_isContextInitialized())
 		{
 		{
 			if (externalGlrc == 0)
 			if (externalGlrc == 0)
 			{
 			{
@@ -188,7 +188,7 @@ namespace BansheeEngine
 
 
 			if (_wglCreateContextAttribsARB != nullptr)
 			if (_wglCreateContextAttribsARB != nullptr)
 			{
 			{
-				WGLEW_GET_FUN(__wglewCreateContextAttribsARB) = (PFNWGLCREATECONTEXTATTRIBSARBPROC)wglGetProcAddress("wglChoosePixelFormatARB");
+				WGLEW_GET_FUN(__wglewCreateContextAttribsARB) = _wglCreateContextAttribsARB;
 				mHasAdvancedContext = true;
 				mHasAdvancedContext = true;
 			}
 			}
 
 

+ 1 - 1
CamelotGLRenderer/Source/glew.cpp

@@ -13474,7 +13474,7 @@ const GLubyte * GLEWAPIENTRY glewGetString (GLenum name)
 
 
 /* ------------------------------------------------------------------------ */
 /* ------------------------------------------------------------------------ */
 
 
-GLboolean glewExperimental = GL_FALSE;
+GLboolean glewExperimental = GL_TRUE;
 
 
 #if !defined(GLEW_MX)
 #if !defined(GLEW_MX)