Browse Source

Nothing important

Panagiotis Christopoulos Charitos 13 years ago
parent
commit
ae825dcec6

+ 8 - 21
include/anki/gl/ShaderProgram.h

@@ -3,7 +3,6 @@
 
 
 #include "anki/util/ConstCharPtrHashMap.h"
 #include "anki/util/ConstCharPtrHashMap.h"
 #include "anki/util/Assert.h"
 #include "anki/util/Assert.h"
-#include "anki/util/Flags.h"
 #include "anki/math/Forward.h"
 #include "anki/math/Forward.h"
 #include "anki/gl/Ogl.h"
 #include "anki/gl/Ogl.h"
 #include "anki/util/Vector.h"
 #include "anki/util/Vector.h"
@@ -40,6 +39,8 @@ public:
 	virtual ~ShaderProgramVariable()
 	virtual ~ShaderProgramVariable()
 	{}
 	{}
 
 
+	ShaderProgramVariable& operator=(const ShaderProgramVariable& b);
+
 	/// @name Accessors
 	/// @name Accessors
 	/// @{
 	/// @{
 	const ShaderProgram& getFatherShaderProgram() const
 	const ShaderProgram& getFatherShaderProgram() const
@@ -73,17 +74,6 @@ public:
 	}
 	}
 	/// @}
 	/// @}
 
 
-	ShaderProgramVariable& operator=(const ShaderProgramVariable& b)
-	{
-		ANKI_ASSERT(type == b.type);
-		loc = b.loc;
-		name = b.name;
-		glDataType = b.glDataType;
-		size = b.size;
-		fatherSProg = b.fatherSProg;
-		return *this;
-	}
-
 private:
 private:
 	GLint loc; ///< GL location
 	GLint loc; ///< GL location
 	std::string name; ///< The name inside the shader program
 	std::string name; ///< The name inside the shader program
@@ -108,14 +98,7 @@ public:
 	{}
 	{}
 
 
 	ShaderProgramUniformVariable& operator=(
 	ShaderProgramUniformVariable& operator=(
-		const ShaderProgramUniformVariable& b)
-	{
-		ShaderProgramVariable::operator=(b);
-		index = b.index;
-		offset = b.offset;
-		arrayStride = b.arrayStride;
-		return *this;
-	}
+		const ShaderProgramUniformVariable& b);
 
 
 	const ShaderProgramUniformBlock* getUniformBlock() const
 	const ShaderProgramUniformBlock* getUniformBlock() const
 	{
 	{
@@ -162,6 +145,9 @@ public:
 	}
 	}
 	/// @}
 	/// @}
 
 
+	/// @name Uniform block setters
+	/// Write a client memory that represents the uniform block
+	/// @{
 	void setClientMemory(void* buff, U32 buffSize,
 	void setClientMemory(void* buff, U32 buffSize,
 		const F32 arr[], U32 size) const;
 		const F32 arr[], U32 size) const;
 
 
@@ -179,6 +165,7 @@ public:
 
 
 	void setClientMemory(void* buff, U32 buffSize,
 	void setClientMemory(void* buff, U32 buffSize,
 		const Mat4 arr[], U32 size) const;
 		const Mat4 arr[], U32 size) const;
+	/// @}
 
 
 private:
 private:
 	GLuint index;
 	GLuint index;
@@ -402,7 +389,7 @@ public:
 
 
 	static GLuint getCurrentProgramGlId()
 	static GLuint getCurrentProgramGlId()
 	{
 	{
-		int i;
+		GLint i;
 		glGetIntegerv(GL_CURRENT_PROGRAM, &i);
 		glGetIntegerv(GL_CURRENT_PROGRAM, &i);
 		return i;
 		return i;
 	}
 	}

+ 1 - 1
include/anki/resource/MeshLoader.h

@@ -123,7 +123,7 @@ private:
 	Vector<VertexWeight> vertWeights; ///< Optional
 	Vector<VertexWeight> vertWeights; ///< Optional
 	Vector<Triangle> tris; ///< Required
 	Vector<Triangle> tris; ///< Required
 	/// Generated. Used for vertex arrays & VBOs
 	/// Generated. Used for vertex arrays & VBOs
-	Vector<ushort> vertIndeces;
+	Vector<U16> vertIndeces;
 	/// @}
 	/// @}
 
 
 	/// Load the mesh data from a binary file
 	/// Load the mesh data from a binary file

+ 45 - 8
src/gl/ShaderProgram.cpp

@@ -17,10 +17,40 @@ namespace anki {
 static const char* padding = "======================================="
 static const char* padding = "======================================="
                              "=======================================";
                              "=======================================";
 
 
+//==============================================================================
+// ShaderProgramVariable                                                       =
+//==============================================================================
+
+//==============================================================================
+ShaderProgramVariable& ShaderProgramVariable::operator=(
+	const ShaderProgramVariable& b)
+{
+	ANKI_ASSERT(type == b.type);
+	loc = b.loc;
+	name = b.name;
+	glDataType = b.glDataType;
+	size = b.size;
+	fatherSProg = b.fatherSProg;
+	return *this;
+}
+
 //==============================================================================
 //==============================================================================
 // ShaderProgramUniformVariable                                                =
 // ShaderProgramUniformVariable                                                =
 //==============================================================================
 //==============================================================================
 
 
+//==============================================================================
+ShaderProgramUniformVariable& ShaderProgramUniformVariable::operator=(
+	const ShaderProgramUniformVariable& b)
+{
+	ShaderProgramVariable::operator=(b);
+	index = b.index;
+	block = b.block;
+	offset = b.offset;
+	arrayStride = b.arrayStride;
+	matrixStride = b.matrixStride;
+	return *this;
+}
+
 //==============================================================================
 //==============================================================================
 void ShaderProgramUniformVariable::doCommonSetCode() const
 void ShaderProgramUniformVariable::doCommonSetCode() const
 {
 {
@@ -28,8 +58,6 @@ void ShaderProgramUniformVariable::doCommonSetCode() const
 		&& "You cannot set variable in uniform block");
 		&& "You cannot set variable in uniform block");
 	ANKI_ASSERT(ShaderProgram::getCurrentProgramGlId() == 
 	ANKI_ASSERT(ShaderProgram::getCurrentProgramGlId() == 
 		getFatherShaderProgram().getGlId());
 		getFatherShaderProgram().getGlId());
-
-	/*enableFlag(SPUVF_DIRTY);*/
 }
 }
 
 
 //==============================================================================
 //==============================================================================
@@ -143,7 +171,7 @@ void ShaderProgramUniformVariable::set(const Texture* const texes[],
 }
 }
 
 
 //==============================================================================
 //==============================================================================
-/// XXX
+// Template functions that return the GL type using an AnKi type
 template<typename T>
 template<typename T>
 static Bool checkType(GLenum glDataType);
 static Bool checkType(GLenum glDataType);
 
 
@@ -582,7 +610,7 @@ void ShaderProgram::initUniAndAttribVars()
 	attribs.resize(attribsCount);
 	attribs.resize(attribsCount);
 	attribs.shrink_to_fit();
 	attribs.shrink_to_fit();
 	attribsCount = 0;
 	attribsCount = 0;
-	for(int i = 0; i < num; i++) // loop all attributes
+	for(GLint i = 0; i < num; i++) // loop all attributes
 	{
 	{
 		// Name
 		// Name
 		glGetActiveAttrib(glId, i, sizeof(name_), &length,
 		glGetActiveAttrib(glId, i, sizeof(name_), &length,
@@ -602,6 +630,7 @@ void ShaderProgram::initUniAndAttribVars()
 
 
 		var.loc = loc;
 		var.loc = loc;
 		var.name = &name_[0];
 		var.name = &name_[0];
+		var.name.shrink_to_fit();
 		var.glDataType = type;
 		var.glDataType = type;
 		var.size = size;
 		var.size = size;
 		var.fatherSProg = this;
 		var.fatherSProg = this;
@@ -670,6 +699,7 @@ void ShaderProgram::initUniAndAttribVars()
 
 
 		var.loc = loc;
 		var.loc = loc;
 		var.name = &name_[0];
 		var.name = &name_[0];
+		var.name.shrink_to_fit();
 		var.glDataType = type;
 		var.glDataType = type;
 		var.size = size;
 		var.size = size;
 		var.fatherSProg = this;
 		var.fatherSProg = this;
@@ -683,23 +713,30 @@ void ShaderProgram::initUniAndAttribVars()
 //==============================================================================
 //==============================================================================
 void ShaderProgram::initUniformBlocks()
 void ShaderProgram::initUniformBlocks()
 {
 {
+	// Get blocks count and create the vector
 	GLint blocksCount;
 	GLint blocksCount;
 	glGetProgramiv(glId, GL_ACTIVE_UNIFORM_BLOCKS, &blocksCount);
 	glGetProgramiv(glId, GL_ACTIVE_UNIFORM_BLOCKS, &blocksCount);
-
+	if(blocksCount < 1)
+	{
+		// Early exit
+		return;
+	}
 	blocks.resize(blocksCount);
 	blocks.resize(blocksCount);
 	blocks.shrink_to_fit();
 	blocks.shrink_to_fit();
 
 
+	// Init all blocks
 	GLuint i = 0;
 	GLuint i = 0;
 	for(ShaderProgramUniformBlock& block : blocks)
 	for(ShaderProgramUniformBlock& block : blocks)
 	{
 	{
 		GLint gli; // General purpose int
 		GLint gli; // General purpose int
 
 
 		// Name
 		// Name
-		char name[256];
+		Array<char, 256> name;
 		GLsizei len;
 		GLsizei len;
-		glGetActiveUniformBlockName(glId, i, sizeof(name), &len, name);
+		glGetActiveUniformBlockName(glId, i, sizeof(name), &len, &name[0]);
+		// The name is null terminated
 
 
-		block.name = name;
+		block.name = &name[0];
 		block.name.shrink_to_fit();
 		block.name.shrink_to_fit();
 
 
 		// Index
 		// Index

+ 0 - 1
src/resource/Mesh.cpp

@@ -3,7 +3,6 @@
 #include "anki/resource/MeshLoader.h"
 #include "anki/resource/MeshLoader.h"
 #include "anki/gl/Vbo.h"
 #include "anki/gl/Vbo.h"
 #include "anki/util/Functions.h"
 #include "anki/util/Functions.h"
-#include <fstream>
 
 
 namespace anki {
 namespace anki {