Просмотр исходного кода

- Finalizing the renderer transision to GL 3.2 core
- Various additions to the Scanner (multiline C++ comments, multiline strings)

Panagiotis Christopoulos Charitos 15 лет назад
Родитель
Сommit
34ac09dc11

+ 5 - 0
src/Main.cpp

@@ -298,6 +298,11 @@ int main( int argc, char* argv[] )
 {
 	new App( argc, argv );
 
+	Scanner scanner;
+	scanner.loadFile( "/users/panoscc/Desktop/Unsaved Document 2" );
+	scanner.getAllPrintAll();
+	return 0;
+
 	init();
 
 	INFO( "Entering main loop" );

+ 2 - 2
src/Misc/skybox.cpp

@@ -39,8 +39,8 @@ bool Skybox::load( const char* filenames[6] )
 	}
 
 	noise = Rsrc::textures.load( "gfx/noise2.tga" );
-	noise->texParameter( GL_TEXTURE_WRAP_S, GL_REPEAT );
-	noise->texParameter( GL_TEXTURE_WRAP_T, GL_REPEAT );
+	noise->setTexParameter( GL_TEXTURE_WRAP_S, GL_REPEAT );
+	noise->setTexParameter( GL_TEXTURE_WRAP_T, GL_REPEAT );
 
 	shader = Rsrc::shaders.load( "shaders/ms_mp_skybox.glsl" );
 

+ 36 - 25
src/Renderer/Dbg.cpp

@@ -15,6 +15,7 @@
 // Statics                                                                                                             =
 //======================================================================================================================
 ShaderProg* Renderer::Dbg::sProg = NULL;
+Mat4 Renderer::Dbg::viewProjectionMat;
 
 
 //======================================================================================================================
@@ -76,11 +77,8 @@ void Renderer::Dbg::renderGrid()
 //======================================================================================================================
 // renderSphere                                                                                                        =
 //======================================================================================================================
-void Renderer::Dbg::renderSphere( const Transform& trf, const Vec4& color, int complexity )
+void Renderer::Dbg::renderSphere( int complexity, float radius )
 {
-	sProg->findUniVar( "color" )->setVec4( &color );
-
-	const float radius = 1.0;
 	const float twopi  = M::PI*2;
 	const float pidiv2 = M::PI/2;
 
@@ -124,8 +122,8 @@ void Renderer::Dbg::renderSphere( const Transform& trf, const Vec4& color, int c
 			py = radius * ey;
 			pz = radius * ez;
 
-			positions.push_back( Vec3(px, py, pz).getTransformed( trf ) );
-			normals.push_back( trf.getRotation() * Vec3(ex, ey, ez) );
+			positions.push_back( Vec3(px, py, pz) );
+			normals.push_back( Vec3(ex, ey, ez) );
 			texCoodrs.push_back( Vec2(-(j/(float)complexity), 2*(i+1)/(float)complexity) );
 
 			ex = costheta1 * costheta3;
@@ -135,8 +133,8 @@ void Renderer::Dbg::renderSphere( const Transform& trf, const Vec4& color, int c
 			py = radius * ey;
 			pz = radius * ez;
 
-			positions.push_back( Vec3(px, py, pz).getTransformed( trf ) );
-			normals.push_back( trf.getRotation() * Vec3(ex, ey, ez) );
+			positions.push_back( Vec3(px, py, pz) );
+			normals.push_back( Vec3(ex, ey, ez) );
 			texCoodrs.push_back( Vec2(-(j/(float)complexity), 2*i/(float)complexity) );
 		}
 	}
@@ -151,12 +149,10 @@ void Renderer::Dbg::renderSphere( const Transform& trf, const Vec4& color, int c
 //======================================================================================================================
 // renderCube                                                                                                          =
 //======================================================================================================================
-void Renderer::Dbg::renderCube( const Transform& trf, const Vec4& color )
+void Renderer::Dbg::renderCube( float size )
 {
-	sProg->findUniVar( "color" )->setVec4( &color );
-
-	Vec3 maxPos = Vec3( 0.5 ).getTransformed( trf );
-	Vec3 minPos = Vec3( -0.5 ).getTransformed( trf );
+	Vec3 maxPos = Vec3( 0.5 * size );
+	Vec3 minPos = Vec3( -0.5 * size );
 
 	Vec3 points [] = {
 		Vec3( maxPos.x, maxPos.y, maxPos.z ),  // right top front
@@ -222,11 +218,11 @@ void Renderer::Dbg::run()
 
 	fbo.bind();
 	sProg->bind();
+	viewProjectionMat = cam.getViewMatrix() * cam.getProjectionMatrix();
 
 	// OGL stuff
 	r.setProjectionViewMatrices( cam );
 	Renderer::setViewport( 0, 0, r.width, r.height );
-
 	glEnable( GL_DEPTH_TEST );
 	glDisable( GL_BLEND );
 
@@ -236,24 +232,39 @@ void Renderer::Dbg::run()
 		SceneNode* node = app->getScene()->nodes[i];
 		if
 		(
-			/*(app->getScene()->nodes[i]->type == SceneNode::NT_LIGHT && showLightsEnabled) ||*/
-			(node->type == SceneNode::NT_CAMERA && showCamerasEnabled) /*||
-			app->getScene()->nodes[i]->type == SceneNode::NT_PARTICLE_EMITTER*/
+			(node->type == SceneNode::NT_LIGHT && showLightsEnabled) ||
+			(node->type == SceneNode::NT_CAMERA && showCamerasEnabled) ||
+			node->type == SceneNode::NT_PARTICLE_EMITTER
 		)
 		{
-			Mat4 modelMat = Mat4( node->getWorldTransform() );
-			Mat4 modelViewMat = Mat4::combineTransformations( cam.getViewMatrix(), modelMat );
-			Mat4 modelViewProjectionMat = cam.getProjectionMatrix() * modelViewMat;
-			sProg->findUniVar( "modelViewProjectionMat" )->setMat4( &modelViewProjectionMat );
 			node->render();
 		}
-		/*else if( app->getScene()->nodes[i]->type == SceneNode::NT_SKELETON && showSkeletonsEnabled )
+		else if( app->getScene()->nodes[i]->type == SceneNode::NT_SKELETON && showSkeletonsEnabled )
 		{
-			SkelNode* skel_node = static_cast<SkelNode*>( app->getScene()->nodes[i] );
+			SkelNode* skelNode = static_cast<SkelNode*>( node );
 			glDisable( GL_DEPTH_TEST );
-			skel_node->render();
+			skelNode->render();
 			glEnable( GL_DEPTH_TEST );
-		}*/
+		}
 	}
 }
 
+
+//======================================================================================================================
+// setColor                                                                                                            =
+//======================================================================================================================
+void Renderer::Dbg::setColor( const Vec4& color )
+{
+	sProg->findUniVar( "color" )->setVec4( &color );
+}
+
+
+//======================================================================================================================
+// setModelMat                                                                                                         =
+//======================================================================================================================
+void Renderer::Dbg::setModelMat( const Mat4& modelMat )
+{
+	Mat4 pmv = viewProjectionMat * modelMat;
+	sProg->findUniVar( "modelViewProjectionMat" )->setMat4( &pmv );
+}
+

+ 4 - 4
src/Renderer/Hdr.cpp

@@ -24,9 +24,9 @@ void Renderer::Pps::Hdr::initFbos( Fbo& fbo, Texture& fai, int internalFormat )
 
 	// create the texes
 	fai.createEmpty2D( width, height, internalFormat, GL_RGB, GL_FLOAT, false );
-	fai.texParameter( GL_TEXTURE_MAG_FILTER, GL_NEAREST );
-	//fai_.texParameter( GL_TEXTURE_MAG_FILTER, GL_LINEAR );
-	fai.texParameter( GL_TEXTURE_MIN_FILTER, GL_NEAREST );
+	fai.setTexParameter( GL_TEXTURE_MAG_FILTER, GL_NEAREST );
+	//fai_.setTexParameter( GL_TEXTURE_MAG_FILTER, GL_LINEAR );
+	fai.setTexParameter( GL_TEXTURE_MIN_FILTER, GL_NEAREST );
 
 	// attach
 	glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, fai.getGlId(), 0 );
@@ -52,7 +52,7 @@ void Renderer::Pps::Hdr::init()
 	initFbos( pass1Fbo, pass1Fai, GL_RGB );
 	initFbos( pass2Fbo, fai, GL_RGB );
 
-	fai.texParameter( GL_TEXTURE_MAG_FILTER, GL_LINEAR );
+	fai.setTexParameter( GL_TEXTURE_MAG_FILTER, GL_LINEAR );
 
 	// init shaders
 	const char* shaderFname = "shaders/PpsHdr.glsl";

+ 17 - 13
src/Renderer/Is.cpp

@@ -242,6 +242,22 @@ void Renderer::Is::spotLightPass( const SpotLight& light )
 	// stencil optimization
 	smo.run( light );
 
+	// set the texture
+	if( light.lightProps->getTexture() == NULL )
+	{
+		ERROR( "No texture is attached to the light. lightProps name: " << light.lightProps->getRsrcName() );
+		return;
+	}
+
+	light.lightProps->getTexture()->setRepeat( false );
+
+	/*
+	 * Before we render disable anisotropic in the light.texture because it produces artifacts.
+	 * todo see if this is necessary with future drivers
+	 */
+	light.lightProps->getTexture()->setTexParameter( GL_TEXTURE_MIN_FILTER, GL_LINEAR );
+	light.lightProps->getTexture()->setTexParameter( GL_TEXTURE_MAG_FILTER, GL_LINEAR );
+
 	// shader prog
 	const LightShaderProg* shdr; // because of the huge name
 
@@ -267,19 +283,7 @@ void Renderer::Is::spotLightPass( const SpotLight& light )
 	shdr->uniVars.lightInvRadius->setFloat( 1.0/light.getDistance() );
 	shdr->uniVars.lightDiffuseCol->setVec3( &light.lightProps->getDiffuseColor() );
 	shdr->uniVars.lightSpecularCol->setVec3( &light.lightProps->getSpecularColor() );
-
-	// set the light texture
-	if( light.lightProps->getTexture() == NULL )
-		ERROR( "No texture is attached to the light. lightProps name: " << light.lightProps->getRsrcName() );
-	else
-		shdr->uniVars.lightTex->setTexture( *light.lightProps->getTexture(), 4 );
-
-	/*
-	 * Before we render disable anisotropic in the light.texture because it produces artifacts.
-	 * todo see if this is necessary with future drivers
-	 */
-	glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
-	glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
+	shdr->uniVars.lightTex->setTexture( *light.lightProps->getTexture(), 4 );
 
 	// set texture matrix for texture & shadowmap projection
 	// Bias * P_light * V_light * inv( V_cam )

+ 6 - 2
src/Renderer/Renderer.h

@@ -358,12 +358,16 @@ class Renderer
 			public:
 				Dbg( Renderer& r_ );
 				void renderGrid();
-				void renderSphere( const Transform& trf, const Vec4& color, int complexity  );
-				void renderCube( const Transform& trf, const Vec4& color );
+				static void renderSphere( int complexity, float radius = 1.0 );
+				static void renderCube( float size = 1.0 );
+
+				static void setColor( const Vec4& color );
+				static void setModelMat( const Mat4& modelMat );
 
 			private:
 				Fbo fbo;
 				static ShaderProg* sProg;
+				static Mat4 viewProjectionMat;
 
 				void init();
 				void run();

+ 5 - 5
src/Renderer/Sm.cpp

@@ -21,17 +21,17 @@ void Renderer::Is::Sm::init()
 
 	// texture
 	shadowMap.createEmpty2D( resolution, resolution, GL_DEPTH_COMPONENT, GL_DEPTH_COMPONENT, GL_FLOAT, true );
-	shadowMap.texParameter( GL_TEXTURE_MIN_FILTER, GL_NEAREST );
+	shadowMap.setTexParameter( GL_TEXTURE_MIN_FILTER, GL_NEAREST );
 	if( bilinearEnabled )
 	{
-		shadowMap.texParameter( GL_TEXTURE_MAG_FILTER, GL_LINEAR );
+		shadowMap.setTexParameter( GL_TEXTURE_MAG_FILTER, GL_LINEAR );
 	}
 	else
 	{
-		shadowMap.texParameter( GL_TEXTURE_MAG_FILTER, GL_NEAREST );
+		shadowMap.setTexParameter( GL_TEXTURE_MAG_FILTER, GL_NEAREST );
 	}
-	shadowMap.texParameter( GL_TEXTURE_COMPARE_MODE, GL_COMPARE_R_TO_TEXTURE );
-	shadowMap.texParameter( GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL );
+	shadowMap.setTexParameter( GL_TEXTURE_COMPARE_MODE, GL_COMPARE_R_TO_TEXTURE );
+	shadowMap.setTexParameter( GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL );
 	/*
 	 * If you dont want to use the FFP for comparing the shadowmap (the above two lines) then you can make the comparison
 	 * inside the glsl shader. The GL_LEQUAL means that: shadow = ( R <= Dt ) ? 1.0 : 0.0; . The R is given by:

+ 8 - 8
src/Renderer/Ssao.cpp

@@ -22,8 +22,8 @@ void Renderer::Pps::Ssao::initBlurFbo( Fbo& fbo, Texture& fai )
 
 	// create the texes
 	fai.createEmpty2D( bwidth, bheight, GL_ALPHA8, GL_ALPHA, GL_FLOAT, false );
-	fai.texParameter( GL_TEXTURE_MAG_FILTER, GL_NEAREST );
-	fai.texParameter( GL_TEXTURE_MIN_FILTER, GL_NEAREST );
+	fai.setTexParameter( GL_TEXTURE_MAG_FILTER, GL_NEAREST );
+	fai.setTexParameter( GL_TEXTURE_MIN_FILTER, GL_NEAREST );
 
 	// attach
 	glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, fai.getGlId(), 0 );
@@ -61,8 +61,8 @@ void Renderer::Pps::Ssao::init()
 
 	// create the FAI
 	pass0Fai.createEmpty2D( width, height, GL_ALPHA8, GL_ALPHA, GL_FLOAT, false );
-	pass0Fai.texParameter( GL_TEXTURE_MAG_FILTER, GL_NEAREST );
-	pass0Fai.texParameter( GL_TEXTURE_MIN_FILTER, GL_NEAREST );
+	pass0Fai.setTexParameter( GL_TEXTURE_MAG_FILTER, GL_NEAREST );
+	pass0Fai.setTexParameter( GL_TEXTURE_MIN_FILTER, GL_NEAREST );
 
 	// attach
 	glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, pass0Fai.getGlId(), 0 );
@@ -107,10 +107,10 @@ void Renderer::Pps::Ssao::init()
 	Texture::compressionEnabled = false;
 	Texture::mipmappingEnabled = true;
 	noiseMap = Rsrc::textures.load( "gfx/noise3.tga" );
-	noiseMap->texParameter( GL_TEXTURE_WRAP_S, GL_REPEAT );
-	noiseMap->texParameter( GL_TEXTURE_WRAP_T, GL_REPEAT );
-	//noise_map->texParameter( GL_TEXTURE_MAG_FILTER, GL_NEAREST );
-	//noise_map->texParameter( GL_TEXTURE_MIN_FILTER, GL_NEAREST );
+	noiseMap->setTexParameter( GL_TEXTURE_WRAP_S, GL_REPEAT );
+	noiseMap->setTexParameter( GL_TEXTURE_WRAP_T, GL_REPEAT );
+	//noise_map->setTexParameter( GL_TEXTURE_MAG_FILTER, GL_NEAREST );
+	//noise_map->setTexParameter( GL_TEXTURE_MIN_FILTER, GL_NEAREST );
 	Texture::compressionEnabled = texCompr;
 	Texture::mipmappingEnabled = mipmaping;
 

+ 1 - 1
src/Resources/LightProps.cpp

@@ -98,7 +98,7 @@ Scanner scanner;
 			}
 				
 			texture = Rsrc::textures.load( token->getValue().getString() );
-			texture->texParameter( GL_TEXTURE_MAX_ANISOTROPY_EXT, 0 );
+			texture->setTexParameter( GL_TEXTURE_MAX_ANISOTROPY_EXT, 0 );
 		}
 		// end of file
 		else if( token->getCode() == Scanner::TC_EOF )

+ 56 - 10
src/Resources/Texture.cpp

@@ -1,3 +1,4 @@
+#include <GL/glew.h>
 #include "Texture.h"
 #include "Renderer.h"
 #include "Image.h"
@@ -21,6 +22,7 @@ Texture::Texture():
 {
 }
 
+
 //======================================================================================================================
 // load                                                                                                                =
 //======================================================================================================================
@@ -42,20 +44,19 @@ bool Texture::load( const char* filename )
 	bind(0);
 	if( mipmappingEnabled )
 	{
-		texParameter( GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR );
+		setTexParameter( GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR );
 	}
 	else
 	{
-		texParameter( GL_TEXTURE_MIN_FILTER, GL_LINEAR );
+		setTexParameter( GL_TEXTURE_MIN_FILTER, GL_LINEAR );
 	}
 
-	texParameter( GL_TEXTURE_MAG_FILTER, GL_LINEAR );
+	setTexParameter( GL_TEXTURE_MAG_FILTER, GL_LINEAR );
 
 	texParameter( GL_TEXTURE_MAX_ANISOTROPY_EXT, float(anisotropyLevel) );
 
 	// leave to GL_REPEAT. There is not real performance impact
-	texParameter( GL_TEXTURE_WRAP_S, GL_REPEAT );
-	texParameter( GL_TEXTURE_WRAP_T, GL_REPEAT );
+	setRepeat( true );
 
 	int format = (img.bpp==32) ? GL_RGBA : GL_RGB;
 
@@ -98,13 +99,13 @@ bool Texture::createEmpty2D( float width_, float height_, int internalFormat, in
 	bind();
 
 	if( mimapping )
-		texParameter( GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR );
+		setTexParameter( GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR );
 	else
-		texParameter( GL_TEXTURE_MIN_FILTER, GL_LINEAR );
+		setTexParameter( GL_TEXTURE_MIN_FILTER, GL_LINEAR );
+
+	setTexParameter( GL_TEXTURE_MAG_FILTER, GL_LINEAR );
+	setRepeat( true );
 
-	texParameter( GL_TEXTURE_MAG_FILTER, GL_LINEAR );
-	texParameter( GL_TEXTURE_WRAP_S, GL_REPEAT );
-	texParameter( GL_TEXTURE_WRAP_T, GL_REPEAT );
 
 	// allocate to vram
 	glTexImage2D( target, 0, internalFormat, width_, height_, 0, format_, type_, NULL );
@@ -160,3 +161,48 @@ void Texture::bind( uint unit ) const
 	glActiveTexture( GL_TEXTURE0+unit );
 	glBindTexture( target, glId );
 }
+
+
+//======================================================================================================================
+// getWidth                                                                                                            =
+//======================================================================================================================
+int Texture::getWidth() const
+{
+	bind();
+	int i;
+	glGetTexLevelParameteriv( target, 0, GL_TEXTURE_WIDTH, &i );
+	return i;
+}
+
+
+//======================================================================================================================
+// getHeight                                                                                                           =
+//======================================================================================================================
+int Texture::getHeight() const
+{
+	bind();
+	int i;
+	glGetTexLevelParameteriv( target, 0, GL_TEXTURE_HEIGHT, &i );
+	return i;
+}
+
+
+//======================================================================================================================
+// setTexParameter [int]                                                                                                  =
+//======================================================================================================================
+void Texture::setTexParameter( GLenum paramName, GLint value ) const
+{
+	bind();
+	glTexParameteri( target, paramName, value );
+}
+
+
+//======================================================================================================================
+// setTexParameter [float]                                                                                                =
+//======================================================================================================================
+void Texture::texParameter( GLenum paramName, GLfloat value ) const
+{
+	bind();
+	glTexParameterf( target, paramName, value );
+}
+

+ 37 - 17
src/Resources/Texture.h

@@ -10,41 +10,61 @@
 /**
  * Texture resource class
  *
- * It loads or creates an image and then loads it in the GPU. Its an OpenGL container. It supports compressed and uncompressed TGAs
- * and all formats of PNG (PNG loading comes through SDL_image)
+ * It loads or creates an image and then loads it in the GPU. Its an OpenGL container. It supports compressed and
+ * uncompressed TGAs and all formats of PNG (PNG loading comes through SDL_image)
  */
 class Texture: public Resource
 {
 	friend class Renderer; /// @todo Remove this when remove the SSAO load noise map crap
 	friend class MainRenderer;
 
-	protected:
-		uint   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 bool mipmappingEnabled;
-		static bool compressionEnabled;
-		static int  anisotropyLevel;
-
 	public:
 		 Texture();
 		~Texture() {}
 
-		uint getGlId() const { DEBUG_ERR(glId==numeric_limits<uint>::max()); return glId; }
-		int  getWidth() const { bind(); int i; glGetTexLevelParameteriv( target, 0, GL_TEXTURE_WIDTH, &i ); return i; }
-		int  getHeight() const { bind(); int i; glGetTexLevelParameteriv( target, 0, GL_TEXTURE_HEIGHT, &i ); return i; }
+		GLuint getGlId() const;
+		int getWidth() const;
+		int getHeight() const;
 
 		bool load( const char* filename );
 		void unload();
 		bool createEmpty2D( float width, float height, int internalFormat, int format, GLenum type_, bool mipmapping );
 		bool createEmpty2DMSAA( float width, float height, int samplesNum, int internalFormat );
 
-		void bind( uint unit=0 ) const;
+		void bind( uint texUnit=0 ) const;
+		void setRepeat( bool repeat ) const;
+		void setTexParameter( GLenum paramName, GLint value ) const;
+		void texParameter( GLenum paramName, GLfloat value ) const;
+
+	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 bool mipmappingEnabled;
+		static bool compressionEnabled;
+		static int  anisotropyLevel;
+}; // end class Texture
+
+
+inline GLuint Texture::getGlId() const
+{
+	DEBUG_ERR(glId==numeric_limits<uint>::max()); return glId;
+}
 
-		inline void texParameter( GLenum paramName, GLint value ) const { bind(); glTexParameteri( target, paramName, value ); }
-		inline void texParameter( GLenum paramName, GLfloat value ) const { bind(); glTexParameterf( target, paramName, value ); }
-};
 
+inline void Texture::setRepeat( bool repeat ) 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 );
+	}
+}
 
 
 #endif

+ 3 - 3
src/Scene/Camera.cpp

@@ -22,6 +22,9 @@ void Camera::setAll( float fovx_, float fovy_, float znear_, float zfar_ )
 //======================================================================================================================
 void Camera::render()
 {
+	Renderer::Dbg::setColor( Vec4(1.0, 0.0, 1.0, 1.0) );
+	Renderer::Dbg::setModelMat( Mat4( getWorldTransform() ) );
+
 	const float camLen = 1.0;
 	float tmp0 = camLen / tan( (M::PI - fovX)*0.5 ) + 0.001;
 	float tmp1 = camLen * tan(fovY*0.5) + 0.001;
@@ -34,9 +37,6 @@ void Camera::render()
 		{tmp0, tmp1, -camLen}, // 4: top right
 	};
 
-	const float colors [][3] = { { 1.0, 0.0, 1.0 }, { 1.0, 0.0, 1.0 }, { 1.0, 0.0, 1.0 }, { 1.0, 0.0, 1.0 },
-	                             { 1.0, 0.0, 1.0 } };
-
 	const ushort indeces [] = { 0, 1, 0, 2, 0, 3, 0, 4, 1, 2, 2, 3, 3, 4, 4, 1 };
 
 

+ 10 - 11
src/Scene/Light.cpp

@@ -6,7 +6,7 @@
 
 
 //======================================================================================================================
-// init [PointLight]                                                                                                =
+// init [PointLight]                                                                                                  =
 //======================================================================================================================
 void PointLight::init( const char* filename )
 {
@@ -16,7 +16,7 @@ void PointLight::init( const char* filename )
 
 
 //======================================================================================================================
-// init [SpotLight]                                                                                                 =
+// init [SpotLight]                                                                                                    =
 //======================================================================================================================
 void SpotLight::init( const char* filename )
 {
@@ -43,16 +43,15 @@ void Light::deinit()
 //======================================================================================================================
 // render                                                                                                              =
 //======================================================================================================================
-void PointLight::render()
+void Light::render()
 {
-	app->getMainRenderer()->dbg.renderSphere( getWorldTransform(), Vec4( lightProps->getDiffuseColor(), 1.0 ), 8 );
-}
+	Renderer::Dbg::setColor( Vec4( lightProps->getDiffuseColor(), 1.0 ) );
 
+	Transform trf = getWorldTransform();
+	trf.setScale( 0.1 );
+	Mat4 mvp = Mat4( trf );
+	Renderer::Dbg::setModelMat( Mat4( getWorldTransform() ) );
 
-//======================================================================================================================
-// render                                                                                                              =
-//======================================================================================================================
-void SpotLight::render()
-{
-	app->getMainRenderer()->dbg.renderSphere( getWorldTransform(), Vec4( lightProps->getDiffuseColor(), 1.0 ), 8 );
+	Renderer::Dbg::renderSphere( 8 );
 }
+

+ 3 - 4
src/Scene/Light.h

@@ -37,6 +37,7 @@ class Light: public SceneNode
 		Light( Type type_ ): SceneNode(NT_LIGHT), type(type_) {}
 		//void init( const char* );
 		void deinit();
+		void render();
 };
 
 
@@ -48,7 +49,6 @@ class PointLight: public Light
 
 		PointLight(): Light(LT_POINT) {}
 		void init( const char* );
-		void render();
 };
 
 
@@ -61,9 +61,8 @@ class SpotLight: public Light
 
 		SpotLight(): Light(LT_SPOT), castsShadow(false) { addChild( &camera ); }
 		float getDistance() const { return camera.getZFar(); }
-		void  setDistance( float d ) { camera.setZFar(d); }
-		void  init( const char* );
-		void  render();
+		void setDistance( float d ) { camera.setZFar(d); }
+		void init( const char* );
 };
 
 

+ 3 - 1
src/Scene/ParticleEmitter.cpp

@@ -169,7 +169,9 @@ void ParticleEmitter::update()
 void ParticleEmitter::render()
 {
 	glPolygonMode( GL_FRONT, GL_LINE );
-	app->getMainRenderer()->dbg.renderCube( getWorldTransform(), Vec4(1.0) );
+	Renderer::Dbg::setColor( Vec4(1.0) );
+	Renderer::Dbg::setModelMat( Mat4( getWorldTransform() ) );
+	Renderer::Dbg::renderCube();
 	glPolygonMode( GL_FRONT, GL_FILL );
 
 }

+ 9 - 15
src/Scene/SkelNode.cpp

@@ -40,25 +40,19 @@ void SkelNode::deinit()
 //======================================================================================================================
 void SkelNode::render()
 {
-	glPushMatrix();
-	app->getMainRenderer()->multMatrix( Mat4(getWorldTransform()) );
+	Renderer::Dbg::setModelMat( Mat4(getWorldTransform()) );
+	Renderer::Dbg::setColor( Vec4(1.0, 0.0, 0.0, 1.0) );
 
-	//glPointSize( 4.0f );
-	//glLineWidth( 2.0f );
+	Vec<Vec3> positions;
 
 	for( uint i=0; i<skeleton->bones.size(); i++ )
 	{
-		glColor3fv( &Vec3( 1.0, 1.0, 1.0 )[0] );
-		glBegin( GL_POINTS );
-			glVertex3fv( &skelAnimCtrl->heads[i][0] );
-		glEnd();
-
-		glBegin( GL_LINES );
-			glVertex3fv( &skelAnimCtrl->heads[i][0] );
-			glColor3fv( &Vec3( 1.0, 0.0, 0.0 )[0] );
-			glVertex3fv( &skelAnimCtrl->tails[i][0] );
-		glEnd();
+		positions.push_back( skelAnimCtrl->heads[i] );
+		positions.push_back( skelAnimCtrl->tails[i] );
 	}
 
-	glPopMatrix();
+	glEnableVertexAttribArray( 0 );
+	glVertexAttribPointer( 0, 3, GL_FLOAT, false, 0, &(positions[0][0]) );
+	glDrawArrays( GL_TRIANGLES, 0, positions.size() );
+	glDisableVertexAttribArray( 0 );
 }

+ 2 - 2
src/Ui/Ui.cpp

@@ -161,8 +161,8 @@ non static funcs
 void init()
 {
 	fontMap = Rsrc::textures.load( "gfx/fontmapa.tga" );
-	fontMap->texParameter( GL_TEXTURE_MIN_FILTER, GL_LINEAR );
-	//font_map->texParameter( GL_TEXTURE_MAG_FILTER, GL_NEAREST );
+	fontMap->setTexParameter( GL_TEXTURE_MIN_FILTER, GL_LINEAR );
+	//font_map->setTexParameter( GL_TEXTURE_MAG_FILTER, GL_NEAREST );
 	shader = Rsrc::shaders.load( "shaders/txt.glsl" );
 	setPos( 0.0, 0.0 );
 	setFontWidth( 0.05 );

+ 37 - 23
src/Util/Tokenizer/Scanner.cpp

@@ -293,7 +293,7 @@ const Scanner::Token& Scanner::getNextToken()
 	{
 		crntToken.code = TC_NEWLINE;
 		--commentedLines;
-		++lineNmbr; // the ultimate hack. I should remember not to do such crapp
+		++lineNmbr; // the ultimate hack. I should remember not to do such crap in the future
 	}
 	else if( *pchar == '/' )
 	{
@@ -406,30 +406,43 @@ bool Scanner::checkWord()
 //======================================================================================================================
 bool Scanner::checkComment()
 {
-	// begining
+	// Beginning
 	if( getNextChar()=='*' )
-		goto branchy_cmnt;
+	{
+		goto cStyleCmnt;
+	}
+	// C++ style comment
 	else if( *pchar=='/' )
 	{
-		// end
-		getLine();
-		crntToken.code = TC_COMMENT;
-		return true;
+		while( true )
+		{
+			char ch = getNextChar();
+			if( ch == '\0' )
+			{
+				crntToken.code = TC_COMMENT;
+				return true;
+			}
+			else if( ch == '\\' )
+			{
+				if( getNextChar() == '\0' )
+					getNextChar();
+			}
+		}
 	}
 	else
 		goto error;
 
-	// multi-line comment
-	branchy_cmnt:
+	// C style comment
+	cStyleCmnt:
 		if( getNextChar()=='*' )
-			goto finalizeBranchy;
+			goto finalizeCCmnt;
 		else if( *pchar==eofChar )
 			goto error;
 		else
-			goto branchy_cmnt;
+			goto cStyleCmnt;
 
-	// multi-line "branchy"
-	finalizeBranchy:
+	// C++ style comment
+	finalizeCCmnt:
 		if( getNextChar()=='/' )
 		{
 			crntToken.code = TC_COMMENT;
@@ -437,7 +450,7 @@ bool Scanner::checkComment()
 			return true;
 		}
 		else
-			goto branchy_cmnt;
+			goto cStyleCmnt;
 
 	//error
 	error:
@@ -705,23 +718,23 @@ bool Scanner::checkString()
 
 	for(;;)
 	{
-		//Error
+		// Error
 		if( ch=='\0' || ch==eofChar ) // if end of line or eof
 		{
 			crntToken.code = TC_ERROR;
 			*tmpStr = '\0';
-			SERROR( "Incorect string ending \"" << crntToken.asString );
+			SERROR( "Incorrect string ending \"" << crntToken.asString << '\"' );
 			return false;
 		}
-		//Escape Codes
+		// Escape Codes
 		else if( ch=='\\' )
 		{
 			ch = getNextChar();
-			if( ch=='\0' || ch==eofChar )
+			if( ch==eofChar )
 			{
 				crntToken.code = TC_ERROR;
 				*tmpStr = '\0';
-				SERROR( "Incorect string ending \"" << crntToken.asString << '\"' );
+				SERROR( "Incorrect string ending \"" << crntToken.asString << '\"' );
 				return false;
 			}
 
@@ -737,12 +750,13 @@ bool Scanner::checkString()
 				case '\'': *tmpStr++ = '\''; break;
 				case '\\': *tmpStr++ = '\\'; break;
 				case '\?': *tmpStr++ = '\?'; break;
+				case '\0': break; // not an escape char but works almost the same
 				default  :
-					SERROR( "Unrecognized escape charachter \'\\" << ch << '\'' );
+					SERROR( "Unrecognized escape character \'\\" << ch << '\'' );
 					*tmpStr++ = ch;
 			}
 		}
-		//End
+		// End
 		else if( ch=='\"' )
 		{
 			*tmpStr = '\0';
@@ -751,7 +765,7 @@ bool Scanner::checkString()
 			getNextChar();
 			return true;
 		}
-		//Build str( main loop )
+		// Build str( main loop )
 		else
 		{
 			*tmpStr++ = ch;
@@ -811,7 +825,7 @@ bool Scanner::checkChar()
 			case '\'': ch0 = '\''; break;
 			case '\\': ch0 = '\\'; break;
 			case '\?': ch0 = '\?'; break;
-			default  : ch0 = ch  ; SERROR( "Unrecognized escape charachter \'\\" << ch << '\'' );
+			default  : ch0 = ch  ; SERROR( "Unrecognized escape character \'\\" << ch << '\'' );
 		}
 		crntToken.value.char_ = ch0;
 	}