Panagiotis Christopoulos Charitos vor 15 Jahren
Ursprung
Commit
f5e085e8cf

+ 34 - 16
.cproject

@@ -3,8 +3,8 @@
 
 <cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
 <storageModule moduleId="org.eclipse.cdt.core.settings">
-<cconfiguration id="cdt.managedbuild.toolchain.gnu.cross.base.278686394">
-<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.toolchain.gnu.cross.base.278686394" moduleId="org.eclipse.cdt.core.settings" name="Default">
+<cconfiguration id="cdt.managedbuild.toolchain.gnu.cross.base.1593777304">
+<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.toolchain.gnu.cross.base.1593777304" moduleId="org.eclipse.cdt.core.settings" name="Default">
 <externalSettings/>
 <extensions>
 <extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
@@ -14,18 +14,18 @@
 </extensions>
 </storageModule>
 <storageModule moduleId="cdtBuildSystem" version="4.0.0">
-<configuration artifactName="anki" buildProperties="" description="" id="cdt.managedbuild.toolchain.gnu.cross.base.278686394" name="Default" parent="org.eclipse.cdt.build.core.emptycfg">
-<folderInfo id="cdt.managedbuild.toolchain.gnu.cross.base.278686394.1132339411" name="/" resourcePath="">
-<toolChain id="cdt.managedbuild.toolchain.gnu.cross.base.960312399" name="cdt.managedbuild.toolchain.gnu.cross.base" superClass="cdt.managedbuild.toolchain.gnu.cross.base">
-<option id="cdt.managedbuild.option.gnu.cross.prefix.880759701" name="Prefix" superClass="cdt.managedbuild.option.gnu.cross.prefix"/>
-<option id="cdt.managedbuild.option.gnu.cross.path.51123088" name="Path" superClass="cdt.managedbuild.option.gnu.cross.path"/>
-<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="cdt.managedbuild.targetPlatform.gnu.cross.671560961" isAbstract="false" osList="all" superClass="cdt.managedbuild.targetPlatform.gnu.cross"/>
-<builder arguments="make -j3" buildPath="${workspace_loc:/anki/build/debug}" command="nice" id="cdt.managedbuild.toolchain.gnu.cross.base.278686394.1477991022" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Gnu Make Builder" superClass="org.eclipse.cdt.build.core.settings.default.builder"/>
-<tool id="cdt.managedbuild.tool.gnu.cross.cpp.compiler.65387374" name="Cross G++ Compiler" superClass="cdt.managedbuild.tool.gnu.cross.cpp.compiler">
-<inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.2094020625" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
+<configuration artifactName="anki" buildProperties="" description="" id="cdt.managedbuild.toolchain.gnu.cross.base.1593777304" name="Default" parent="org.eclipse.cdt.build.core.emptycfg">
+<folderInfo id="cdt.managedbuild.toolchain.gnu.cross.base.1593777304.1771284297" name="/" resourcePath="">
+<toolChain id="cdt.managedbuild.toolchain.gnu.cross.base.652528495" name="cdt.managedbuild.toolchain.gnu.cross.base" superClass="cdt.managedbuild.toolchain.gnu.cross.base">
+<option id="cdt.managedbuild.option.gnu.cross.prefix.124248385" name="Prefix" superClass="cdt.managedbuild.option.gnu.cross.prefix"/>
+<option id="cdt.managedbuild.option.gnu.cross.path.568633506" name="Path" superClass="cdt.managedbuild.option.gnu.cross.path"/>
+<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="cdt.managedbuild.targetPlatform.gnu.cross.2099631" isAbstract="false" osList="all" superClass="cdt.managedbuild.targetPlatform.gnu.cross"/>
+<builder arguments="make -j3" buildPath="${workspace_loc:/anki/build/debug}" command="nice" id="cdt.managedbuild.toolchain.gnu.cross.base.1593777304.618553305" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Gnu Make Builder" superClass="org.eclipse.cdt.build.core.settings.default.builder"/>
+<tool id="cdt.managedbuild.tool.gnu.cross.cpp.compiler.454660912" name="Cross G++ Compiler" superClass="cdt.managedbuild.tool.gnu.cross.cpp.compiler">
+<inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.264866474" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
 </tool>
-<tool id="cdt.managedbuild.tool.gnu.cross.cpp.linker.1101033180" name="Cross G++ Linker" superClass="cdt.managedbuild.tool.gnu.cross.cpp.linker">
-<inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.2069070912" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input">
+<tool id="cdt.managedbuild.tool.gnu.cross.cpp.linker.628710088" name="Cross G++ Linker" superClass="cdt.managedbuild.tool.gnu.cross.cpp.linker">
+<inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.444788722" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input">
 <additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
 <additionalInput kind="additionalinput" paths="$(LIBS)"/>
 </inputType>
@@ -116,13 +116,31 @@
 <parser enabled="true"/>
 </scannerInfoProvider>
 </profile>
+<profile id="org.eclipse.cdt.managedbuilder.xlc.core.XLCManagedMakePerProjectProfile">
+<buildOutputProvider>
+<openAction enabled="false" filePath=""/>
+<parser enabled="false"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -v ${plugin_state_location}/${specs_file}" command="${XL_compilerRoot}/xlc" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile id="org.eclipse.cdt.managedbuilder.xlc.core.XLCManagedMakePerProjectProfileCPP">
+<buildOutputProvider>
+<openAction enabled="false" filePath=""/>
+<parser enabled="false"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -v ${plugin_state_location}/${specs_file}" command="${XL_compilerRoot}/xlC" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
 </storageModule>
 <storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
-<storageModule moduleId="org.eclipse.cdt.core.language.mapping"/>
-<storageModule moduleId="org.eclipse.cdt.internal.ui.text.commentOwnerProjectMappings"/>
 </cconfiguration>
 </storageModule>
 <storageModule moduleId="cdtBuildSystem" version="4.0.0">
-<project id="anki.null.1990650523" name="anki"/>
+<project id="anki.null.323176720" name="anki"/>
 </storageModule>
 </cproject>

+ 0 - 1
.project

@@ -3,7 +3,6 @@
 	<name>anki</name>
 	<comment></comment>
 	<projects>
-		<project>bullet</project>
 	</projects>
 	<buildSpec>
 		<buildCommand>

Datei-Diff unterdrückt, da er zu groß ist
+ 397 - 386
build/debug/Makefile


+ 14 - 3
src/Renderer/Renderer.h

@@ -105,7 +105,7 @@ class Renderer
 					PROPERTY_R(bool, enabled, isEnabled) ///< If false then disable
 					PROPERTY_R(bool, pcfEnabled, isPcfEnabled) ///< Enable Percentage Closer Filtering
 					PROPERTY_R(bool, bilinearEnabled, isBilinearEnabled) ///< Shadowmap bilinear filtering. Better quality
-					PROPERTY_R(int, resolution, getResolution) ///< Shadowmap resolution. The higher the better
+					PROPERTY_R(int, resolution, getResolution) ///< Shadowmap resolution. The higher the better but slower
 
 					public:
 						Sm(Renderer& r_): RenderingStage(r_) {}
@@ -138,7 +138,7 @@ class Renderer
 						static float sMOUvSCoords[]; ///< Illumination stage stencil masking optimizations UV sphere vertex positions
 						static Vbo sMOUvSVbo; ///< Illumination stage stencil masking optimizations UV sphere VBO
 						RsrcPtr<ShaderProg> sProg;
-						const ShaderProg::UniVar* modelViewProjectionMatUniVar;
+						const ShaderProg::UniVar* modelViewProjectionMatUniVar; ///< Opt
 
 						void init();
 						void run(const PointLight& light);
@@ -177,11 +177,18 @@ class Renderer
 				RsrcPtr<ShaderProg> pointLightSProg; ///< Illumination stage point light shader program
 				RsrcPtr<ShaderProg> spotLightNoShadowSProg; ///< Illumination stage spot light w/o shadow shader program
 				RsrcPtr<ShaderProg> spotLightShadowSProg; ///< Illumination stage spot light w/ shadow shader program
+
+				/**
+				 * @name Ptrs to uniform variables
+				 */
+				//*@{*/
 				const ShaderProg::UniVar* ambientColUniVar;
 				const ShaderProg::UniVar* sceneColMapUniVar;
 				UniVars pointLightSProgUniVars;
 				UniVars spotLightNoShadowSProgUniVars;
 				UniVars spotLightShadowSProgUniVars;
+				//*@}*/
+
 				Vec3 viewVectors[4];
 				Vec2 planes;
 
@@ -393,12 +400,16 @@ class Renderer
 	// Public                                                                                                            =
 	//====================================================================================================================
 	public:
-		// the stages as data members
+		/**
+		 * @name Rendering stages
+		 */
+		/**@{*/
 		Ms ms; ///< Material rendering stage
 		Is is; ///< Illumination rendering stage
 		Pps pps; ///< Postprocessing rendering stage
 		Bs bs; ///< Blending stage
 		Dbg dbg; ///< Debugging rendering stage
+		/**@}*/
 
 		Renderer();
 

+ 50 - 49
src/Resources/Helpers/Image.cpp

@@ -1,17 +1,19 @@
 #include <SDL_image.h>
+#include <boost/filesystem.hpp>
+#include <boost/algorithm/string.hpp>
 #include <fstream>
 #include "Image.h"
 #include "Util.h"
 
 
-unsigned char Image::tgaHeaderUncompressed[12] = {0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0};
-unsigned char Image::tgaHeaderCompressed[12]   = {0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+uchar Image::tgaHeaderUncompressed[12] = {0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+uchar Image::tgaHeaderCompressed[12]   = {0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0};
 
 
 //======================================================================================================================
-// loadUncompressedTGA                                                                                                 =
+// loadUncompressedTga                                                                                                 =
 //======================================================================================================================
-bool Image::loadUncompressedTGA(const char* filename, fstream& fs)
+bool Image::loadUncompressedTga(const char* filename, fstream& fs)
 {
 	// read the info from header
 	unsigned char header6[6];
@@ -33,19 +35,19 @@ bool Image::loadUncompressedTGA(const char* filename, fstream& fs)
 	}
 
 	// read the data
-	int bytes_per_pxl	= (bpp / 8);
-	int image_size = bytes_per_pxl * width * height;
-	data = new char [image_size];
+	int bytesPerPxl	= (bpp / 8);
+	int imageSize = bytesPerPxl * width * height;
+	data.reserve(imageSize);
 
-	fs.read(data, image_size);
-	if(fs.gcount() != image_size)
+	fs.read(&data[0], imageSize);
+	if(fs.gcount() != imageSize)
 	{
 		ERROR("File \"" << filename << "\": Cannot read image data");
 		return false;
 	}
 
 	// swap red with blue
-	for(int i=0; i<int(image_size); i+=bytes_per_pxl)
+	for(int i=0; i<int(imageSize); i+=bytesPerPxl)
 	{
 		uint temp = data[i];
 		data[i] = data[i + 2];
@@ -57,9 +59,9 @@ bool Image::loadUncompressedTGA(const char* filename, fstream& fs)
 
 
 //======================================================================================================================
-// loadCompressedTGA                                                                                                   =
+// loadCompressedTga                                                                                                   =
 //======================================================================================================================
-bool Image::loadCompressedTGA(const char* filename, fstream& fs)
+bool Image::loadCompressedTga(const char* filename, fstream& fs)
 {
 	unsigned char header6[6];
 	fs.read((char*)&header6[0], sizeof(header6));
@@ -80,9 +82,9 @@ bool Image::loadCompressedTGA(const char* filename, fstream& fs)
 	}
 
 
-	int bytes_per_pxl = (bpp / 8);
-	int image_size = bytes_per_pxl * width * height;
-	data = new char [image_size];
+	int bytesPerPxl = (bpp / 8);
+	int image_size = bytesPerPxl * width * height;
+	data.reserve(image_size);
 
 	uint pixelcount = height * width;
 	uint currentpixel = 0;
@@ -105,8 +107,8 @@ bool Image::loadCompressedTGA(const char* filename, fstream& fs)
 			chunkheader++;
 			for(int counter = 0; counter < chunkheader; counter++)
 			{
-				fs.read((char*)&colorbuffer[0], bytes_per_pxl);
-				if(fs.gcount() != bytes_per_pxl)
+				fs.read((char*)&colorbuffer[0], bytesPerPxl);
+				if(fs.gcount() != bytesPerPxl)
 				{
 					ERROR("File \"" << filename << "\": Cannot read image data");
 					return false;
@@ -116,12 +118,12 @@ bool Image::loadCompressedTGA(const char* filename, fstream& fs)
 				data[currentbyte + 1] = colorbuffer[1];
 				data[currentbyte + 2] = colorbuffer[0];
 
-				if(bytes_per_pxl == 4)
+				if(bytesPerPxl == 4)
 				{
 					data[currentbyte + 3] = colorbuffer[3];
 				}
 
-				currentbyte += bytes_per_pxl;
+				currentbyte += bytesPerPxl;
 				currentpixel++;
 
 				if(currentpixel > pixelcount)
@@ -134,8 +136,8 @@ bool Image::loadCompressedTGA(const char* filename, fstream& fs)
 		else
 		{
 			chunkheader -= 127;
-			fs.read((char*)&colorbuffer[0], bytes_per_pxl);
-			if(fs.gcount() != bytes_per_pxl)
+			fs.read((char*)&colorbuffer[0], bytesPerPxl);
+			if(fs.gcount() != bytesPerPxl)
 			{
 				ERROR("File \"" << filename << "\": Cannot read from file");
 				return false;
@@ -147,12 +149,12 @@ bool Image::loadCompressedTGA(const char* filename, fstream& fs)
 				data[currentbyte+1] = colorbuffer[1];
 				data[currentbyte+2] = colorbuffer[0];
 
-				if(bytes_per_pxl == 4)
+				if(bytesPerPxl == 4)
 				{
 					data[currentbyte + 3] = colorbuffer[3];
 				}
 
-				currentbyte += bytes_per_pxl;
+				currentbyte += bytesPerPxl;
 				currentpixel++;
 
 				if(currentpixel > pixelcount)
@@ -169,12 +171,12 @@ bool Image::loadCompressedTGA(const char* filename, fstream& fs)
 
 
 //======================================================================================================================
-// loadTGA                                                                                                             =
+// loadTga                                                                                                             =
 //======================================================================================================================
-bool Image::loadTGA(const char* filename)
+bool Image::loadTga(const char* filename)
 {
 	fstream fs;
-	char my_tga_header[12];
+	char myTgaHeader[12];
 	fs.open(filename, ios::in|ios::binary);
 
 	if(!fs.good())
@@ -183,38 +185,38 @@ bool Image::loadTGA(const char* filename)
 		return false;
 	}
 
-	fs.read(&my_tga_header[0], sizeof(my_tga_header));
-	if(fs.gcount() != sizeof(my_tga_header))
+	fs.read(&myTgaHeader[0], sizeof(myTgaHeader));
+	if(fs.gcount() != sizeof(myTgaHeader))
 	{
 		ERROR("File \"" << filename << "\": Cannot read file header");
 		fs.close();
 		return false;
 	}
 
-	bool funcs_return;
-	if(memcmp(tgaHeaderUncompressed, &my_tga_header[0], sizeof(my_tga_header)) == 0)
+	bool funcsReturn;
+	if(memcmp(tgaHeaderUncompressed, &myTgaHeader[0], sizeof(myTgaHeader)) == 0)
 	{
-		funcs_return = loadUncompressedTGA(filename, fs);
+		funcsReturn = loadUncompressedTga(filename, fs);
 	}
-	else if(memcmp(tgaHeaderCompressed, &my_tga_header[0], sizeof(my_tga_header)) == 0)
+	else if(memcmp(tgaHeaderCompressed, &myTgaHeader[0], sizeof(myTgaHeader)) == 0)
 	{
-		funcs_return = loadCompressedTGA(filename, fs);
+		funcsReturn = loadCompressedTga(filename, fs);
 	}
 	else
 	{
 		ERROR("File \"" << filename << "\": Invalid image header");
-		funcs_return = false;
+		funcsReturn = false;
 	}
 
 	fs.close();
-	return funcs_return;
+	return funcsReturn;
 }
 
 
 //======================================================================================================================
-// loadPNG                                                                                                             =
+// loadPng                                                                                                             =
 //======================================================================================================================
-bool Image::loadPNG(const char* filename)
+bool Image::loadPng(const char* filename)
 {
 	SDL_Surface *sdli;
 	sdli = IMG_Load(filename);
@@ -236,20 +238,19 @@ bool Image::loadPNG(const char* filename)
 		return false;
 	}
 
-	int bytespp = bpp/8;
+	int bytespp = bpp / 8;
 	int bytes = width * height * bytespp;
-	data = new char [bytes];
+	data.reserve(bytes);
 
 	// copy and flip height
 	for(uint w=0; w<width; w++)
+	{
 		for(uint h=0; h<height; h++)
 		{
-			memcpy(
-				&data[(width*h+w) * bytespp],
-				&((char*)sdli->pixels)[(width*(height-h-1)+w) * bytespp],
-				bytespp
-			);
+			memcpy( &data[(width * h + w) * bytespp], &((char*)sdli->pixels)[(width * (height -h - 1) + w) * bytespp],
+			        bytespp);
 		}
+	}
 
 	SDL_FreeSurface(sdli);
 	return true;
@@ -262,22 +263,22 @@ bool Image::loadPNG(const char* filename)
 bool Image::load(const char* filename)
 {
 	// get the extension
-	string ext = Util::getFileExtension(filename);
+	string ext = filesystem::path(filename).extension();
+	to_lower(ext);
+
 
 	// load from this extension
 	if(ext == "tga")
 	{
-		if(!loadTGA(filename))
+		if(!loadTga(filename))
 		{
-			unload();
 			return false;
 		}
 	}
 	else if(ext == "png")
 	{
-		if(!loadPNG(filename))
+		if(!loadPng(filename))
 		{
-			unload();
 			return false;
 		}
 	}

+ 14 - 16
src/Resources/Helpers/Image.h

@@ -1,6 +1,7 @@
-#ifndef _IMAGE_H_
-#define _IMAGE_H_
+#ifndef IMAGE_H
+#define IMAGE_H
 
+#include <boost/ptr_container/ptr_vector.hpp>
 #include "Common.h"
 
 
@@ -9,26 +10,23 @@
  */
 class Image
 {
-	protected:
-		static unsigned char tgaHeaderUncompressed[12];
-		static unsigned char tgaHeaderCompressed[12];
-
-		bool loadUncompressedTGA(const char* filename, fstream& fs);
-		bool loadCompressedTGA(const char* filename, fstream& fs);
-		bool loadPNG(const char* filename);
-		bool loadTGA(const char* filename);
-
 	public:
 		uint  width;
 		uint  height;
 		uint  bpp;
-		char* data;
-
-		 Image(): data(NULL) {}
-		~Image() { unload(); }
+		ptr_vector<char> data;
 
 		bool load(const char* filename);
-		void unload() { if(data) delete [] data; data=NULL; }
+
+	private:
+		static uchar tgaHeaderUncompressed[12];
+		static uchar tgaHeaderCompressed[12];
+
+		bool loadUncompressedTga(const char* filename, fstream& fs);
+		bool loadCompressedTga(const char* filename, fstream& fs);
+		bool loadPng(const char* filename);
+		bool loadTga(const char* filename);
 };
 
+
 #endif

+ 3 - 0
src/Resources/ShaderProg.h

@@ -152,6 +152,9 @@ class ShaderProg: public Resource
 	//====================================================================================================================
 	private:
 		GLuint glId; ///< The OpenGL ID of the shader program
+		GLuint vertShaderGlId;
+		GLuint geomShaderGlId;
+		GLuint fragShaderGlId;
 		static string stdSourceCode;
 		Vec<UniVar> uniVars; ///< All the uniform variables
 		Vec<AttribVar> attribVars; ///< All the attribute variables

+ 28 - 12
src/Resources/Texture.cpp

@@ -30,7 +30,7 @@ Texture::Texture():
 bool Texture::load(const char* filename)
 {
 	target = GL_TEXTURE_2D;
-	if(glId != numeric_limits<uint>::max())
+	if(isLoaded())
 	{
 		ERROR("Texture already loaded");
 		return false;
@@ -72,13 +72,12 @@ bool Texture::load(const char* filename)
 		intFormat = (img.bpp==32) ? GL_RGBA : GL_RGB;
 	}
 
-	glTexImage2D(target, 0, intFormat, img.width, img.height, 0, format, GL_UNSIGNED_BYTE, img.data);
+	glTexImage2D(target, 0, intFormat, img.width, img.height, 0, format, GL_UNSIGNED_BYTE, &img.data[0]);
 	if(mipmappingEnabled)
 	{
 		glGenerateMipmap(target);
 	}
 
-	img.unload();
 	return true;
 }
 
@@ -86,12 +85,11 @@ bool Texture::load(const char* filename)
 //======================================================================================================================
 // createEmpty2D                                                                                                       =
 //======================================================================================================================
-bool Texture::createEmpty2D(float width_, float height_, int internalFormat, int format_, GLenum type_,
-                            bool mimapping)
+bool Texture::createEmpty2D(float width_, float height_, int internalFormat, int format_, GLenum type_, bool mimapping)
 {
 	target = GL_TEXTURE_2D;
 	DEBUG_ERR(internalFormat>0 && internalFormat<=4); // deprecated internal format
-	DEBUG_ERR(glId != numeric_limits<uint>::max()); // Texture already loaded
+	DEBUG_ERR(isLoaded());
 
 	// GL stuff
 	glGenTextures(1, &glId);
@@ -122,7 +120,7 @@ bool Texture::createEmpty2D(float width_, float height_, int internalFormat, int
 bool Texture::createEmpty2DMsaa(int samplesNum, int internalFormat, int width_, int height_, bool mimapping)
 {
 	target = GL_TEXTURE_2D_MULTISAMPLE;
-	DEBUG_ERR(glId != numeric_limits<uint>::max()); // Texture already loaded
+	DEBUG_ERR(isLoaded());
 
 	glGenTextures(1, &glId);
 	bind();
@@ -142,8 +140,8 @@ bool Texture::createEmpty2DMsaa(int samplesNum, int internalFormat, int width_,
 //======================================================================================================================
 void Texture::unload()
 {
-	glDeleteTextures(1, &glId);
-	INFO("ASFD");
+	if(isLoaded())
+		glDeleteTextures(1, &glId);
 }
 
 
@@ -156,7 +154,7 @@ void Texture::bind(uint unit) const
 		WARNING("Max tex units passed");
 
 	glActiveTexture(GL_TEXTURE0+unit);
-	glBindTexture(target, glId);
+	glBindTexture(target, getGlId());
 }
 
 
@@ -185,7 +183,7 @@ int Texture::getHeight() const
 
 
 //======================================================================================================================
-// setTexParameter [int]                                                                                                  =
+// setTexParameter [int]                                                                                               =
 //======================================================================================================================
 void Texture::setTexParameter(GLenum paramName, GLint value) const
 {
@@ -195,7 +193,7 @@ void Texture::setTexParameter(GLenum paramName, GLint value) const
 
 
 //======================================================================================================================
-// setTexParameter [float]                                                                                                =
+// setTexParameter [float]                                                                                             =
 //======================================================================================================================
 void Texture::texParameter(GLenum paramName, GLfloat value) const
 {
@@ -203,3 +201,21 @@ void Texture::texParameter(GLenum paramName, GLfloat value) const
 	glTexParameterf(target, paramName, value);
 }
 
+
+//======================================================================================================================
+// setRepeat                                                                                                           =
+//======================================================================================================================
+void Texture::setRepeat(bool repeat) const
+{
+	bind();
+	if(repeat)
+	{
+		setTexParameter(GL_TEXTURE_WRAP_S, GL_REPEAT);
+		setTexParameter(GL_TEXTURE_WRAP_T, GL_REPEAT);
+	}
+	else
+	{
+		setTexParameter(GL_TEXTURE_WRAP_S, GL_CLAMP);
+		setTexParameter(GL_TEXTURE_WRAP_T, GL_CLAMP);
+	}
+}

+ 6 - 14
src/Resources/Texture.h

@@ -39,33 +39,25 @@ class Texture: public Resource
 	protected:
 		GLuint glId; ///< Identification for OGL
 		GLenum target; ///< GL_TEXTURE_2D, GL_TEXTURE_3D... etc
-		static int  textureUnitsNum; ///< This needs to be filled after the main renderer initialization
+		static int  textureUnitsNum; ///< This needs to be filled in OpenGL initialization
 		static bool mipmappingEnabled;
 		static bool compressionEnabled;
 		static int  anisotropyLevel;
+
+		bool isLoaded() const;
 };
 
 
 inline GLuint Texture::getGlId() const
 {
-	DEBUG_ERR(glId==numeric_limits<uint>::max());
+	DEBUG_ERR(!isLoaded());
 	return glId;
 }
 
 
-inline void Texture::setRepeat(bool repeat) const
+inline bool Texture::isLoaded() const
 {
-	if(repeat)
-	{
-		setTexParameter(GL_TEXTURE_WRAP_S, GL_REPEAT);
-		setTexParameter(GL_TEXTURE_WRAP_T, GL_REPEAT);
-	}
-	else
-	{
-		setTexParameter(GL_TEXTURE_WRAP_S, GL_CLAMP);
-		setTexParameter(GL_TEXTURE_WRAP_T, GL_CLAMP);
-	}
+	return glId != numeric_limits<uint>::max();
 }
 
-
 #endif

Einige Dateien werden nicht angezeigt, da zu viele Dateien in diesem Diff geändert wurden.