Browse Source

*Redisining the ShaderProg

Panagiotis Christopoulos Charitos 16 years ago
parent
commit
1c3dfe8e43

+ 0 - 3
shaders/is_lp_point.glsl

@@ -1,3 +0,0 @@
-#define _POINT_LIGHT_
-
-#pragma anki include "shaders/is_lp_generic.glsl"

+ 0 - 3
shaders/is_lp_spot.glsl

@@ -1,3 +0,0 @@
-#define _SPOT_LIGHT_
-
-#pragma anki include "shaders/is_lp_generic.glsl"

+ 0 - 4
shaders/is_lp_spot_shad.glsl

@@ -1,4 +0,0 @@
-#define _SPOT_LIGHT_
-#define _SHADOW_
-
-#pragma anki include "shaders/is_lp_generic.glsl"

+ 19 - 19
shaders/pps.glsl

@@ -7,11 +7,11 @@
 #pragma anki include "shaders/photoshop_filters.glsl"
 #pragma anki include "shaders/median_filter.glsl"
 
-uniform sampler2D is_fai;
-uniform sampler2D pps_ssao_fai;
-uniform sampler2D ms_normal_fai;
-uniform sampler2D pps_hdr_fai;
-uniform sampler2D pps_lscatt_fai;
+uniform sampler2D isFai;
+uniform sampler2D ppsSsaoFai;
+uniform sampler2D msNormalFai;
+uniform sampler2D ppsHdrFai;
+uniform sampler2D ppsLscattFai;
 
 varying vec2 texCoords;
 
@@ -55,12 +55,12 @@ vec3 EdgeAA()
 	const vec2 kernel[8] = vec2[]( vec2(-1.0,1.0), vec2(1.0,-1.0), vec2(-1.0,-1.0), vec2(1.0,1.0), vec2(-1.0,0.0), vec2(1.0,0.0), vec2(0.0,-1.0), vec2(0.0,1.0) );
 	const float weight = 1.0;
 
-	vec3 tex = texture2D( ms_normal_fai, texCoords ).rgb;
+	vec3 tex = texture2D( msNormalFai, texCoords ).rgb;
 	float factor = -0.5;
 
 	for( int i=0; i<4; i++ )
 	{
-		vec3 t = texture2D( ms_normal_fai, texCoords + kernel[i]*pixelsize ).rgb;
+		vec3 t = texture2D( msNormalFai, texCoords + kernel[i]*pixelsize ).rgb;
 		t -= tex;
 		factor += dot(t, t);
 	}
@@ -68,16 +68,16 @@ vec3 EdgeAA()
 	factor = min(1.0, factor) * weight;
 
 	//return vec3(factor);
-	//if( factor < 0.01 ) return texture2D( is_fai, texCoords ).rgb;
+	//if( factor < 0.01 ) return texture2D( isFai, texCoords ).rgb;
 
 	vec3 color = vec3(0.0);
 
 	for( int i=0; i<8; i++ )
 	{
-		color += texture2D( is_fai, texCoords + kernel[i]*pixelsize*factor ).rgb;
+		color += texture2D( isFai, texCoords + kernel[i]*pixelsize*factor ).rgb;
 	}
 
-	color += 2.0 * texture2D( is_fai, texCoords ).rgb;
+	color += 2.0 * texture2D( isFai, texCoords ).rgb;
 
 	return color*(1.0/9.0);
 
@@ -113,17 +113,17 @@ vec3 EdgeAA()
 //
 //	/*if( factor < 0.001 )
 //	{
-//		return texture2D( is_fai, texCoords ).rgb;
+//		return texture2D( isFai, texCoords ).rgb;
 //	}*/
 //
 //	vec3 color = vec3(0.0);
 //
 //	for( int i=0; i<8; i++ )
 //	{
-//		color += texture2D( is_fai, texCoords + kernel[i]*pixelsize*factor ).rgb;
+//		color += texture2D( isFai, texCoords + kernel[i]*pixelsize*factor ).rgb;
 //	}
 //
-//	color += 2.0 * texture2D( is_fai, texCoords ).rgb;
+//	color += 2.0 * texture2D( isFai, texCoords ).rgb;
 //
 //	return color*(1.0/10.0);
 }
@@ -142,7 +142,7 @@ void main (void)
 	#if defined(_EDGEAA_)
 		color = EdgeAA();
 	#else
-		color = texture2D( is_fai, texCoords ).rgb;
+		color = texture2D( isFai, texCoords ).rgb;
 	#endif
 
 	/*const float gamma = 0.7;
@@ -151,17 +151,17 @@ void main (void)
 	color.b = pow(color.b, 1.0 / gamma);*/
 
 	#if defined(_SSAO_)
-		float ssao_factor = texture2D( pps_ssao_fai, texCoords ).a;
+		float ssao_factor = texture2D( ppsSsaoFai, texCoords ).a;
 		color *= ssao_factor;
 	#endif
 
 	#if defined(_LSCATT_)
-		vec3 lscatt = texture2D( pps_lscatt_fai, texCoords ).rgb;
+		vec3 lscatt = texture2D( ppsLscattFai, texCoords ).rgb;
 		color += lscatt;
 	#endif
 
 	#if defined(_HDR_)
-		vec3 hdr = texture2D( pps_hdr_fai, texCoords ).rgb;
+		vec3 hdr = texture2D( ppsHdrFai, texCoords ).rgb;
 		color += hdr;
 	#endif
 
@@ -176,8 +176,8 @@ void main (void)
 	//gl_FragData[0] = vec4( bloom_factor );
 	//gl_FragColor = vec4( EdgeAA(), 1.0 );
 	//gl_FragColor = texture2D( pps_boom_fai, texCoords );
-	//gl_FragColor = texture2D( is_fai, texCoords );
-	//gl_FragData[0].rgb = UnpackNormal( texture2D( ms_normal_fai, texCoords ).rg );
+	//gl_FragColor = texture2D( isFai, texCoords );
+	//gl_FragData[0].rgb = UnpackNormal( texture2D( msNormalFai, texCoords ).rg );
 	//gl_FragData[0] = vec4( hdr, 1.0 );
 }
 

+ 13 - 9
shaders/pps_hdr_generic.glsl

@@ -1,3 +1,7 @@
+/**
+ * Pass 0 horizontal blur, pass 1 vertical, pass 2 median
+ */
+
 #pragma anki vertShaderBegins
 
 #pragma anki include "shaders/simple_vert.glsl"
@@ -8,13 +12,13 @@
 
 varying vec2 texCoords;
 
-uniform sampler2D tex;
+uniform sampler2D fai;
 
 void main()
 {
-	//gl_FragData[0].rgb = texture2D( tex, texCoords).rgb;return;
+	//gl_FragData[0].rgb = texture2D( fai, texCoords).rgb;return;
 
-	/*if( texCoords.x*R_W > textureSize(tex,0).x/2 )
+	/*if( texCoords.x*R_W > textureSize(fai,0).x/2 )
 		gl_FragData[0].rgb = vec3( 1, 0, 0 );
 	else
 		gl_FragData[0].rgb = vec3( 0, 1, 0 );
@@ -24,9 +28,9 @@ void main()
 		const float super_offset = 2.5;
 
 		#if defined( _PPS_HDR_PASS0_ )
-			float offset = 1.0 / float(textureSize(tex,0).x) * super_offset;
+			float offset = 1.0 / float(textureSize(fai,0).x) * super_offset;
 		#else
-			float offset = 1.0 / float(textureSize(tex,0).y) * super_offset;
+			float offset = 1.0 / float(textureSize(fai,0).y) * super_offset;
 		#endif
 
 		const int KERNEL_SIZE = 9;
@@ -38,17 +42,17 @@ void main()
 		for( int i=0; i<KERNEL_SIZE; i++ )
 		{
 			#if defined( _PPS_HDR_PASS_0_ )
-				color += texture2D( tex, texCoords + vec2(kernel[i], 0.0) ).rgb;
+				color += texture2D( fai, texCoords + vec2(kernel[i], 0.0) ).rgb;
 			#else // _PPS_HDR_PASS_1_
-				color += texture2D( tex, texCoords + vec2(0.0, kernel[i]) ).rgb;
+				color += texture2D( fai, texCoords + vec2(0.0, kernel[i]) ).rgb;
 			#endif
 		}
 
 		gl_FragData[0].rgb = color / KERNEL_SIZE;
 
 	#else // _PPS_HDR_PASS_2_
-		vec3 color = MedianFilterRGB( tex, texCoords );
-		//vec3 color = texture2D( tex, texCoords ).rgb;
+		vec3 color = MedianFilterRGB( fai, texCoords );
+		//vec3 color = texture2D( fai, texCoords ).rgb;
 
 		float Y = dot(vec3(0.30, 0.59, 0.11), color);
 		const float exposure = 4.0;

+ 0 - 3
shaders/pps_hdr_pass0.glsl

@@ -1,3 +0,0 @@
-#define _PPS_HDR_PASS_0_
-
-#pragma anki include "shaders/pps_hdr_generic.glsl"

+ 0 - 3
shaders/pps_hdr_pass1.glsl

@@ -1,3 +0,0 @@
-#define _PPS_HDR_PASS_1_
-
-#pragma anki include "shaders/pps_hdr_generic.glsl"

+ 0 - 3
shaders/pps_hdr_pass2.glsl

@@ -1,3 +0,0 @@
-#define _PPS_HDR_PASS_2_
-
-#pragma anki include "shaders/pps_hdr_generic.glsl"

+ 7 - 9
shaders/pps_lscatt.glsl

@@ -10,12 +10,10 @@ float exposure = 2.0;
 float decay = 0.8;
 float density = 1.0;
 float weight = 0.3;
-uniform vec2 light_pos_screen_space = vec2(0.5, 0.5);
+uniform vec2 lightPosScreenSpace = vec2(0.5, 0.5);
 
-#pragma anki uniform ms_depth_fai 0
-uniform sampler2D ms_depth_fai;
-#pragma anki uniform is_fai 1
-uniform sampler2D is_fai;
+uniform sampler2D msDepthFai;
+uniform sampler2D isFai;
 
 varying vec2 texCoords;
 
@@ -23,7 +21,7 @@ varying vec2 texCoords;
 
 void main()
 {
-	vec2 delta_tex_coord = texCoords - light_pos_screen_space;
+	vec2 delta_tex_coord = texCoords - lightPosScreenSpace;
 	vec2 texCoords2 = texCoords;
 	delta_tex_coord *= 1.0 / float(SAMPLES_NUM) * density;
 	float illumination_decay = 1.0;
@@ -34,14 +32,14 @@ void main()
 	{
 		texCoords2 -= delta_tex_coord;
 
-		float depth = texture2D( ms_depth_fai, texCoords2 ).r;
+		float depth = texture2D( msDepthFai, texCoords2 ).r;
 		if( depth != 1.0 ) // if the fragment is not part of the skybox dont bother continuing
 		{
 			illumination_decay *= decay;
 			continue;
 		}
 
-		vec3 sample = texture2D( is_fai, texCoords2 ).rgb;			
+		vec3 sample = texture2D( isFai, texCoords2 ).rgb;			
 		sample *= illumination_decay * weight;
 		gl_FragData[0].rgb += sample;
 		illumination_decay *= decay;
@@ -49,6 +47,6 @@ void main()
 
 	gl_FragData[0].rgb *= exposure;
 	
-	//gl_FragData[0].rgb = texture2D( is_fai, texCoords ).rgb;
+	//gl_FragData[0].rgb = texture2D( isFai, texCoords ).rgb;
 	//gl_FragData[0].rgb = vec3(1, 1, 0);
 }

+ 6 - 0
src/main.cpp

@@ -162,12 +162,18 @@ void initPhysics()
 	dynamicsWorld->setDebugDrawer(&debugDrawer);
 }
 
+#include "ShaderParser.h"
+
 
 //=====================================================================================================================================
 // init                                                                                                                               =
 //=====================================================================================================================================
 void init()
 {
+	ShaderParser par;
+	par.parseFile( "test.glsl" );
+
+
 	PRINT( "Engine initializing..." );
 
 	initPhysics();

+ 3 - 3
src/renderer/Bs.cpp

@@ -28,7 +28,7 @@ static Fbo fbo; ///< blending models FBO
 void init()
 {
 	// create FBO
-	fbo.Create();
+	fbo.create();
 	fbo.bind();
 
 	// inform FBO about the color buffers
@@ -43,7 +43,7 @@ void init()
 		FATAL( "Cannot create deferred shading blending stage FBO" );
 
 	// unbind
-	fbo.Unbind();
+	fbo.unbind();
 }
 
 
@@ -77,7 +77,7 @@ void runStage( const Camera& cam )
 
 	// restore a few things
 	glDepthMask( true );
-	Fbo::Unbind();
+	Fbo::unbind();
 }
 
 

+ 5 - 5
src/renderer/Bs2.cpp

@@ -32,7 +32,7 @@ void init2()
 {
 	//** 1st FBO **
 	// create FBO
-	fbo.Create();
+	fbo.create();
 	fbo.bind();
 
 	// inform FBO about the color buffers
@@ -47,11 +47,11 @@ void init2()
 		FATAL( "Cannot create deferred shading blending stage FBO" );
 
 	// unbind
-	fbo.Unbind();
+	fbo.unbind();
 
 
 	//** 2nd FBO **
-	intermid_fbo.Create();
+	intermid_fbo.create();
 	intermid_fbo.bind();
 
 	// texture
@@ -67,7 +67,7 @@ void init2()
 		FATAL( "Cannot create deferred shading blending stage FBO" );
 
 	// unbind
-	intermid_fbo.Unbind();
+	intermid_fbo.unbind();
 
 	shaderProg = rsrc::shaders.load( "shaders/bs_refract.glsl" );
 }
@@ -109,7 +109,7 @@ void runStage2( const Camera& cam )
 
 	// restore a few things
 	glDepthMask( true );
-	Fbo::Unbind();
+	Fbo::unbind();
 }
 
 

+ 42 - 52
src/renderer/Dbg.cpp

@@ -71,21 +71,21 @@ bool showSkeletons = false;
 bool showCameras = true;
 bool showBvolumes = true;
 
-
 static Fbo fbo;
 
-static ShaderProg* shdr;
+class DbgShaderProg: public ShaderProg
+{};
+
+static DbgShaderProg sProg;
 
 
-/*
-=======================================================================================================================================
-init                                                                                                                                  =
-=======================================================================================================================================
-*/
+//=====================================================================================================================================
+// init                                                                                                                               =
+//=====================================================================================================================================
 void init()
 {
 	// create FBO
-	fbo.Create();
+	fbo.create();
 	fbo.bind();
 
 	// inform in what buffers we draw
@@ -100,23 +100,21 @@ void init()
 		FATAL( "Cannot create debug FBO" );
 
 	// unbind
-	fbo.Unbind();
+	fbo.unbind();
 
 	// shader
-	shdr = rsrc::shaders.load( "shaders/dbg.glsl" );
+	sProg.customLoad( "shaders/dbg.glsl" );
 }
 
 
-/*
-=======================================================================================================================================
-runStage                                                                                                                              =
-=======================================================================================================================================
-*/
+//=====================================================================================================================================
+// runStage                                                                                                                           =
+//=====================================================================================================================================
 void runStage( const Camera& cam )
 {
 	fbo.bind();
 
-	shdr->bind();
+	sProg.bind();
 
 	// OGL stuff
 	R::setProjectionViewMatrices( cam );
@@ -152,20 +150,18 @@ void runStage( const Camera& cam )
 
 
 	// unbind
-	fbo.Unbind();
+	fbo.unbind();
 }
 
 
-/*
-=======================================================================================================================================
-renderGrid                                                                                                                            =
-=======================================================================================================================================
-*/
+//=====================================================================================================================================
+// renderGrid                                                                                                                         =
+//=====================================================================================================================================
 void renderGrid()
 {
-	float col0[] = { 0.5f, 0.5f, 0.5f };
-	float col1[] = { 0.0f, 0.0f, 1.0f };
-	float col2[] = { 1.0f, 0.0f, 0.0f };
+	float col0[] = { 0.5, 0.5, 0.5 };
+	float col1[] = { 0.0, 0.0, 1.0 };
+	float col2[] = { 1.0, 0.0, 0.0 };
 
 	glDisable( GL_TEXTURE_2D );
 	glDisable( GL_LIGHTING );
@@ -201,11 +197,9 @@ void renderGrid()
 }
 
 
-/*
-=======================================================================================================================================
-renderQuad                                                                                                                            =
-=======================================================================================================================================
-*/
+//=====================================================================================================================================
+// renderQuad                                                                                                                         =
+//=====================================================================================================================================
 void renderQuad( float w, float h )
 {
 	float wdiv2 = w/2, hdiv2 = h/2;
@@ -226,11 +220,9 @@ void renderQuad( float w, float h )
 }
 
 
-/*
-=======================================================================================================================================
-renderSphere                                                                                                                          =
-=======================================================================================================================================
-*/
+//=====================================================================================================================================
+// renderSphere                                                                                                                       =
+//=====================================================================================================================================
 void renderSphere( float r, int p )
 {
 	const float twopi  = PI*2;
@@ -240,13 +232,13 @@ void renderSphere( float r, int p )
 	float theta2 = 0.0;
 	float theta3 = 0.0;
 
-	float ex = 0.0f;
-	float ey = 0.0f;
-	float ez = 0.0f;
+	float ex = 0.0;
+	float ey = 0.0;
+	float ez = 0.0;
 
-	float px = 0.0f;
-	float py = 0.0f;
-	float pz = 0.0f;
+	float px = 0.0;
+	float py = 0.0;
+	float pz = 0.0;
 
 
 	for( int i = 0; i < p/2; ++i )
@@ -296,53 +288,51 @@ void renderSphere( float r, int p )
 }
 
 
-/*
-=======================================================================================================================================
-renderCube                                                                                                                            =
-=======================================================================================================================================
-*/
+//=====================================================================================================================================
+// renderCube                                                                                                                         =
+//=====================================================================================================================================
 void renderCube( bool cols, float size )
 {
 	size *= 0.5f;
 	glBegin(GL_QUADS);
 		// Front Face
 		if(cols) glColor3f( 0.0, 0.0, 1.0 );
-		glNormal3f( 0.0f, 0.0f, 1.0f);
+		glNormal3f( 0.0, 0.0, 1.0f);
 		glTexCoord2f(0.0, 0.0); glVertex3f(-size, -size,  size);
 		glTexCoord2f(1.0, 0.0); glVertex3f( size, -size,  size);
 		glTexCoord2f(1.0, 1.0); glVertex3f( size,  size,  size);
 		glTexCoord2f(0.0, 1.0); glVertex3f(-size,  size,  size);
 		// Back Face
 		if(cols) glColor3f( 0.0, 0.0, size );
-		glNormal3f( 0.0f, 0.0f,-1.0f);
+		glNormal3f( 0.0, 0.0,-1.0f);
 		glTexCoord2f(1.0, 0.0); glVertex3f(-size, -size, -size);
 		glTexCoord2f(1.0, 1.0); glVertex3f(-size,  size, -size);
 		glTexCoord2f(0.0, 1.0); glVertex3f( size,  size, -size);
 		glTexCoord2f(0.0, 0.0); glVertex3f( size, -size, -size);
 		// Top Face
 		if(cols) glColor3f( 0.0, 1.0, 0.0 );
-		glNormal3f( 0.0f, 1.0f, 0.0f);
+		glNormal3f( 0.0, 1.0f, 0.0);
 		glTexCoord2f(0.0, 1.0); glVertex3f(-size,  size, -size);
 		glTexCoord2f(0.0, 0.0); glVertex3f(-size,  size,  size);
 		glTexCoord2f(1.0, 0.0); glVertex3f( size,  size,  size);
 		glTexCoord2f(1.0, 1.0); glVertex3f( size,  size, -size);
 		// Bottom Face
 		if(cols) glColor3f( 0.0, size, 0.0 );
-		glNormal3f( 0.0f,-1.0f, 0.0f);
+		glNormal3f( 0.0,-1.0f, 0.0);
 		glTexCoord2f(1.0, 1.0); glVertex3f(-size, -size, -size);
 		glTexCoord2f(0.0, 1.0); glVertex3f( size, -size, -size);
 		glTexCoord2f(0.0, 0.0); glVertex3f( size, -size,  size);
 		glTexCoord2f(1.0, 0.0); glVertex3f(-size, -size,  size);
 		// Right face
 		if(cols) glColor3f( 1.0, 0.0, 0.0 );
-		glNormal3f( 1.0f, 0.0f, 0.0f);
+		glNormal3f( 1.0f, 0.0, 0.0);
 		glTexCoord2f(1.0, 0.0); glVertex3f( size, -size, -size);
 		glTexCoord2f(1.0, 1.0); glVertex3f( size,  size, -size);
 		glTexCoord2f(0.0, 1.0); glVertex3f( size,  size,  size);
 		glTexCoord2f(0.0, 0.0); glVertex3f( size, -size,  size);
 		// Left Face
 		if(cols) glColor3f( size, 0.0, 0.0 );
-		glNormal3f(-1.0f, 0.0f, 0.0f);
+		glNormal3f(-1.0f, 0.0, 0.0);
 		glTexCoord2f(0.0, 0.0); glVertex3f(-size, -size, -size);
 		glTexCoord2f(1.0, 0.0); glVertex3f(-size, -size,  size);
 		glTexCoord2f(1.0, 1.0); glVertex3f(-size,  size,  size);

+ 1 - 1
src/renderer/Earlyz.cpp

@@ -33,7 +33,7 @@ init
 void init()
 {
 	// create FBO
-	fbo.Create();
+	fbo.create();
 	fbo.bind();
 
 	// inform the we wont write to color buffers

+ 2 - 2
src/renderer/Fbo.h

@@ -14,7 +14,7 @@ class Fbo
 		Fbo(): glId(0) {}
 
 		/// Creates a new FBO
-		void Create()
+		void create()
 		{
 			DEBUG_ERR( glId != 0 ); // FBO already initialized
 			glGenFramebuffers( 1, &glId );
@@ -28,7 +28,7 @@ class Fbo
 		}
 
 		/// Unbinds the FBO. Actualy unbinds all FBOs
-		static void Unbind() { glBindFramebuffer( GL_FRAMEBUFFER, 0 ); }
+		static void unbind() { glBindFramebuffer( GL_FRAMEBUFFER, 0 ); }
 
 		/**
 		 * Checks the status of an initialized FBO

+ 49 - 55
src/renderer/Hdr.cpp

@@ -13,14 +13,12 @@ namespace Pps {
 namespace Hdr {
 
 
-/*
-=======================================================================================================================================
-VARS                                                                                                                                  =
-=======================================================================================================================================
-*/
+//=====================================================================================================================================
+// VARS                                                                                                                               =
+//=====================================================================================================================================
 bool enabled = true;
 
-static Fbo pass0_fbo, pass1_fbo, pass2_fbo; // yet another FBO and another, damn
+static Fbo pass0Fbo, pass1Fbo, pass2Fbo; // yet another FBO and another, damn
 
 float renderingQuality = 0.25; // 1/4 of the image
 static uint wwidth, wheight; // render width and height
@@ -28,27 +26,34 @@ static uint wwidth, wheight; // render width and height
 // hdr images
 Texture pass0Fai; // for vertical blur pass
 Texture pass1Fai; // with the horizontal blur
-Texture pass2Fai;
+Texture fai; ///< The final fai
+
+class HdrShaderProg: public ShaderProg
+{
+	public:
+		struct
+		{
+			int fai;
+		} uniLocs;
+};
 
-static ShaderProg* pass0_shdr, * pass1_shdr, * pass2_shdr; // hdr pass 0 and pass 1 shaders
+static HdrShaderProg pass0SProg, pass1SProg, pass2SProg;
 
 
-/*
-=======================================================================================================================================
-InitFBOs                                                                                                                              =
-=======================================================================================================================================
-*/
-static void InitFBOs( Fbo& fbo, Texture& fai, int internal_format )
+//=====================================================================================================================================
+// initFbos                                                                                                                           =
+//=====================================================================================================================================
+static void initFbos( Fbo& fbo, Texture& fai, int internalFormat )
 {
 	// create FBO
-	fbo.Create();
+	fbo.create();
 	fbo.bind();
 
 	// inform in what buffers we draw
 	fbo.setNumOfColorAttachements(1);
 
 	// create the texes
-	fai.createEmpty2D( wwidth, wheight, internal_format, GL_RGB );
+	fai.createEmpty2D( wwidth, wheight, internalFormat, GL_RGB );
 	fai.texParameter( GL_TEXTURE_MAG_FILTER, GL_LINEAR );
 	fai.texParameter( GL_TEXTURE_MIN_FILTER, GL_NEAREST );
 
@@ -60,36 +65,37 @@ static void InitFBOs( Fbo& fbo, Texture& fai, int internal_format )
 		FATAL( "Cannot create deferred shading post-processing stage HDR passes FBO" );
 
 	// unbind
-	fbo.Unbind();
+	fbo.unbind();
 }
 
 
-/*
-=======================================================================================================================================
-init                                                                                                                                  =
-=======================================================================================================================================
-*/
+//=====================================================================================================================================
+// init                                                                                                                               =
+//=====================================================================================================================================
 void init()
 {
 	wwidth = R::Pps::Hdr::renderingQuality * R::w;
 	wheight = R::Pps::Hdr::renderingQuality * R::h;
 
-	InitFBOs( pass0_fbo, pass0Fai, GL_RGB );
-	InitFBOs( pass1_fbo, pass1Fai, GL_RGB );
-	InitFBOs( pass2_fbo, pass2Fai, GL_RGB );
+	initFbos( pass0Fbo, pass0Fai, GL_RGB );
+	initFbos( pass1Fbo, pass1Fai, GL_RGB );
+	initFbos( pass2Fbo, fai, GL_RGB );
 
 	// init shaders
-	pass0_shdr = rsrc::shaders.load( "shaders/pps_hdr_pass0.glsl" );
-	pass1_shdr = rsrc::shaders.load( "shaders/pps_hdr_pass1.glsl" );
-	pass2_shdr = rsrc::shaders.load( "shaders/pps_hdr_pass2.glsl" );
+	pass0SProg.customLoad( "shaders/pps_hdr_generic.glsl", "#define _PPS_HDR_PASS_0_\n" );
+	pass0SProg.uniLocs.fai = pass0SProg.uniLocs.fai;
+
+	pass1SProg.customLoad( "shaders/pps_hdr_generic.glsl", "#define _PPS_HDR_PASS_1_\n" );
+	pass1SProg.uniLocs.fai = pass1SProg.uniLocs.fai;
+
+	pass2SProg.customLoad( "shaders/pps_hdr_generic.glsl", "#define _PPS_HDR_PASS_2_\n" );
+	pass2SProg.uniLocs.fai = pass2SProg.uniLocs.fai;
 }
 
 
-/*
-=======================================================================================================================================
-runPass                                                                                                                               =
-=======================================================================================================================================
-*/
+//=====================================================================================================================================
+// runPass                                                                                                                            =
+//=====================================================================================================================================
 void runPass( const Camera& /*cam*/ )
 {
 	R::setViewport( 0, 0, wwidth, wheight );
@@ -99,39 +105,27 @@ void runPass( const Camera& /*cam*/ )
 
 
 	// pass 0
-	pass0_fbo.bind();
-
-	pass0_shdr->bind();
-
-	pass0_shdr->locTexUnit( pass0_shdr->getUniVar("tex").getLoc(), R::Is::fai, 0 );
-
-	// Draw quad
+	pass0Fbo.bind();
+	pass0SProg.bind();
+	pass0SProg.locTexUnit( pass0SProg.uniLocs.fai, R::Is::fai, 0 );
 	R::DrawQuad( 0 );
 
 
 	// pass 1
-	pass1_fbo.bind();
-
-	pass1_shdr->bind();
-
-	pass1_shdr->locTexUnit( pass1_shdr->getUniVar("tex").getLoc(), pass0Fai, 0 );
-
-	// Draw quad
+	pass1Fbo.bind();
+	pass1SProg.bind();
+	pass1SProg.locTexUnit( pass1SProg.uniLocs.fai, pass0Fai, 0 );
 	R::DrawQuad( 0 );
 
 
 	// pass 2
-	pass2_fbo.bind();
-
-	pass2_shdr->bind();
-
-	pass2_shdr->locTexUnit( pass2_shdr->getUniVar("tex").getLoc(), pass1Fai, 0 );
-
-	// Draw quad
+	pass2Fbo.bind();
+	pass2SProg.bind();
+	pass2SProg.locTexUnit( pass2SProg.uniLocs.fai, pass1Fai, 0 );
 	R::DrawQuad( 0 );
 
 	// end
-	Fbo::Unbind();
+	Fbo::unbind();
 }
 
 

File diff suppressed because it is too large
+ 41 - 12
src/renderer/Is.cpp


+ 13 - 13
src/renderer/Lscatt.cpp

@@ -21,9 +21,9 @@ bool enabled = false;
 
 Texture fai;
 
-static ShaderProg* shdr;
-static int ms_depth_fai_uni_loc;
-static int is_fai_uni_loc;
+static ShaderProg sProg;
+static int msDepthFaiUniLoc;
+static int isFaiUniLoc;
 
 
 /*
@@ -38,7 +38,7 @@ void init()
 	float wheight = R::Pps::Lscatt::renderingQuality * R::h;
 
 	// create FBO
-	fbo.Create();
+	fbo.create();
 	fbo.bind();
 
 	// inform in what buffers we draw
@@ -57,13 +57,13 @@ void init()
 		FATAL( "Cannot create deferred shading post-processing stage light scattering pass FBO" );
 
 	// unbind
-	fbo.Unbind();
+	fbo.unbind();
 
 
 	// init shaders
-	shdr = rsrc::shaders.load( "shaders/pps_lscatt.glsl" );
-	ms_depth_fai_uni_loc = shdr->getUniVar( "ms_depth_fai" ).getLoc();
-	is_fai_uni_loc = shdr->getUniVar( "is_fai" ).getLoc();
+	sProg.customLoad( "shaders/pps_lscatt.glsl" );
+	msDepthFaiUniLoc = sProg.getUniVar( "msDepthFai" ).getLoc();
+	isFaiUniLoc = sProg.getUniVar( "isFai" ).getLoc();
 }
 
 
@@ -82,23 +82,23 @@ void runPass( const Camera& cam )
 	glDisable( GL_DEPTH_TEST );
 
 	// set the shader
-	shdr->bind();
+	sProg.bind();
 
-	shdr->locTexUnit( ms_depth_fai_uni_loc, R::Ms::depthFai, 0 );
-	shdr->locTexUnit( is_fai_uni_loc, R::Is::fai, 1 );
+	sProg.locTexUnit( msDepthFaiUniLoc, R::Ms::depthFai, 0 );
+	sProg.locTexUnit( isFaiUniLoc, R::Is::fai, 1 );
 
 	// pass the light
 	Vec4 p = Vec4( Scene::getSunPos(), 1.0 );
 	p = cam.getProjectionMatrix() * (cam.getViewMatrix() * p);
 	p /= p.w;
 	p = p/2 + 0.5;
-	glUniform2fv( shdr->getUniVar("light_pos_screen_space").getLoc(), 1, &p[0] );
+	glUniform2fv( sProg.getUniVar("lightPosScreenSpace").getLoc(), 1, &p[0] );
 
 	// Draw quad
 	R::DrawQuad( 0 );
 
 	// end
-	fbo.Unbind();
+	fbo.unbind();
 }
 
 

+ 3 - 3
src/renderer/Ms.cpp

@@ -32,7 +32,7 @@ Texture normalFai, diffuseFai, specularFai, depthFai;
 void init()
 {
 	// create FBO
-	fbo.Create();
+	fbo.create();
 	fbo.bind();
 
 	// inform in what buffers we draw
@@ -66,7 +66,7 @@ void init()
 		FATAL( "Cannot create deferred shading material pass FBO" );
 
 	// unbind
-	fbo.Unbind();
+	fbo.unbind();
 
 #if defined( _EARLY_Z_ )
 	R::Ms::earlyz::init();
@@ -119,7 +119,7 @@ void runStage( const Camera& cam )
 		glDepthFunc( GL_LESS );
 	#endif
 
-	fbo.Unbind();
+	fbo.unbind();
 }
 
 

+ 33 - 25
src/renderer/Pps.cpp

@@ -21,7 +21,7 @@ static Fbo fbo; // yet another FBO
 Texture fai;
 
 // shader stuff
-static ShaderProg* sProg;
+/*static ShaderProg* sProg;
 
 namespace shdrVars
 {
@@ -30,7 +30,22 @@ namespace shdrVars
 	int msNormalFai;
 	int hdrFai;
 	int lscattFai;
-}
+}*/
+
+class PpsShaderProg: public ShaderProg
+{
+	public:
+		struct
+		{
+			int isFai;
+			int ppsSsaoFai;
+			int msNormalFai;
+			int hdrFai;
+			int lscattFai;
+		} uniLocs;
+};
+
+static PpsShaderProg sProg;
 
 
 /*
@@ -41,7 +56,7 @@ init
 void init()
 {
 	// create FBO
-	fbo.Create();
+	fbo.create();
 	fbo.bind();
 
 	// inform in what buffers we draw
@@ -57,34 +72,34 @@ void init()
 	if( !fbo.isGood() )
 		FATAL( "Cannot create post-processing stage FBO" );
 
-	fbo.Unbind();
+	fbo.unbind();
 
 
 	// init the shader and it's vars
-	sProg = rsrc::shaders.load( "shaders/pps.glsl" );
-	sProg->bind();
+	sProg.customLoad( "shaders/pps.glsl" );
+	sProg.bind();
 
-	shdrVars::isFai = sProg->getUniVar( "is_fai" ).getLoc();
+	sProg.uniLocs.isFai = sProg.getUniVar( "isFai" ).getLoc();
 
 	if( R::Pps::Ssao::enabled )
 	{
 		R::Pps::Ssao::init();
-		shdrVars::ppsSsaoFai = sProg->getUniVar( "pps_ssao_fai" ).getLoc();
+		sProg.uniLocs.ppsSsaoFai = sProg.getUniVar( "ppsSsaoFai" ).getLoc();
 	}
 
 	if( R::Pps::Hdr::enabled )
 	{
 		R::Pps::Hdr::init();
-		shdrVars::hdrFai = sProg->getUniVar( "pps_hdr_fai" ).getLoc();
+		sProg.uniLocs.hdrFai = sProg.getUniVar( "ppsHdrFai" ).getLoc();
 	}
 
 	if( R::Pps::edgeaa::enabled )
-		shdrVars::msNormalFai = sProg->getUniVar( "ms_normal_fai" ).getLoc();
+		sProg.uniLocs.msNormalFai = sProg.getUniVar( "msNormalFai" ).getLoc();
 
 	if( R::Pps::Lscatt::enabled )
 	{
 		R::Pps::Lscatt::init();
-		shdrVars::lscattFai = sProg->getUniVar( "pps_lscatt_fai" ).getLoc();
+		sProg.uniLocs.lscattFai = sProg.getUniVar( "ppsLscattFai" ).getLoc();
 	}
 
 }
@@ -115,35 +130,28 @@ void runStage( const Camera& cam )
 	R::setViewport( 0, 0, R::w, R::h );
 
 	// set shader
-	sProg->bind();
+	sProg.bind();
 
-	R::Is::fai.bind(0);
-	//R::Ms::depthFai.bind(0);
-	glUniform1i( shdrVars::isFai, 0 );
+	sProg.locTexUnit( sProg.uniLocs.isFai, R::Is::fai, 0 );
 
 	if( R::Pps::Ssao::enabled )
 	{
-		R::Pps::Ssao::bluredFai2.bind(1);
-		glUniform1i( shdrVars::ppsSsaoFai, 1 );
+		sProg.locTexUnit( sProg.uniLocs.ppsSsaoFai, R::Pps::Ssao::bluredFai2, 1 );
 	}
 
 	if( R::Pps::edgeaa::enabled )
 	{
-		R::Ms::normalFai.bind(2);
-		glUniform1i( shdrVars::msNormalFai, 2 );
+		sProg.locTexUnit( sProg.uniLocs.msNormalFai, R::Ms::normalFai, 2 );
 	}
 
 	if( R::Pps::Hdr::enabled )
 	{
-		R::Pps::Hdr::pass2Fai.bind(3);
-		//R::Bs::r_fai.bind(3);
-		glUniform1i( shdrVars::hdrFai, 3 );
+		sProg.locTexUnit( sProg.uniLocs.hdrFai, R::Pps::Hdr::fai, 3 );
 	}
 
 	if( R::Pps::Lscatt::enabled )
 	{
-		R::Pps::Lscatt::fai.bind(4);
-		glUniform1i( shdrVars::lscattFai, 4 );
+		sProg.locTexUnit( sProg.uniLocs.lscattFai, R::Pps::Lscatt::fai, 4 );
 	}
 
 
@@ -151,7 +159,7 @@ void runStage( const Camera& cam )
 	R::DrawQuad( 0 );
 
 	// unbind FBO
-	fbo.Unbind();
+	fbo.unbind();
 }
 
 

+ 1 - 1
src/renderer/Renderer.h

@@ -143,7 +143,7 @@ namespace Pps
 		extern void    runPass( const Camera& cam );
 		extern Texture pass0Fai;
 		extern Texture pass1Fai;
-		extern Texture pass2Fai;
+		extern Texture fai;
 		extern float   renderingQuality;
 	}
 

+ 3 - 9
src/renderer/Shadows.cpp

@@ -20,7 +20,6 @@ bool bilinear = true;
 
 static Fbo fbo;
 
-ShaderProg* shdr_depth, * shdr_depth_grass, * shdr_depth_hw_skinning;
 
 // exportable vars
 int shadowResolution = 512;
@@ -35,7 +34,7 @@ init
 void init()
 {
 	// create FBO
-	fbo.Create();
+	fbo.create();
 	fbo.bind();
 
 	// texture
@@ -60,12 +59,7 @@ void init()
 		FATAL( "Cannot create shadow FBO" );
 
 	// unbind
-	fbo.Unbind();
-
-	// shaders
-	shdr_depth = rsrc::shaders.load( "shaders/dp.glsl" );
-	shdr_depth_grass = rsrc::shaders.load( "shaders/dp_grass.glsl" );
-	shdr_depth_hw_skinning = rsrc::shaders.load( "shaders/dp_hw_skinning.glsl" );
+	fbo.unbind();
 }
 
 
@@ -125,7 +119,7 @@ void runPass( const Camera& cam )
 	glPopMatrix();
 
 	// FBO
-	fbo.Unbind();
+	fbo.unbind();
 }
 
 

+ 7 - 7
src/renderer/Ssao.cpp

@@ -39,7 +39,7 @@ static Texture* noise_map;
 static void InitBlurFBO()
 {
 	// create FBO
-	blurFbo.Create();
+	blurFbo.create();
 	blurFbo.bind();
 
 	// inform in what buffers we draw
@@ -58,12 +58,12 @@ static void InitBlurFBO()
 		FATAL( "Cannot create deferred shading post-processing stage SSAO blur FBO" );
 
 	// unbind
-	blurFbo.Unbind();
+	blurFbo.unbind();
 
 
 
 	// create FBO
-	blurFbo2.Create();
+	blurFbo2.create();
 	blurFbo2.bind();
 
 	// inform in what buffers we draw
@@ -82,7 +82,7 @@ static void InitBlurFBO()
 		FATAL( "Cannot create deferred shading post-processing stage SSAO blur FBO" );
 
 	// unbind
-	blurFbo2.Unbind();
+	blurFbo2.unbind();
 }
 
 
@@ -98,7 +98,7 @@ void init()
 	wheight = R::Pps::Ssao::renderingQuality * R::h;
 
 	// create FBO
-	fbo.Create();
+	fbo.create();
 	fbo.bind();
 
 	// inform in what buffers we draw
@@ -117,7 +117,7 @@ void init()
 		FATAL( "Cannot create deferred shading post-processing stage SSAO pass FBO" );
 
 	// unbind
-	fbo.Unbind();
+	fbo.unbind();
 
 
 	// init shaders
@@ -180,7 +180,7 @@ void runPass( const Camera& cam )
 
 
 	// end
-	Fbo::Unbind();
+	Fbo::unbind();
 }
 
 

+ 1 - 1
src/renderer2/r_is.cpp

@@ -88,7 +88,7 @@ void renderer_t::illumination_stage_t::CalcPlanes()
 //=====================================================================================================================================
 void renderer_t::illumination_stage_t::ambient_pass_t::init()
 {
-	shaderProg.customload( "shaders/is_ap.glsl", "" );
+	shaderProg.customLoad( "shaders/is_ap.glsl", "" );
 }
 
 

+ 1 - 1
src/renderer2/r_ms.cpp

@@ -9,7 +9,7 @@
 void renderer_t::material_stage_t::init()
 {
 	// create FBO
-	fbo.Create();
+	fbo.create();
 	fbo.bind();
 
 	// inform in what buffers we draw

+ 65 - 21
src/resources/ShaderParser.cpp

@@ -47,8 +47,15 @@ Vec<ShaderParser::ShaderVarPragma>::iterator ShaderParser::findShaderVar( Vec<Sh
 //=====================================================================================================================================
 // parseFileForPragmas                                                                                                                =
 //=====================================================================================================================================
-bool ShaderParser::parseFileForPragmas( const string& filename, int id )
+bool ShaderParser::parseFileForPragmas( const string& filename, int depth )
 {
+	// first check the depth
+	if( depth > 99 )
+	{
+		ERROR( "The include depth is too high. Probably circular includance (Im in file \"" << filename << "\")" );
+		return false;
+	}
+
 	// load file in lines
 	Vec<string> lines = Util::getFileLines( filename.c_str() );
 	if( lines.size() < 1 )
@@ -80,45 +87,63 @@ bool ShaderParser::parseFileForPragmas( const string& filename, int id )
 					if( token->code == Scanner::TC_IDENTIFIER && strcmp(token->value.string, "vertShaderBegins") == 0 )
 					{
 						// play
-						if( fragShaderBegins.definedInLine != -1 ) // check if frag shader already defined
+
+						// its defined in same place so there is probable circular includance
+						if( vertShaderBegins.definedInLine==scanner.getLineNmbr() && vertShaderBegins.definedInFile==filename )
 						{
-							PARSE_ERR( "vertShaderBegins must precede fragShaderBegins defined at " << fragShaderBegins.definedInFile <<
-							           ":" << fragShaderBegins.definedInLine );
+							PARSE_ERR( "vertShaderBegins already defined in the same place. Check for circular or multiple includance" );
 							return false;
 						}
-						
-						if( vertShaderBegins.definedInLine != -1 ) // already defined elseware so throw error
+
+						if( vertShaderBegins.definedInLine != -1 ) // already defined elsewhere so throw error
 						{
 							PARSE_ERR( "vertShaderBegins already defined at " << vertShaderBegins.definedInFile << ":" <<
 							           vertShaderBegins.definedInLine );
 							return false;
 						}
+
+						if( fragShaderBegins.definedInLine != -1 ) // frag shader should be after vert
+						{
+							PARSE_ERR( "vertShaderBegins must precede fragShaderBegins defined at " << fragShaderBegins.definedInFile <<
+							           ":" << fragShaderBegins.definedInLine );
+							return false;
+						}
+						
 						vertShaderBegins.definedInFile = filename;
 						vertShaderBegins.definedInLine = scanner.getLineNmbr();
 						vertShaderBegins.globalLine = sourceLines.size() + 1;
-						sourceLines.push_back( string("#line ") + Util::intToStr(scanner.getLineNmbr()) + ' ' + Util::intToStr(id) + " // " + lines[scanner.getLineNmbr()-1] );
+						sourceLines.push_back( string("#line ") + Util::intToStr(scanner.getLineNmbr()) + ' ' + Util::intToStr(depth) + " // " + lines[scanner.getLineNmbr()-1] );
 						// stop play
 					}
 /* fragShaderBegins */
 					else if( token->code == Scanner::TC_IDENTIFIER && strcmp(token->value.string, "fragShaderBegins") == 0 )
 					{
 						// play
-						if( vertShaderBegins.definedInLine == -1 )
+
+						// its defined in same place so there is probable circular includance
+						if( fragShaderBegins.definedInLine==scanner.getLineNmbr() && fragShaderBegins.definedInFile==filename )
 						{
-							PARSE_ERR( "fragShaderBegins should be defined after vertShaderBegins" );
+							PARSE_ERR( "fragShaderBegins already defined in the same place. Check for circular or multiple includance" );
 							return false;
 						}
-						
-						if( fragShaderBegins.definedInLine != -1 ) // if already defined elseware throw error
+
+						if( fragShaderBegins.definedInLine != -1 ) // if already defined elsewhere throw error
 						{
 							PARSE_ERR( "fragShaderBegins already defined at " << fragShaderBegins.definedInFile << ":" <<
 							           fragShaderBegins.definedInLine );
 							return false;
 						}
+						
+						if( vertShaderBegins.definedInLine == -1 ) // vert shader entry point not defined
+						{
+							PARSE_ERR( "fragShaderBegins should be defined after vertShaderBegins" );
+							return false;
+						}
+
 						fragShaderBegins.definedInFile = filename;
 						fragShaderBegins.definedInLine = scanner.getLineNmbr();
 						fragShaderBegins.globalLine = sourceLines.size() + 1;
-						sourceLines.push_back( string("#line ") + Util::intToStr(scanner.getLineNmbr()) + ' ' + Util::intToStr(id) + " // " + lines[scanner.getLineNmbr()-1] );
+						sourceLines.push_back( string("#line ") + Util::intToStr(scanner.getLineNmbr()) + ' ' + Util::intToStr(depth) + " // " + lines[scanner.getLineNmbr()-1] );
 						// stop play
 					}
 /* include */
@@ -129,9 +154,9 @@ bool ShaderParser::parseFileForPragmas( const string& filename, int id )
 						{
 							// play
 							//int line = sourceLines.size();
-							sourceLines.push_back( string("#line 0 ") + Util::intToStr(id+1) + " // " + lines[scanner.getLineNmbr()-1] );
-							if( !parseFileForPragmas( token->value.string, id+1 ) ) return false;
-							sourceLines.push_back( string("#line ") + Util::intToStr(scanner.getLineNmbr()) + ' ' + Util::intToStr(id) +  " // end of " + lines[scanner.getLineNmbr()-1] );
+							sourceLines.push_back( string("#line 0 ") + Util::intToStr(depth+1) + " // " + lines[scanner.getLineNmbr()-1] );
+							if( !parseFileForPragmas( token->value.string, depth+1 ) ) return false;
+							sourceLines.push_back( string("#line ") + Util::intToStr(scanner.getLineNmbr()) + ' ' + Util::intToStr(depth) +  " // end of " + lines[scanner.getLineNmbr()-1] );
 							// stop play
 						}
 						else
@@ -146,21 +171,40 @@ bool ShaderParser::parseFileForPragmas( const string& filename, int id )
 						token = &scanner.getNextToken();
 						if( token->code == Scanner::TC_IDENTIFIER )
 						{
-							string var_name = token->value.string;
+							string varName = token->value.string;
 							token = &scanner.getNextToken();
 							if( token->code == Scanner::TC_NUMBER && token->type == Scanner::DT_INT )
 							{
-								// play
-								Vec<ShaderVarPragma>::iterator attrib = findShaderVar( output.attributes, var_name );
+								int loc = token->value.int_;
+
+								// check if already defined and for circular includance
+								Vec<ShaderVarPragma>::iterator attrib = findShaderVar( output.attributes, varName );
 								if( attrib != output.attributes.end() )
 								{
-									PARSE_ERR( "Attribute already defined at " << attrib->definedInFile << ":" << attrib->definedInLine );
+									if( attrib->definedInLine==scanner.getLineNmbr() && attrib->definedInFile==filename )
+									{
+										PARSE_ERR( "\"" << varName << "\" already defined in the same place. Check for circular or multiple includance" );
+									}
+									else
+									{
+										PARSE_ERR( "Attribute \"" << varName << "\" already defined at " << attrib->definedInFile << ":" << attrib->definedInLine );
+									}
 									return false;
 								}
+								// search if another var has the same loc
+								for( attrib = output.attributes.begin(); attrib!=output.attributes.end(); ++attrib )
+								{
+									if( attrib->customLoc == loc )
+									{
+										PARSE_ERR( "The attributes \"" << attrib->name << "\" (" << attrib->definedInFile << ":" << attrib->definedInLine <<
+										           ") and \"" << varName << "\" share the same location" );
+										return false;
+									}
+								}
 								
-								output.attributes.push_back( ShaderVarPragma( filename, scanner.getLineNmbr(), var_name, token->value.int_ ) );
+								// all ok, push it back
+								output.attributes.push_back( ShaderVarPragma( filename, scanner.getLineNmbr(), varName, loc ) );
 								sourceLines.push_back( lines[scanner.getLineNmbr()-1] );
-								// stop play
 							}
 							else
 							{

+ 6 - 3
src/resources/ShaderParser.h

@@ -7,7 +7,10 @@
 
 /**
  * The class fills some of the GLSL spec deficiencies. It adds the include preprocessor directive and the support to have all the
- * shaders in the same file. The file that includes all the shaders is called ShaderParser-compatible
+ * shaders in the same file. The file that includes all the shaders is called ShaderParser-compatible. The preprocessor pragmas are
+ * four: include, vertShaderBegins, fragShaderBegins and attribute. The *ShaderBegins indicate where the shader code begins and must be
+ * in certain order, first the vert shader and then the frag. The include is self-explanatory. The attribute is used to bind custom
+ * locations to attributes.
  */
 class ShaderParser
 {
@@ -54,10 +57,10 @@ class ShaderParser
 		/**
 		 * A recursive function that parses a file for pragmas and updates the output
 		 * @param filename The file to parse
-		 * @param id The #line in GLSL does not support filename so an id it being used instead
+		 * @param depth The #line in GLSL does not support filename so an depth it being used. It also tracks the include depth
 		 * @return True on success
 		 */
-		bool parseFileForPragmas( const string& filename, int id = 0 );
+		bool parseFileForPragmas( const string& filename, int depth = 0 );
 
 		/**
 		 * Searches inside the Output::uniforms or Output::attributes vectors

+ 3 - 3
src/resources/ShaderProg.cpp

@@ -178,15 +178,15 @@ bool ShaderProg::bindCustomAttribLocs( const ShaderParser& pars ) const
 //=====================================================================================================================================
 bool ShaderProg::load( const char* filename )
 {
-	if( !customload( filename, "" ) ) return false;
+	if( !customLoad( filename, "" ) ) return false;
 	return true;
 }
 
 
 //=====================================================================================================================================
-// customload                                                                                                                         =
+// customLoad                                                                                                                         =
 //=====================================================================================================================================
-bool ShaderProg::customload( const char* filename, const char* extraSource )
+bool ShaderProg::customLoad( const char* filename, const char* extraSource )
 {
 	if( getRsrcName().length() == 0 )
 	{

+ 4 - 1
src/resources/ShaderProg.h

@@ -19,6 +19,9 @@ class ShaderProg: public Resource
 	PROPERTY_R( uint, glId, getGlId )
 	
 	private:
+		/**
+		 * Attribute of uniform variable
+		 */
 		class Var
 		{
 			PROPERTY_R( int, loc, getLoc );
@@ -59,7 +62,7 @@ class ShaderProg: public Resource
 		static uint getCurrentProgramGlId() { int i; glGetIntegerv( GL_CURRENT_PROGRAM, &i ); return i; }
 
 		bool load( const char* filename );
-		bool customload( const char* filename, const char* extraSource ); ///< Used by the renderer's shader programs
+		bool customLoad( const char* filename, const char* extraSource = "" ); ///< Used by the renderer's shader programs
 		void unload() { /* ToDo: add code */ }
 
 		const Vec<Var>& getUniVars() const { return uniVars; } ///< Accessor to uniform vars vector

+ 7 - 7
src/tokenizer/parser.h

@@ -9,8 +9,8 @@
 parser macros                                                                                                                         =
 =======================================================================================================================================
 */
-#define PARSE_ERR(x) ERROR( "PARSE_ERR (" << scanner.getScriptName() << ':' << scanner.getLineNmbr() << "): " << x )
-#define PARSE_WARN(x) WARNING( "PARSE_WARN (" << scanner.getScriptName() << ':' << scanner.getLineNmbr() << "): " << x )
+#define PARSE_ERR(x) ERROR( "Parse Error (" << scanner.getScriptName() << ':' << scanner.getLineNmbr() << "): " << x )
+#define PARSE_WARN(x) WARNING( "Parse Warning (" << scanner.getScriptName() << ':' << scanner.getLineNmbr() << "): " << x )
 
 // common parser errors
 #define PARSE_ERR_EXPECTED(x) PARSE_ERR( "Expected " << x << " and not " << Scanner::getTokenInfo(scanner.getCrntToken()) );
@@ -23,11 +23,11 @@ ParseArrOfNumbers
 =======================================================================================================================================
 */
 /**
-It parses expressions like this one: { 10 -0.2 123.e-10 -0x0FF } and stores the result in the arr array
-@param scanner The scanner that we will use
-@param size The number of numbers inside the brackets
-@param arr The array that the func returns the numbers
-@return True if the parsing was success or false otherwise
+ * It parses expressions like this one: { 10 -0.2 123.e-10 -0x0FF } and stores the result in the arr array
+ * @param scanner The scanner that we will use
+ * @param size The number of numbers inside the brackets
+ * @param arr The array that the func returns the numbers
+ * @return True if the parsing was successful
 */
 template <typename Type> bool ParseArrOfNumbers( Scanner& scanner, bool paren, bool signs, uint size, Type* arr )
 {

Some files were not shown because too many files changed in this diff