Quellcode durchsuchen

Work on the new coding style

Panagiotis Christopoulos Charitos vor 16 Jahren
Ursprung
Commit
e210d426fd
80 geänderte Dateien mit 2177 neuen und 2022 gelöschten Zeilen
  1. 451 334
      build/debug/Makefile
  2. 1 1
      src/controllers/mesh_skel_ctrl.h
  3. 22 22
      src/controllers/skel_anim_ctrl.cpp
  4. 8 8
      src/controllers/skel_anim_ctrl.h
  5. 9 9
      src/main.cpp
  6. 1 1
      src/math/mat3.inl.h
  7. 13 13
      src/renderer/fbo.h
  8. 6 6
      src/renderer/r_bs.cpp
  9. 15 15
      src/renderer/r_bs2.cpp
  10. 6 6
      src/renderer/r_dbg.cpp
  11. 62 62
      src/renderer/r_is.cpp
  12. 17 17
      src/renderer/r_is_shadows.cpp
  13. 15 15
      src/renderer/r_ms.cpp
  14. 11 11
      src/renderer/r_ms_earlyz.cpp
  15. 22 22
      src/renderer/r_pps.cpp
  16. 23 23
      src/renderer/r_pps_hdr.cpp
  17. 16 16
      src/renderer/r_pps_lscatt.cpp
  18. 29 29
      src/renderer/r_pps_ssao.cpp
  19. 21 21
      src/renderer/r_private.h
  20. 19 19
      src/renderer/renderer.cpp
  21. 14 14
      src/renderer/renderer.h
  22. 14 14
      src/renderer/vbo.h
  23. 5 5
      src/renderer2/r_is.cpp
  24. 11 11
      src/renderer2/r_ms.cpp
  25. 12 12
      src/renderer2/renderer.hpp
  26. 33 0
      src/resources/Extension.cpp
  27. 24 0
      src/resources/Extension.h
  28. 14 14
      src/resources/LightProps.cpp
  29. 46 0
      src/resources/LightProps.h
  30. 82 82
      src/resources/Material.cpp
  31. 40 40
      src/resources/Material.h
  32. 92 92
      src/resources/Mesh.cpp
  33. 75 0
      src/resources/Mesh.h
  34. 25 0
      src/resources/Path.h
  35. 14 14
      src/resources/Resource.cpp
  36. 197 0
      src/resources/Resource.h
  37. 73 73
      src/resources/ShaderParser.cpp
  38. 66 25
      src/resources/ShaderParser.h
  39. 106 106
      src/resources/ShaderProg.cpp
  40. 55 0
      src/resources/ShaderProg.h
  41. 3 3
      src/resources/SkelAnim.cpp
  42. 45 0
      src/resources/SkelAnim.h
  43. 12 12
      src/resources/Skeleton.cpp
  44. 48 0
      src/resources/Skeleton.h
  45. 51 51
      src/resources/Texture.cpp
  46. 67 0
      src/resources/Texture.h
  47. 0 33
      src/resources/extension.cpp
  48. 0 24
      src/resources/extension.h
  49. 0 46
      src/resources/light_props.h
  50. 0 75
      src/resources/mesh.h
  51. 0 25
      src/resources/path.h
  52. 0 198
      src/resources/resource.h
  53. 0 55
      src/resources/shader_prog.h
  54. 0 45
      src/resources/skel_anim.h
  55. 0 48
      src/resources/skeleton.h
  56. 0 69
      src/resources/texture.h
  57. 11 11
      src/scene/light.cpp
  58. 5 5
      src/scene/light.h
  59. 47 47
      src/scene/mesh_node.cpp
  60. 6 6
      src/scene/mesh_node.h
  61. 1 1
      src/scene/node.cpp
  62. 2 2
      src/scene/node.h
  63. 8 8
      src/scene/scene.cpp
  64. 4 4
      src/scene/scene.h
  65. 1 1
      src/scene/skel_model_node.h
  66. 4 4
      src/scene/skel_node.cpp
  67. 2 2
      src/scene/skel_node.h
  68. 2 2
      src/tokenizer/Scanner.h
  69. 4 4
      src/tokenizer/parser.h
  70. 11 11
      src/ui/ui.cpp
  71. 5 5
      src/uncategorized/collision.h
  72. 17 17
      src/uncategorized/map.cpp
  73. 8 8
      src/uncategorized/map.h
  74. 1 1
      src/uncategorized/particles.h
  75. 15 15
      src/uncategorized/skybox.cpp
  76. 6 6
      src/uncategorized/skybox.h
  77. 22 22
      src/utility/common.h
  78. 1 1
      src/utility/u_string.h
  79. 2 2
      src/utility/util.cpp
  80. 1 1
      src/utility/util.h

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


+ 1 - 1
src/controllers/mesh_skel_ctrl.h

@@ -7,7 +7,7 @@
 
 
 class mesh_node_t;
 class mesh_node_t;
 class skel_node_t;
 class skel_node_t;
-class mesh_t;
+class Mesh;
 
 
 
 
 /**
 /**

+ 22 - 22
src/controllers/skel_anim_ctrl.cpp

@@ -1,7 +1,7 @@
 #include "skel_anim_ctrl.h"
 #include "skel_anim_ctrl.h"
-#include "skel_anim.h"
+#include "SkelAnim.h"
 #include "skel_node.h"
 #include "skel_node.h"
-#include "skeleton.h"
+#include "Skeleton.h"
 #include "renderer.h"
 #include "renderer.h"
 
 
 
 
@@ -15,20 +15,20 @@ skel_anim_ctrl_t::skel_anim_ctrl_t( skel_node_t* skel_node_ ):
 	heads.resize( skel_node->skeleton->bones.size() );
 	heads.resize( skel_node->skeleton->bones.size() );
 	tails.resize( skel_node->skeleton->bones.size() );
 	tails.resize( skel_node->skeleton->bones.size() );
 	bone_rotations.resize( skel_node->skeleton->bones.size() );
 	bone_rotations.resize( skel_node->skeleton->bones.size() );
-	bone_translations.resize( skel_node->skeleton->bones.size() );
+	Boneranslations.resize( skel_node->skeleton->bones.size() );
 }
 }
 
 
 
 
 //=====================================================================================================================================
 //=====================================================================================================================================
 // Interpolate                                                                                                                        =
 // Interpolate                                                                                                                        =
 //=====================================================================================================================================
 //=====================================================================================================================================
-void skel_anim_ctrl_t::Interpolate( skel_anim_t* animation, float frame )
+void skel_anim_ctrl_t::Interpolate( SkelAnim* animation, float frame )
 {
 {
 	DEBUG_ERR( frame >= animation->frames_num );
 	DEBUG_ERR( frame >= animation->frames_num );
 
 
 	// calculate the t (used in slerp and lerp) and
 	// calculate the t (used in slerp and lerp) and
 	// calc the l_pose and r_pose witch indicate the pose ids in witch the frame lies between
 	// calc the l_pose and r_pose witch indicate the pose ids in witch the frame lies between
-	const vec_t<uint>& keyframes = animation->keyframes;
+	const Vec<uint>& keyframes = animation->keyframes;
 	float t = 0.0;
 	float t = 0.0;
 	uint l_pose = 0, r_pose = 0;
 	uint l_pose = 0, r_pose = 0;
 	for( uint j=0; j<keyframes.size(); j++ )
 	for( uint j=0; j<keyframes.size(); j++ )
@@ -53,16 +53,16 @@ void skel_anim_ctrl_t::Interpolate( skel_anim_t* animation, float frame )
 	DEBUG_ERR( bone_rotations.size()<1 );
 	DEBUG_ERR( bone_rotations.size()<1 );
 	for( uint i=0; i<bone_rotations.size(); i++ )
 	for( uint i=0; i<bone_rotations.size(); i++ )
 	{
 	{
-		const skel_anim_t::bone_anim_t& banim = animation->bones[i];
+		const SkelAnim::BoneAnim& banim = animation->bones[i];
 
 
 		mat3_t& local_rot = bone_rotations[i];
 		mat3_t& local_rot = bone_rotations[i];
-		vec3_t& local_transl = bone_translations[i];
+		vec3_t& local_transl = Boneranslations[i];
 
 
 		// if the bone has animations then slerp and lerp to find the rotation and translation
 		// if the bone has animations then slerp and lerp to find the rotation and translation
 		if( banim.keyframes.size() != 0 )
 		if( banim.keyframes.size() != 0 )
 		{
 		{
-			const skel_anim_t::bone_pose_t& l_bpose = banim.keyframes[l_pose];
-			const skel_anim_t::bone_pose_t& r_bpose = banim.keyframes[r_pose];
+			const SkelAnim::BonePose& l_bpose = banim.keyframes[l_pose];
+			const SkelAnim::BonePose& r_bpose = banim.keyframes[r_pose];
 
 
 			// rotation
 			// rotation
 			const quat_t& q0 = l_bpose.rotation;
 			const quat_t& q0 = l_bpose.rotation;
@@ -101,29 +101,29 @@ void skel_anim_ctrl_t::UpdateBoneTransforms()
 	while( head != tail ) // while queue not empty
 	while( head != tail ) // while queue not empty
 	{
 	{
 		uint bone_id = queue[head++]; // queue pop
 		uint bone_id = queue[head++]; // queue pop
-		const skeleton_t::bone_t& boned = skel_node->skeleton->bones[bone_id];
+		const Skeleton::Bone& boned = skel_node->skeleton->bones[bone_id];
 
 
 		// bone.final_transform = MA * ANIM * MAi
 		// bone.final_transform = MA * ANIM * MAi
 		// where MA is bone matrix at armature space and ANIM the interpolated transformation.
 		// where MA is bone matrix at armature space and ANIM the interpolated transformation.
-		CombineTransformations( bone_translations[bone_id], bone_rotations[bone_id],
-		                        boned.tsl_skel_space_inv, boned.rot_skel_space_inv,
-		                        bone_translations[bone_id], bone_rotations[bone_id] );
+		CombineTransformations( Boneranslations[bone_id], bone_rotations[bone_id],
+		                        boned.tslSkelSpaceInv, boned.rotSkelSpaceInv,
+		                        Boneranslations[bone_id], bone_rotations[bone_id] );
 
 
-		CombineTransformations( boned.tsl_skel_space, boned.rot_skel_space,
-		                        bone_translations[bone_id], bone_rotations[bone_id],
-		                        bone_translations[bone_id], bone_rotations[bone_id] );
+		CombineTransformations( boned.tslSkelSpace, boned.rotSkelSpace,
+		                        Boneranslations[bone_id], bone_rotations[bone_id],
+		                        Boneranslations[bone_id], bone_rotations[bone_id] );
 
 
 		// and finaly add the parent's transform
 		// and finaly add the parent's transform
 		if( boned.parent )
 		if( boned.parent )
 		{
 		{
 			// bone.final_final_transform = parent.transf * bone.final_transform
 			// bone.final_final_transform = parent.transf * bone.final_transform
-			CombineTransformations( bone_translations[boned.parent->id], bone_rotations[boned.parent->id],
-		                          bone_translations[bone_id], bone_rotations[bone_id],
-		                          bone_translations[bone_id], bone_rotations[bone_id] );
+			CombineTransformations( Boneranslations[boned.parent->id], bone_rotations[boned.parent->id],
+		                          Boneranslations[bone_id], bone_rotations[bone_id],
+		                          Boneranslations[bone_id], bone_rotations[bone_id] );
 		}
 		}
 
 
 		// now add the bone's childes
 		// now add the bone's childes
-		for( uint i=0; i<boned.childs_num; i++ )
+		for( uint i=0; i<boned.childsNum; i++ )
 			queue[tail++] = boned.childs[i]->id;
 			queue[tail++] = boned.childs[i]->id;
 	}
 	}
 }
 }
@@ -134,12 +134,12 @@ void skel_anim_ctrl_t::UpdateBoneTransforms()
 //=====================================================================================================================================
 //=====================================================================================================================================
 void skel_anim_ctrl_t::Deform()
 void skel_anim_ctrl_t::Deform()
 {
 {
-	skeleton_t* skeleton = skel_node->skeleton;
+	Skeleton* skeleton = skel_node->skeleton;
 
 
 	for( uint i=0; i<skeleton->bones.size(); i++ )
 	for( uint i=0; i<skeleton->bones.size(); i++ )
 	{
 	{
 		const mat3_t& rot = bone_rotations[ i ];
 		const mat3_t& rot = bone_rotations[ i ];
-		const vec3_t& transl = bone_translations[ i ];
+		const vec3_t& transl = Boneranslations[ i ];
 
 
 		heads[i] = skeleton->bones[i].head.GetTransformed( transl, rot );
 		heads[i] = skeleton->bones[i].head.GetTransformed( transl, rot );
 		tails[i] = skeleton->bones[i].tail.GetTransformed( transl, rot );
 		tails[i] = skeleton->bones[i].tail.GetTransformed( transl, rot );

+ 8 - 8
src/controllers/skel_anim_ctrl.h

@@ -5,8 +5,8 @@
 #include "controller.h"
 #include "controller.h"
 #include "gmath.h"
 #include "gmath.h"
 
 
-class skeleton_t;
-class skel_anim_t;
+class Skeleton;
+class SkelAnim;
 class skel_node_t;
 class skel_node_t;
 
 
 
 
@@ -14,17 +14,17 @@ class skel_node_t;
 class skel_anim_ctrl_t: public controller_t
 class skel_anim_ctrl_t: public controller_t
 {
 {
 	private:
 	private:
-		void Interpolate( skel_anim_t* animation, float frame );
+		void Interpolate( SkelAnim* animation, float frame );
 		void UpdateBoneTransforms();
 		void UpdateBoneTransforms();
 		void Deform();
 		void Deform();
 
 
 	public:
 	public:
-		skel_anim_t*  skel_anim; ///< Skeleton animation resource
+		SkelAnim*  skel_anim; ///< Skeleton animation resource
 		skel_node_t*  skel_node;
 		skel_node_t*  skel_node;
-		vec_t<vec3_t> heads;
-		vec_t<vec3_t> tails;
-		vec_t<mat3_t> bone_rotations;
-		vec_t<vec3_t> bone_translations;
+		Vec<vec3_t> heads;
+		Vec<vec3_t> tails;
+		Vec<mat3_t> bone_rotations;
+		Vec<vec3_t> Boneranslations;
 		float step;
 		float step;
 		float frame;
 		float frame;
 
 

+ 9 - 9
src/main.cpp

@@ -11,12 +11,12 @@
 #include "ui.h"
 #include "ui.h"
 #include "app.h"
 #include "app.h"
 #include "particles.h"
 #include "particles.h"
-#include "texture.h"
-#include "mesh.h"
+#include "Texture.h"
+#include "Mesh.h"
 #include "light.h"
 #include "light.h"
 #include "collision.h"
 #include "collision.h"
-#include "material.h"
-#include "resource.h"
+#include "Material.h"
+#include "Resource.h"
 #include "scene.h"
 #include "scene.h"
 #include "Scanner.h"
 #include "Scanner.h"
 #include "skybox.h"
 #include "skybox.h"
@@ -24,11 +24,11 @@
 #include "mesh_node.h"
 #include "mesh_node.h"
 #include "skel_model_node.h"
 #include "skel_model_node.h"
 #include "mesh_node.h"
 #include "mesh_node.h"
-#include "skel_anim.h"
+#include "SkelAnim.h"
 #include "mesh_skel_ctrl.h"
 #include "mesh_skel_ctrl.h"
 #include "skel_anim_ctrl.h"
 #include "skel_anim_ctrl.h"
 #include "skel_node.h"
 #include "skel_node.h"
-#include "light_props.h"
+#include "LightProps.h"
 #include "btBulletCollisionCommon.h"
 #include "btBulletCollisionCommon.h"
 #include "btBulletDynamicsCommon.h"
 #include "btBulletDynamicsCommon.h"
 #include "BulletDebuger.h"
 #include "BulletDebuger.h"
@@ -226,17 +226,17 @@ void Init()
 	imp = new skel_model_node_t();
 	imp = new skel_model_node_t();
 	imp->Init( "models/imp/imp.smdl" );
 	imp->Init( "models/imp/imp.smdl" );
 	imp->SetLocalTransformation( vec3_t( 0.0, 2.11, 0.0 ), mat3_t( euler_t(-m::PI/2, 0.0, 0.0) ), 0.7 );
 	imp->SetLocalTransformation( vec3_t( 0.0, 2.11, 0.0 ), mat3_t( euler_t(-m::PI/2, 0.0, 0.0) ), 0.7 );
-	imp->mesh_nodes[0]->mesh_skel_ctrl->skel_node->skel_anim_ctrl->skel_anim = rsrc::skel_anims.Load( "models/imp/walk.imp.anim" );
+	imp->mesh_nodes[0]->mesh_skel_ctrl->skel_node->skel_anim_ctrl->skel_anim = rsrc::skel_anims.load( "models/imp/walk.imp.anim" );
 	imp->mesh_nodes[0]->mesh_skel_ctrl->skel_node->skel_anim_ctrl->step = 0.8;
 	imp->mesh_nodes[0]->mesh_skel_ctrl->skel_node->skel_anim_ctrl->step = 0.8;
 
 
 
 
 	//
 	//
 	floor_ = new floor_t;
 	floor_ = new floor_t;
-	//floor_->material = rsrc::materials.Load( "materials/default.mtl" );
+	//floor_->material = rsrc::materials.load( "materials/default.mtl" );
 
 
 	const char* skybox_fnames [] = { "textures/env/hellsky4_forward.tga", "textures/env/hellsky4_back.tga", "textures/env/hellsky4_left.tga",
 	const char* skybox_fnames [] = { "textures/env/hellsky4_forward.tga", "textures/env/hellsky4_back.tga", "textures/env/hellsky4_left.tga",
 																	 "textures/env/hellsky4_right.tga", "textures/env/hellsky4_up.tga", "textures/env/hellsky4_down.tga" };
 																	 "textures/env/hellsky4_right.tga", "textures/env/hellsky4_up.tga", "textures/env/hellsky4_down.tga" };
-	scene::skybox.Load( skybox_fnames );
+	scene::skybox.load( skybox_fnames );
 
 
 	PRINT( "Engine initialization ends (" << app::GetTicks()-ticks << ")" );
 	PRINT( "Engine initialization ends (" << app::GetTicks()-ticks << ")" );
 	cerr.flush();
 	cerr.flush();

+ 1 - 1
src/math/mat3.inl.h

@@ -443,7 +443,7 @@ inline void mat3_t::SetRotationY( float rad )
 	ME(2,2) = costheta;
 	ME(2,2) = costheta;
 }
 }
 
 
-// LoadRotationZ
+// loadRotationZ
 inline void mat3_t::SetRotationZ( float rad )
 inline void mat3_t::SetRotationZ( float rad )
 {
 {
 	float sintheta, costheta;
 	float sintheta, costheta;

+ 13 - 13
src/renderer/fbo.h

@@ -8,23 +8,23 @@
 /// The class is created as a wrapper to avoid common mistakes
 /// The class is created as a wrapper to avoid common mistakes
 class fbo_t
 class fbo_t
 {
 {
-	PROPERTY_R( uint, gl_id, GetGLID ) ///< OpenGL idendification
+	PROPERTY_R( uint, glId, getGlId ) ///< OpenGL idendification
 
 
 	public:
 	public:
-		fbo_t(): gl_id(0) {}
+		fbo_t(): glId(0) {}
 
 
 		/// Creates a new FBO
 		/// Creates a new FBO
 		void Create()
 		void Create()
 		{
 		{
-			DEBUG_ERR( gl_id != 0 ); // FBO allready initialized
-			glGenFramebuffers( 1, &gl_id );
+			DEBUG_ERR( glId != 0 ); // FBO allready initialized
+			glGenFramebuffers( 1, &glId );
 		}
 		}
 
 
 		/// Binds FBO
 		/// Binds FBO
 		void Bind() const
 		void Bind() const
 		{
 		{
-			DEBUG_ERR( gl_id == 0 );  // FBO unitialized
-			glBindFramebuffer( GL_FRAMEBUFFER, gl_id );
+			DEBUG_ERR( glId == 0 );  // FBO unitialized
+			glBindFramebuffer( GL_FRAMEBUFFER, glId );
 		}
 		}
 
 
 		/// Unbinds the FBO. Actualy unbinds all FBOs
 		/// Unbinds the FBO. Actualy unbinds all FBOs
@@ -36,8 +36,8 @@ class fbo_t
 		 */
 		 */
 		bool IsGood() const
 		bool IsGood() const
 		{
 		{
-			DEBUG_ERR( gl_id == 0 );  // FBO unitialized
-			DEBUG_ERR( GetCurrentFBO() != gl_id ); // another FBO is binded
+			DEBUG_ERR( glId == 0 );  // FBO unitialized
+			DEBUG_ERR( GetCurrentFBO() != glId ); // another FBO is binded
 
 
 			return glCheckFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE;
 			return glCheckFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE;
 		}
 		}
@@ -45,8 +45,8 @@ class fbo_t
 		/// Set the number of color attachements of the FBO
 		/// Set the number of color attachements of the FBO
 		void SetNumOfColorAttachements( uint num ) const
 		void SetNumOfColorAttachements( uint num ) const
 		{
 		{
-			DEBUG_ERR( gl_id == 0 );  // FBO unitialized
-			DEBUG_ERR( GetCurrentFBO() != gl_id ); // another FBO is binded
+			DEBUG_ERR( glId == 0 );  // FBO unitialized
+			DEBUG_ERR( GetCurrentFBO() != glId ); // another FBO is binded
 
 
 			if( num == 0 )
 			if( num == 0 )
 			{
 			{
@@ -67,9 +67,9 @@ class fbo_t
 		 */
 		 */
 		static uint GetCurrentFBO()
 		static uint GetCurrentFBO()
 		{
 		{
-			int fbo_gl_id;
-			glGetIntegerv( GL_FRAMEBUFFER_BINDING, &fbo_gl_id );
-			return (uint)fbo_gl_id;
+			int fbo_glId;
+			glGetIntegerv( GL_FRAMEBUFFER_BINDING, &fbo_glId );
+			return (uint)fbo_glId;
 		}
 		}
 };
 };
 
 

+ 6 - 6
src/renderer/r_bs.cpp

@@ -6,12 +6,12 @@
 #include "renderer.h"
 #include "renderer.h"
 #include "camera.h"
 #include "camera.h"
 #include "scene.h"
 #include "scene.h"
-#include "mesh.h"
+#include "Mesh.h"
 #include "r_private.h"
 #include "r_private.h"
-#include "resource.h"
+#include "Resource.h"
 #include "fbo.h"
 #include "fbo.h"
 #include "mesh_node.h"
 #include "mesh_node.h"
-#include "material.h"
+#include "Material.h"
 
 
 
 
 namespace r {
 namespace r {
@@ -36,8 +36,8 @@ void Init()
 	fbo.SetNumOfColorAttachements(1);
 	fbo.SetNumOfColorAttachements(1);
 
 
 	// attach the texes
 	// attach the texes
-	glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, r::is::fai.GetGLID(), 0 );
-	glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT,  GL_TEXTURE_2D, r::ms::depth_fai.GetGLID(), 0 );
+	glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, r::is::fai.getGlId(), 0 );
+	glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT,  GL_TEXTURE_2D, r::ms::depth_fai.getGlId(), 0 );
 
 
 	// test if success
 	// test if success
 	if( !fbo.IsGood() )
 	if( !fbo.IsGood() )
@@ -69,7 +69,7 @@ void RunStage( const camera_t& cam )
 		if( mesh_node->material->blends && !mesh_node->material->blends )
 		if( mesh_node->material->blends && !mesh_node->material->blends )
 		{
 		{
 			fbo.Bind();
 			fbo.Bind();
-			mesh_node->material->Setup();
+			mesh_node->material->setup();
 			mesh_node->Render();
 			mesh_node->Render();
 		}
 		}
 
 

+ 15 - 15
src/renderer/r_bs2.cpp

@@ -6,12 +6,12 @@
 #include "renderer.h"
 #include "renderer.h"
 #include "camera.h"
 #include "camera.h"
 #include "scene.h"
 #include "scene.h"
-#include "mesh.h"
+#include "Mesh.h"
 #include "r_private.h"
 #include "r_private.h"
-#include "resource.h"
+#include "Resource.h"
 #include "fbo.h"
 #include "fbo.h"
 #include "mesh_node.h"
 #include "mesh_node.h"
-#include "material.h"
+#include "Material.h"
 
 
 
 
 namespace r {
 namespace r {
@@ -22,8 +22,8 @@ namespace bs {
 //=====================================================================================================================================
 //=====================================================================================================================================
 static fbo_t intermid_fbo, fbo;
 static fbo_t intermid_fbo, fbo;
 
 
-static texture_t fai; ///< RGB for color and A for mask (0 doesnt pass, 1 pass)
-static shader_prog_t* shader_prog;
+static Texture fai; ///< RGB for color and A for mask (0 doesnt pass, 1 pass)
+static ShaderProg* shader_prog;
 
 
 
 
 //=====================================================================================================================================
 //=====================================================================================================================================
@@ -40,8 +40,8 @@ void Init2()
 	fbo.SetNumOfColorAttachements(1);
 	fbo.SetNumOfColorAttachements(1);
 
 
 	// attach the texes
 	// attach the texes
-	glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, r::pps::fai.GetGLID(), 0 );
-	glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT,  GL_TEXTURE_2D, r::ms::depth_fai.GetGLID(), 0 );
+	glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, r::pps::fai.getGlId(), 0 );
+	glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT,  GL_TEXTURE_2D, r::ms::depth_fai.getGlId(), 0 );
 
 
 	// test if success
 	// test if success
 	if( !fbo.IsGood() )
 	if( !fbo.IsGood() )
@@ -57,11 +57,11 @@ void Init2()
 
 
 	// texture
 	// texture
 	intermid_fbo.SetNumOfColorAttachements(1);
 	intermid_fbo.SetNumOfColorAttachements(1);
-	fai.CreateEmpty2D( r::w, r::h, GL_RGBA8, GL_RGBA );
-	glFramebufferTexture2D( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, fai.GetGLID(), 0 );
+	fai.createEmpty2D( r::w, r::h, GL_RGBA8, GL_RGBA );
+	glFramebufferTexture2D( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, fai.getGlId(), 0 );
 
 
 	// attach the texes
 	// attach the texes
-	glFramebufferTexture2D( GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,  GL_TEXTURE_2D, r::ms::depth_fai.GetGLID(), 0 );
+	glFramebufferTexture2D( GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,  GL_TEXTURE_2D, r::ms::depth_fai.getGlId(), 0 );
 
 
 	// test if success
 	// test if success
 	if( !intermid_fbo.IsGood() )
 	if( !intermid_fbo.IsGood() )
@@ -70,7 +70,7 @@ void Init2()
 	// unbind
 	// unbind
 	intermid_fbo.Unbind();
 	intermid_fbo.Unbind();
 
 
-	shader_prog = rsrc::shaders.Load( "shaders/bs_refract.glsl" );
+	shader_prog = rsrc::shaders.load( "shaders/bs_refract.glsl" );
 }
 }
 
 
 
 
@@ -96,14 +96,14 @@ void RunStage2( const camera_t& cam )
 			intermid_fbo.Bind();
 			intermid_fbo.Bind();
 			glEnable( GL_DEPTH_TEST );
 			glEnable( GL_DEPTH_TEST );
 			glClear( GL_COLOR_BUFFER_BIT );
 			glClear( GL_COLOR_BUFFER_BIT );
-			mesh_node->material->Setup();
+			mesh_node->material->setup();
 			mesh_node->Render();
 			mesh_node->Render();
 
 
 			fbo.Bind();
 			fbo.Bind();
 			glDisable( GL_DEPTH_TEST );
 			glDisable( GL_DEPTH_TEST );
-			shader_prog->Bind();
-			shader_prog->LocTexUnit( shader_prog->GetUniformLocation(0), fai, 0 );
-			r::DrawQuad( shader_prog->GetAttributeLocation(0) );
+			shader_prog->bind();
+			shader_prog->locTexUnit( shader_prog->GetUniLoc(0), fai, 0 );
+			r::DrawQuad( shader_prog->getAttribLoc(0) );
 		}
 		}
 	}
 	}
 
 

+ 6 - 6
src/renderer/r_dbg.cpp

@@ -2,7 +2,7 @@
 #include "r_private.h"
 #include "r_private.h"
 #include "fbo.h"
 #include "fbo.h"
 #include "scene.h"
 #include "scene.h"
-#include "texture.h"
+#include "Texture.h"
 #include "fbo.h"
 #include "fbo.h"
 #include "node.h"
 #include "node.h"
 #include "skel_node.h"
 #include "skel_node.h"
@@ -119,7 +119,7 @@ bool show_bvolumes = true;
 
 
 static fbo_t fbo;
 static fbo_t fbo;
 
 
-static shader_prog_t* shdr;
+static ShaderProg* shdr;
 
 
 
 
 /*
 /*
@@ -137,8 +137,8 @@ void Init()
 	fbo.SetNumOfColorAttachements(1);
 	fbo.SetNumOfColorAttachements(1);
 
 
 	// attach the textures
 	// attach the textures
-	glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, r::pps::fai.GetGLID(), 0 );
-	glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT,  GL_TEXTURE_2D, r::ms::depth_fai.GetGLID(), 0 );
+	glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, r::pps::fai.getGlId(), 0 );
+	glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT,  GL_TEXTURE_2D, r::ms::depth_fai.getGlId(), 0 );
 
 
 	// test if success
 	// test if success
 	if( !fbo.IsGood() )
 	if( !fbo.IsGood() )
@@ -148,7 +148,7 @@ void Init()
 	fbo.Unbind();
 	fbo.Unbind();
 
 
 	// shader
 	// shader
-	shdr = rsrc::shaders.Load( "shaders/dbg.glsl" );
+	shdr = rsrc::shaders.load( "shaders/dbg.glsl" );
 }
 }
 
 
 
 
@@ -161,7 +161,7 @@ void RunStage( const camera_t& cam )
 {
 {
 	fbo.Bind();
 	fbo.Bind();
 
 
-	shdr->Bind();
+	shdr->bind();
 
 
 	// OGL stuff
 	// OGL stuff
 	SetProjectionViewMatrices( cam );
 	SetProjectionViewMatrices( cam );

+ 62 - 62
src/renderer/r_is.cpp

@@ -5,13 +5,13 @@ The file contains functions and vars used for the deferred shading illumination
 #include "renderer.h"
 #include "renderer.h"
 #include "camera.h"
 #include "camera.h"
 #include "scene.h"
 #include "scene.h"
-#include "mesh.h"
+#include "Mesh.h"
 #include "light.h"
 #include "light.h"
-#include "resource.h"
+#include "Resource.h"
 #include "scene.h"
 #include "scene.h"
 #include "r_private.h"
 #include "r_private.h"
 #include "fbo.h"
 #include "fbo.h"
-#include "light_props.h"
+#include "LightProps.h"
 
 
 namespace r {
 namespace r {
 namespace is {
 namespace is {
@@ -24,15 +24,15 @@ VARS
 */
 */
 static fbo_t fbo;
 static fbo_t fbo;
 
 
-texture_t fai;  // illuminated scene
+Texture fai;  // illuminated scene
 
 
 static uint stencil_rb; // framebuffer render buffer for stencil optimizations
 static uint stencil_rb; // framebuffer render buffer for stencil optimizations
 
 
 // shaders
 // shaders
-static shader_prog_t* shdr_is_ambient;
-static shader_prog_t* shdr_is_lp_point_light;
-static shader_prog_t* shdr_is_lp_spot_light_nos;
-static shader_prog_t* shdr_is_lp_spot_light_s;
+static ShaderProg* shdr_is_ambient;
+static ShaderProg* shdr_is_lp_point_light;
+static ShaderProg* shdr_is_lp_spot_light_nos;
+static ShaderProg* shdr_is_lp_spot_light_s;
 
 
 
 
 // the bellow are used to speedup the calculation of the frag pos (view space) inside the shader. This is done by precompute the
 // the bellow are used to speedup the calculation of the frag pos (view space) inside the shader. This is done by precompute the
@@ -138,13 +138,13 @@ static void InitStageFBO()
 	fbo.SetNumOfColorAttachements(1);
 	fbo.SetNumOfColorAttachements(1);
 
 
 	// create the txtrs
 	// create the txtrs
-	if( !fai.CreateEmpty2D( r::w, r::h, GL_RGB, GL_RGB, GL_UNSIGNED_BYTE ) )
+	if( !fai.createEmpty2D( r::w, r::h, GL_RGB, GL_RGB, GL_UNSIGNED_BYTE ) )
 	{
 	{
 		FATAL( "See prev error" );
 		FATAL( "See prev error" );
 	}
 	}
 
 
 	// attach
 	// attach
-	glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, fai.GetGLID(), 0 );
+	glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, fai.getGlId(), 0 );
 
 
 	// test if success
 	// test if success
 	if( !fbo.IsGood() )
 	if( !fbo.IsGood() )
@@ -163,10 +163,10 @@ Init
 void Init()
 void Init()
 {
 {
 	// load the shaders
 	// load the shaders
-	shdr_is_ambient = rsrc::shaders.Load( "shaders/is_ap.glsl" );
-	shdr_is_lp_point_light = rsrc::shaders.Load( "shaders/is_lp_point.glsl" );
-	shdr_is_lp_spot_light_nos = rsrc::shaders.Load( "shaders/is_lp_spot.glsl" );
-	shdr_is_lp_spot_light_s = rsrc::shaders.Load( "shaders/is_lp_spot_shad.glsl" );
+	shdr_is_ambient = rsrc::shaders.load( "shaders/is_ap.glsl" );
+	shdr_is_lp_point_light = rsrc::shaders.load( "shaders/is_lp_point.glsl" );
+	shdr_is_lp_spot_light_nos = rsrc::shaders.load( "shaders/is_lp_spot.glsl" );
+	shdr_is_lp_spot_light_s = rsrc::shaders.load( "shaders/is_lp_spot_shad.glsl" );
 
 
 
 
 	// init the rest
 	// init the rest
@@ -187,14 +187,14 @@ static void AmbientPass( const camera_t& /*cam*/, const vec3_t& color )
 	glDisable( GL_BLEND );
 	glDisable( GL_BLEND );
 
 
 	// set the shader
 	// set the shader
-	shdr_is_ambient->Bind();
+	shdr_is_ambient->bind();
 
 
 	// set the uniforms
 	// set the uniforms
-	glUniform3fv( shdr_is_ambient->GetUniformLocation(0), 1, &((vec3_t)color)[0] );
-	shdr_is_ambient->LocTexUnit( shdr_is_ambient->GetUniformLocation(1), r::ms::diffuse_fai, 0 );
+	glUniform3fv( shdr_is_ambient->GetUniLoc(0), 1, &((vec3_t)color)[0] );
+	shdr_is_ambient->locTexUnit( shdr_is_ambient->GetUniLoc(1), r::ms::diffuse_fai, 0 );
 
 
 	// Draw quad
 	// Draw quad
-	r::DrawQuad( shdr_is_ambient->GetAttributeLocation(0) );
+	r::DrawQuad( shdr_is_ambient->getAttribLoc(0) );
 }
 }
 
 
 
 
@@ -326,33 +326,33 @@ static void PointLightPass( const camera_t& cam, const point_light_t& light )
 	SetStencilMask( cam, light );
 	SetStencilMask( cam, light );
 
 
 	//** bind the shader **
 	//** bind the shader **
-	const shader_prog_t& shader = *shdr_is_lp_point_light; // I dont want to type
-	shader.Bind();
+	const ShaderProg& shader = *shdr_is_lp_point_light; // I dont want to type
+	shader.bind();
 
 
 	// bind the material stage framebuffer attachable images
 	// bind the material stage framebuffer attachable images
-	shader.LocTexUnit( shader.GetUniformLocation(0), r::ms::normal_fai, 0 );
-	shader.LocTexUnit( shader.GetUniformLocation(1), r::ms::diffuse_fai, 1 );
-	shader.LocTexUnit( shader.GetUniformLocation(2), r::ms::specular_fai, 2 );
-	shader.LocTexUnit( shader.GetUniformLocation(3), r::ms::depth_fai, 3 );
-	glUniform2fv( shader.GetUniformLocation(4), 1, &planes[0] );
+	shader.locTexUnit( shader.GetUniLoc(0), r::ms::normal_fai, 0 );
+	shader.locTexUnit( shader.GetUniLoc(1), r::ms::diffuse_fai, 1 );
+	shader.locTexUnit( shader.GetUniLoc(2), r::ms::specular_fai, 2 );
+	shader.locTexUnit( shader.GetUniLoc(3), r::ms::depth_fai, 3 );
+	glUniform2fv( shader.GetUniLoc(4), 1, &planes[0] );
 
 
 	vec3_t light_pos_eye_space = light.translation_wspace.GetTransformed( cam.GetViewMatrix() );
 	vec3_t light_pos_eye_space = light.translation_wspace.GetTransformed( cam.GetViewMatrix() );
-	glUniform3fv( shader.GetUniformLocation(5), 1, &light_pos_eye_space[0] );
-	glUniform1f( shader.GetUniformLocation(6), 1.0/light.radius );
-	glUniform3fv( shader.GetUniformLocation(7), 1, &vec3_t(light.light_props->GetDiffuseColor())[0] );
-	glUniform3fv( shader.GetUniformLocation(8), 1, &vec3_t(light.light_props->GetSpecularColor())[0] );
+	glUniform3fv( shader.GetUniLoc(5), 1, &light_pos_eye_space[0] );
+	glUniform1f( shader.GetUniLoc(6), 1.0/light.radius );
+	glUniform3fv( shader.GetUniLoc(7), 1, &vec3_t(light.light_props->getDiffuseColor())[0] );
+	glUniform3fv( shader.GetUniLoc(8), 1, &vec3_t(light.light_props->getSpecularColor())[0] );
 
 
 	//** render quad **
 	//** render quad **
-	glEnableVertexAttribArray( shader.GetAttributeLocation(0) );
-	glEnableVertexAttribArray( shader.GetAttributeLocation(1) );
+	glEnableVertexAttribArray( shader.getAttribLoc(0) );
+	glEnableVertexAttribArray( shader.getAttribLoc(1) );
 
 
-	glVertexAttribPointer( shader.GetAttributeLocation(0), 2, GL_FLOAT, false, 0, &quad_vert_cords[0] );
-	glVertexAttribPointer( shader.GetAttributeLocation(1), 3, GL_FLOAT, false, 0, &view_vectors[0] );
+	glVertexAttribPointer( shader.getAttribLoc(0), 2, GL_FLOAT, false, 0, &quad_vert_cords[0] );
+	glVertexAttribPointer( shader.getAttribLoc(1), 3, GL_FLOAT, false, 0, &view_vectors[0] );
 
 
 	glDrawArrays( GL_QUADS, 0, 4 );
 	glDrawArrays( GL_QUADS, 0, 4 );
 
 
-	glDisableVertexAttribArray( shader.GetAttributeLocation(0) );
-	glDisableVertexAttribArray( shader.GetAttributeLocation(1) );
+	glDisableVertexAttribArray( shader.getAttribLoc(0) );
+	glDisableVertexAttribArray( shader.getAttribLoc(1) );
 
 
 	//glDisable( GL_SCISSOR_TEST );
 	//glDisable( GL_SCISSOR_TEST );
 	glDisable( GL_STENCIL_TEST );
 	glDisable( GL_STENCIL_TEST );
@@ -373,7 +373,7 @@ static void SpotLightPass( const camera_t& cam, const spot_light_t& light )
 	SetStencilMask( cam, light );
 	SetStencilMask( cam, light );
 
 
 	//** generate the shadow map (if needed) **
 	//** generate the shadow map (if needed) **
-	if( light.casts_shadow )
+	if( light.castsShadow )
 	{
 	{
 		r::is::shadows::RunPass( light.camera );
 		r::is::shadows::RunPass( light.camera );
 
 
@@ -387,35 +387,35 @@ static void SpotLightPass( const camera_t& cam, const spot_light_t& light )
 	}
 	}
 
 
 	//** set the shader and uniforms **
 	//** set the shader and uniforms **
-	const shader_prog_t* shdr; // because of the huge name
+	const ShaderProg* shdr; // because of the huge name
 
 
-	if( light.casts_shadow )  shdr = shdr_is_lp_spot_light_s;
+	if( light.castsShadow )  shdr = shdr_is_lp_spot_light_s;
 	else                      shdr = shdr_is_lp_spot_light_nos;
 	else                      shdr = shdr_is_lp_spot_light_nos;
 
 
-	shdr->Bind();
+	shdr->bind();
 
 
 	// bind the framebuffer attachable images
 	// bind the framebuffer attachable images
-	shdr->LocTexUnit( shdr->GetUniformLocation(0), r::ms::normal_fai, 0 );
-	shdr->LocTexUnit( shdr->GetUniformLocation(1), r::ms::diffuse_fai, 1 );
-	shdr->LocTexUnit( shdr->GetUniformLocation(2), r::ms::specular_fai, 2 );
-	shdr->LocTexUnit( shdr->GetUniformLocation(3), r::ms::depth_fai, 3 );
+	shdr->locTexUnit( shdr->GetUniLoc(0), r::ms::normal_fai, 0 );
+	shdr->locTexUnit( shdr->GetUniLoc(1), r::ms::diffuse_fai, 1 );
+	shdr->locTexUnit( shdr->GetUniLoc(2), r::ms::specular_fai, 2 );
+	shdr->locTexUnit( shdr->GetUniLoc(3), r::ms::depth_fai, 3 );
 
 
-	if( light.light_props->GetTexture() == NULL )
-		ERROR( "No texture is attached to the light. light_props name: " << light.light_props->GetName() );
+	if( light.light_props->getTexture() == NULL )
+		ERROR( "No texture is attached to the light. light_props name: " << light.light_props->getName() );
 
 
 	// the planes
 	// the planes
-	//glUniform2fv( shdr->GetUniformLocation("planes"), 1, &planes[0] );
-	glUniform2fv( shdr->GetUniformLocation(4), 1, &planes[0] );
+	//glUniform2fv( shdr->getUniLoc("planes"), 1, &planes[0] );
+	glUniform2fv( shdr->GetUniLoc(4), 1, &planes[0] );
 
 
 	// the light params
 	// the light params
 	vec3_t light_pos_eye_space = light.translation_wspace.GetTransformed( cam.GetViewMatrix() );
 	vec3_t light_pos_eye_space = light.translation_wspace.GetTransformed( cam.GetViewMatrix() );
-	glUniform3fv( shdr->GetUniformLocation(5), 1, &light_pos_eye_space[0] );
-	glUniform1f( shdr->GetUniformLocation(6), 1.0/light.GetDistance() );
-	glUniform3fv( shdr->GetUniformLocation(7), 1, &vec3_t(light.light_props->GetDiffuseColor())[0] );
-	glUniform3fv( shdr->GetUniformLocation(8), 1, &vec3_t(light.light_props->GetSpecularColor())[0] );
+	glUniform3fv( shdr->GetUniLoc(5), 1, &light_pos_eye_space[0] );
+	glUniform1f( shdr->GetUniLoc(6), 1.0/light.GetDistance() );
+	glUniform3fv( shdr->GetUniLoc(7), 1, &vec3_t(light.light_props->getDiffuseColor())[0] );
+	glUniform3fv( shdr->GetUniLoc(8), 1, &vec3_t(light.light_props->getSpecularColor())[0] );
 
 
 	// set the light texture
 	// set the light texture
-	shdr->LocTexUnit( shdr->GetUniformLocation(9), *light.light_props->GetTexture(), 4 );
+	shdr->locTexUnit( shdr->GetUniLoc(9), *light.light_props->getTexture(), 4 );
 	// before we render disable anisotropic in the light.texture because it produces artefacts. ToDo: see if this is unececeary in future drivers
 	// before we render disable anisotropic in the light.texture because it produces artefacts. ToDo: see if this is unececeary in future drivers
 	glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
 	glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
 	glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
 	glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
@@ -427,13 +427,13 @@ static void SpotLightPass( const camera_t& cam, const spot_light_t& light )
 	static mat4_t bias_m4( 0.5, 0.0, 0.0, 0.5, 0.0, 0.5, 0.0, 0.5, 0.0, 0.0, 0.5, 0.5, 0.0, 0.0, 0.0, 1.0 );
 	static mat4_t bias_m4( 0.5, 0.0, 0.0, 0.5, 0.0, 0.5, 0.0, 0.5, 0.0, 0.0, 0.5, 0.5, 0.0, 0.0, 0.0, 1.0 );
 	mat4_t tex_projection_mat;
 	mat4_t tex_projection_mat;
 	tex_projection_mat = bias_m4 * light.camera.GetProjectionMatrix() * light.camera.GetViewMatrix() * cam.transformation_wspace;
 	tex_projection_mat = bias_m4 * light.camera.GetProjectionMatrix() * light.camera.GetViewMatrix() * cam.transformation_wspace;
-	glUniformMatrix4fv( shdr->GetUniformLocation(10), 1, true, &tex_projection_mat[0] );
+	glUniformMatrix4fv( shdr->GetUniLoc(10), 1, true, &tex_projection_mat[0] );
 
 
 	/*
 	/*
 	const float mBias[] = {0.5, 0.0, 0.0, 0.0, 0.0, 0.5, 0.0, 0.0, 0.0, 0.0, 0.5, 0.0, 0.5, 0.5, 0.5, 1.0};
 	const float mBias[] = {0.5, 0.0, 0.0, 0.0, 0.0, 0.5, 0.0, 0.0, 0.0, 0.0, 0.5, 0.0, 0.5, 0.5, 0.5, 1.0};
 	glActiveTexture( GL_TEXTURE0 );
 	glActiveTexture( GL_TEXTURE0 );
 	glMatrixMode( GL_TEXTURE );
 	glMatrixMode( GL_TEXTURE );
-	glLoadMatrixf( mBias );
+	glloadMatrixf( mBias );
 	r::MultMatrix( light.camera.GetProjectionMatrix() );
 	r::MultMatrix( light.camera.GetProjectionMatrix() );
 	r::MultMatrix( light.camera.GetViewMatrix() );
 	r::MultMatrix( light.camera.GetViewMatrix() );
 	r::MultMatrix( cam.transformation_wspace );
 	r::MultMatrix( cam.transformation_wspace );
@@ -441,22 +441,22 @@ static void SpotLightPass( const camera_t& cam, const spot_light_t& light )
 
 
 	// the shadow stuff
 	// the shadow stuff
 	// render depth to texture and then bind it
 	// render depth to texture and then bind it
-	if( light.casts_shadow )
+	if( light.castsShadow )
 	{
 	{
-		shdr->LocTexUnit( shdr->GetUniformLocation(11), r::is::shadows::shadow_map, 5 );
+		shdr->locTexUnit( shdr->GetUniLoc(11), r::is::shadows::shadow_map, 5 );
 	}
 	}
 
 
 	//** render quad **
 	//** render quad **
-	glEnableVertexAttribArray( shdr->GetAttributeLocation(0) );
-	glEnableVertexAttribArray( shdr->GetAttributeLocation(1) );
+	glEnableVertexAttribArray( shdr->getAttribLoc(0) );
+	glEnableVertexAttribArray( shdr->getAttribLoc(1) );
 
 
-	glVertexAttribPointer( shdr->GetAttributeLocation(0), 2, GL_FLOAT, false, 0, &quad_vert_cords[0] );
-	glVertexAttribPointer( shdr->GetAttributeLocation(1), 3, GL_FLOAT, false, 0, &view_vectors[0] );
+	glVertexAttribPointer( shdr->getAttribLoc(0), 2, GL_FLOAT, false, 0, &quad_vert_cords[0] );
+	glVertexAttribPointer( shdr->getAttribLoc(1), 3, GL_FLOAT, false, 0, &view_vectors[0] );
 
 
 	glDrawArrays( GL_QUADS, 0, 4 );
 	glDrawArrays( GL_QUADS, 0, 4 );
 
 
-	glDisableVertexAttribArray( shdr->GetAttributeLocation(0) );
-	glDisableVertexAttribArray( shdr->GetAttributeLocation(1) );
+	glDisableVertexAttribArray( shdr->getAttribLoc(0) );
+	glDisableVertexAttribArray( shdr->getAttribLoc(1) );
 
 
 	// restore texture matrix
 	// restore texture matrix
 	glMatrixMode( GL_TEXTURE );
 	glMatrixMode( GL_TEXTURE );

+ 17 - 17
src/renderer/r_is_shadows.cpp

@@ -1,10 +1,10 @@
 #include "renderer.h"
 #include "renderer.h"
-#include "texture.h"
+#include "Texture.h"
 #include "scene.h"
 #include "scene.h"
-#include "resource.h"
+#include "Resource.h"
 #include "r_private.h"
 #include "r_private.h"
 #include "fbo.h"
 #include "fbo.h"
-#include "material.h"
+#include "Material.h"
 #include "mesh_node.h"
 #include "mesh_node.h"
 
 
 namespace r {
 namespace r {
@@ -21,11 +21,11 @@ bool bilinear = true;
 
 
 static fbo_t fbo;
 static fbo_t fbo;
 
 
-shader_prog_t* shdr_depth, * shdr_depth_grass, * shdr_depth_hw_skinning;
+ShaderProg* shdr_depth, * shdr_depth_grass, * shdr_depth_hw_skinning;
 
 
 // exportable vars
 // exportable vars
 int shadow_resolution = 512;
 int shadow_resolution = 512;
-texture_t shadow_map;
+Texture shadow_map;
 
 
 
 
 /*
 /*
@@ -40,12 +40,12 @@ void Init()
 	fbo.Bind();
 	fbo.Bind();
 
 
 	// texture
 	// texture
-	shadow_map.CreateEmpty2D( shadow_resolution, shadow_resolution, GL_DEPTH_COMPONENT, GL_DEPTH_COMPONENT );
-	shadow_map.TexParameter( GL_TEXTURE_MIN_FILTER, GL_NEAREST );
-	if( bilinear ) shadow_map.TexParameter( GL_TEXTURE_MAG_FILTER, GL_LINEAR );
-	else           shadow_map.TexParameter( GL_TEXTURE_MAG_FILTER, GL_NEAREST );
-	shadow_map.TexParameter( GL_TEXTURE_COMPARE_MODE, GL_COMPARE_R_TO_TEXTURE );
-	shadow_map.TexParameter( GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL );
+	shadow_map.createEmpty2D( shadow_resolution, shadow_resolution, GL_DEPTH_COMPONENT, GL_DEPTH_COMPONENT );
+	shadow_map.texParameter( GL_TEXTURE_MIN_FILTER, GL_NEAREST );
+	if( bilinear ) shadow_map.texParameter( GL_TEXTURE_MAG_FILTER, GL_LINEAR );
+	else           shadow_map.texParameter( GL_TEXTURE_MAG_FILTER, GL_NEAREST );
+	shadow_map.texParameter( GL_TEXTURE_COMPARE_MODE, GL_COMPARE_R_TO_TEXTURE );
+	shadow_map.texParameter( GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL );
 	/// If you dont want to use the FFP for comparing the shadwomap (the above two lines) then you can make the comparision inside the
 	/// If you dont want to use the FFP for comparing the shadwomap (the above two lines) then you can make the comparision inside the
 	/// glsl shader. The GL_LEQUAL means that: shadow = ( R <= Dt ) ? 1.0 : 0.0; . The R is given by: R = _tex_coord2.z/_tex_coord2.w;
 	/// glsl shader. The GL_LEQUAL means that: shadow = ( R <= Dt ) ? 1.0 : 0.0; . The R is given by: R = _tex_coord2.z/_tex_coord2.w;
 	/// and the Dt = shadow2D(shadow_depth_map, _shadow_uv ).r (see lp_generic.frag). Hardware filters like GL_LINEAR cannot be applied.
 	/// and the Dt = shadow2D(shadow_depth_map, _shadow_uv ).r (see lp_generic.frag). Hardware filters like GL_LINEAR cannot be applied.
@@ -54,7 +54,7 @@ void Init()
 	fbo.SetNumOfColorAttachements(0);
 	fbo.SetNumOfColorAttachements(0);
 
 
 	// attach the texture
 	// attach the texture
-	glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, shadow_map.GetGLID(), 0 );
+	glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, shadow_map.getGlId(), 0 );
 
 
 	// test if success
 	// test if success
 	if( !fbo.IsGood() )
 	if( !fbo.IsGood() )
@@ -64,9 +64,9 @@ void Init()
 	fbo.Unbind();
 	fbo.Unbind();
 
 
 	// shaders
 	// 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" );
+	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" );
 }
 }
 
 
 
 
@@ -109,9 +109,9 @@ void RunPass( const camera_t& cam )
 
 
 		DEBUG_ERR( mesh_node->material->dp_mtl == NULL );
 		DEBUG_ERR( mesh_node->material->dp_mtl == NULL );
 
 
-		//mesh_node->material->dp_mtl->Setup();
+		//mesh_node->material->dp_mtl->setup();
 		//mesh_node->RenderDepth();
 		//mesh_node->RenderDepth();
-		mesh_node->material->Setup();
+		mesh_node->material->setup();
 		mesh_node->Render();
 		mesh_node->Render();
 	}
 	}
 
 

+ 15 - 15
src/renderer/r_ms.cpp

@@ -5,10 +5,10 @@
 #include "renderer.h"
 #include "renderer.h"
 #include "camera.h"
 #include "camera.h"
 #include "scene.h"
 #include "scene.h"
-#include "mesh.h"
+#include "Mesh.h"
 #include "r_private.h"
 #include "r_private.h"
 #include "fbo.h"
 #include "fbo.h"
-#include "material.h"
+#include "Material.h"
 #include "mesh_node.h"
 #include "mesh_node.h"
 
 
 
 
@@ -23,7 +23,7 @@ VARS
 */
 */
 static fbo_t fbo;
 static fbo_t fbo;
 
 
-texture_t normal_fai, diffuse_fai, specular_fai, depth_fai;
+Texture normal_fai, diffuse_fai, specular_fai, depth_fai;
 
 
 
 
 
 
@@ -41,26 +41,26 @@ void Init()
 
 
 	// create the FAIs
 	// create the FAIs
 	const int internal_format = GL_RGBA16F_ARB;
 	const int internal_format = GL_RGBA16F_ARB;
-	if( !normal_fai.CreateEmpty2D( r::w, r::h, internal_format, GL_RGBA ) ||
-	    !diffuse_fai.CreateEmpty2D( r::w, r::h, internal_format, GL_RGBA ) ||
-	    !specular_fai.CreateEmpty2D( r::w, r::h, internal_format, GL_RGBA ) ||
-	    !depth_fai.CreateEmpty2D( r::w, r::h, GL_DEPTH24_STENCIL8_EXT, GL_DEPTH_STENCIL_EXT, GL_UNSIGNED_INT_24_8_EXT ) )
+	if( !normal_fai.createEmpty2D( r::w, r::h, internal_format, GL_RGBA ) ||
+	    !diffuse_fai.createEmpty2D( r::w, r::h, internal_format, GL_RGBA ) ||
+	    !specular_fai.createEmpty2D( r::w, r::h, internal_format, GL_RGBA ) ||
+	    !depth_fai.createEmpty2D( r::w, r::h, GL_DEPTH24_STENCIL8_EXT, GL_DEPTH_STENCIL_EXT, GL_UNSIGNED_INT_24_8_EXT ) )
 	{
 	{
 		FATAL( "See prev error" );
 		FATAL( "See prev error" );
 	}
 	}
 
 
 	
 	
 	// you could use the above for SSAO but the difference is very little.
 	// you could use the above for SSAO but the difference is very little.
-	//depth_fai.TexParameter( GL_TEXTURE_MAG_FILTER, GL_LINEAR );
-	//depth_fai.TexParameter( GL_TEXTURE_MIN_FILTER, GL_LINEAR );
+	//depth_fai.texParameter( GL_TEXTURE_MAG_FILTER, GL_LINEAR );
+	//depth_fai.texParameter( GL_TEXTURE_MIN_FILTER, GL_LINEAR );
 
 
 	// attach the buffers to the FBO
 	// attach the buffers to the FBO
-	glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, normal_fai.GetGLID(), 0 );
-	glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT1_EXT, GL_TEXTURE_2D, diffuse_fai.GetGLID(), 0 );
-	glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT2_EXT, GL_TEXTURE_2D, specular_fai.GetGLID(), 0 );
+	glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, normal_fai.getGlId(), 0 );
+	glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT1_EXT, GL_TEXTURE_2D, diffuse_fai.getGlId(), 0 );
+	glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT2_EXT, GL_TEXTURE_2D, specular_fai.getGlId(), 0 );
 
 
-	glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, depth_fai.GetGLID(), 0 );
-	glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, GL_TEXTURE_2D, depth_fai.GetGLID(), 0 );
+	glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, depth_fai.getGlId(), 0 );
+	glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, GL_TEXTURE_2D, depth_fai.getGlId(), 0 );
 
 
 	// test if success
 	// test if success
 	if( !fbo.IsGood() )
 	if( !fbo.IsGood() )
@@ -108,7 +108,7 @@ void RunStage( const camera_t& cam )
 		mesh_node_t* mesh_node = scene::mesh_nodes[i];
 		mesh_node_t* mesh_node = scene::mesh_nodes[i];
 		DEBUG_ERR( mesh_node->material == NULL );
 		DEBUG_ERR( mesh_node->material == NULL );
 		if( mesh_node->material->blends || mesh_node->material->refracts ) continue;
 		if( mesh_node->material->blends || mesh_node->material->refracts ) continue;
-		mesh_node->material->Setup();
+		mesh_node->material->setup();
 		mesh_node->Render();
 		mesh_node->Render();
 	}
 	}
 
 

+ 11 - 11
src/renderer/r_ms_earlyz.cpp

@@ -3,8 +3,8 @@ The file contains functions and vars used for the deferred shading/material stag
 */
 */
 
 
 #include "renderer.h"
 #include "renderer.h"
-#include "resource.h"
-#include "texture.h"
+#include "Resource.h"
+#include "Texture.h"
 #include "scene.h"
 #include "scene.h"
 #include "r_private.h"
 #include "r_private.h"
 #include "fbo.h"
 #include "fbo.h"
@@ -23,7 +23,7 @@ VARS
 */
 */
 static fbo_t fbo;
 static fbo_t fbo;
 
 
-static shader_prog_t* shdr_dp, * shdr_dp_grass; // passes for solid objects and grass-like
+static ShaderProg* shdr_dp, * shdr_dp_grass; // passes for solid objects and grass-like
 
 
 
 
 /*
 /*
@@ -35,24 +35,24 @@ void Init()
 {
 {
 	// create FBO
 	// create FBO
 	fbo.Create();
 	fbo.Create();
-	fbo.Bind();
+	fbo.bind();
 
 
 	// inform the we wont write to color buffers
 	// inform the we wont write to color buffers
 	fbo.SetNumOfColorAttachements(0);
 	fbo.SetNumOfColorAttachements(0);
 
 
 	// attach the texture
 	// attach the texture
-	glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, r::ms::depth_fai.gl_id, 0 );
+	glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, r::ms::depth_fai.glId, 0 );
 
 
 	// test if success
 	// test if success
 	if( !fbo.CheckStatus() )
 	if( !fbo.CheckStatus() )
 		FATAL( "Cannot create earlyZ FBO" );
 		FATAL( "Cannot create earlyZ FBO" );
 
 
 	// unbind
 	// unbind
-	fbo.Unbind();
+	fbo.unbind();
 
 
 	// shaders
 	// shaders
-	shdr_dp = rsrc::shaders.Load( "shaders/dp.glsl" );
-	shdr_dp_grass = rsrc::shaders.Load( "shaders/dp_grass.glsl" );
+	shdr_dp = rsrc::shaders.load( "shaders/dp.glsl" );
+	shdr_dp_grass = rsrc::shaders.load( "shaders/dp_grass.glsl" );
 }
 }
 
 
 
 
@@ -64,7 +64,7 @@ RunPass
 void RunPass( const camera_t& cam )
 void RunPass( const camera_t& cam )
 {
 {
 	/*// FBO
 	/*// FBO
-	fbo.Bind();
+	fbo.bind();
 
 
 	// matrix
 	// matrix
 	glClear( GL_DEPTH_BUFFER_BIT );
 	glClear( GL_DEPTH_BUFFER_BIT );
@@ -79,7 +79,7 @@ void RunPass( const camera_t& cam )
 
 
 	// render all meshes
 	// render all meshes
 	for( uint i=0; i<scene::meshes.size(); i++ )
 	for( uint i=0; i<scene::meshes.size(); i++ )
-		RenderDepth<mesh_t>( *scene::meshes[i], shdr_dp, shdr_dp_grass );
+		RenderDepth<Mesh>( *scene::meshes[i], shdr_dp, shdr_dp_grass );
 
 
 	// render all smodels
 	// render all smodels
 	for( uint i=0; i<scene::models.size(); i++ )
 	for( uint i=0; i<scene::models.size(); i++ )
@@ -88,7 +88,7 @@ void RunPass( const camera_t& cam )
 	glColorMask( true, true, true, true );
 	glColorMask( true, true, true, true );
 
 
 	// end
 	// end
-	fbo.Unbind();*/
+	fbo.unbind();*/
 }
 }
 
 
 
 

+ 22 - 22
src/renderer/r_pps.cpp

@@ -1,6 +1,6 @@
 #include "renderer.h"
 #include "renderer.h"
-#include "resource.h"
-#include "texture.h"
+#include "Resource.h"
+#include "Texture.h"
 #include "r_private.h"
 #include "r_private.h"
 #include "fbo.h"
 #include "fbo.h"
 
 
@@ -19,10 +19,10 @@ VARS
 
 
 static fbo_t fbo; // yet another FBO
 static fbo_t fbo; // yet another FBO
 
 
-texture_t fai;
+Texture fai;
 
 
 // shader stuff
 // shader stuff
-static shader_prog_t* shdr_post_proc_stage;
+static ShaderProg* shdr_post_proc_stage;
 
 
 namespace shdr_vars
 namespace shdr_vars
 {
 {
@@ -49,10 +49,10 @@ void Init()
 	fbo.SetNumOfColorAttachements(1);
 	fbo.SetNumOfColorAttachements(1);
 
 
 	// create the texes
 	// create the texes
-	fai.CreateEmpty2D( r::w, r::h, GL_RGB, GL_RGB );
+	fai.createEmpty2D( r::w, r::h, GL_RGB, GL_RGB );
 
 
 	// attach
 	// attach
-	glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, fai.GetGLID(), 0 );
+	glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, fai.getGlId(), 0 );
 
 
 	// test if success
 	// test if success
 	if( !fbo.IsGood() )
 	if( !fbo.IsGood() )
@@ -62,30 +62,30 @@ void Init()
 
 
 
 
 	// init the shader and it's vars
 	// init the shader and it's vars
-	shdr_post_proc_stage = rsrc::shaders.Load( "shaders/pps.glsl" );
-	shdr_post_proc_stage->Bind();
+	shdr_post_proc_stage = rsrc::shaders.load( "shaders/pps.glsl" );
+	shdr_post_proc_stage->bind();
 
 
-	shdr_vars::is_fai = shdr_post_proc_stage->GetUniformLocation( "is_fai" );
+	shdr_vars::is_fai = shdr_post_proc_stage->getUniLoc( "is_fai" );
 
 
 	if( r::pps::ssao::enabled )
 	if( r::pps::ssao::enabled )
 	{
 	{
 		r::pps::ssao::Init();
 		r::pps::ssao::Init();
-		shdr_vars::pps_ssao_fai = shdr_post_proc_stage->GetUniformLocation( "pps_ssao_fai" );
+		shdr_vars::pps_ssao_fai = shdr_post_proc_stage->getUniLoc( "pps_ssao_fai" );
 	}
 	}
 
 
 	if( r::pps::hdr::enabled )
 	if( r::pps::hdr::enabled )
 	{
 	{
 		r::pps::hdr::Init();
 		r::pps::hdr::Init();
-		shdr_vars::hdr_fai = shdr_post_proc_stage->GetUniformLocation( "pps_hdr_fai" );
+		shdr_vars::hdr_fai = shdr_post_proc_stage->getUniLoc( "pps_hdr_fai" );
 	}
 	}
 
 
 	if( r::pps::edgeaa::enabled )
 	if( r::pps::edgeaa::enabled )
-		shdr_vars::ms_normal_fai = shdr_post_proc_stage->GetUniformLocation( "ms_normal_fai" );
+		shdr_vars::ms_normal_fai = shdr_post_proc_stage->getUniLoc( "ms_normal_fai" );
 
 
 	if( r::pps::lscatt::enabled )
 	if( r::pps::lscatt::enabled )
 	{
 	{
 		r::pps::lscatt::Init();
 		r::pps::lscatt::Init();
-		shdr_vars::lscatt_fai = shdr_post_proc_stage->GetUniformLocation( "pps_lscatt_fai" );
+		shdr_vars::lscatt_fai = shdr_post_proc_stage->getUniLoc( "pps_lscatt_fai" );
 	}
 	}
 
 
 }
 }
@@ -116,40 +116,40 @@ void RunStage( const camera_t& cam )
 	r::SetViewport( 0, 0, r::w, r::h );
 	r::SetViewport( 0, 0, r::w, r::h );
 
 
 	// set shader
 	// set shader
-	shdr_post_proc_stage->Bind();
+	shdr_post_proc_stage->bind();
 
 
-	r::is::fai.Bind(0);
-	//r::ms::depth_fai.Bind(0);
+	r::is::fai.bind(0);
+	//r::ms::depth_fai.bind(0);
 	glUniform1i( shdr_vars::is_fai, 0 );
 	glUniform1i( shdr_vars::is_fai, 0 );
 
 
 	if( r::pps::ssao::enabled )
 	if( r::pps::ssao::enabled )
 	{
 	{
-		r::pps::ssao::blured_fai.Bind(1);
+		r::pps::ssao::blured_fai.bind(1);
 		glUniform1i( shdr_vars::pps_ssao_fai, 1 );
 		glUniform1i( shdr_vars::pps_ssao_fai, 1 );
 	}
 	}
 
 
 	if( r::pps::edgeaa::enabled )
 	if( r::pps::edgeaa::enabled )
 	{
 	{
-		r::ms::normal_fai.Bind(2);
+		r::ms::normal_fai.bind(2);
 		glUniform1i( shdr_vars::ms_normal_fai, 2 );
 		glUniform1i( shdr_vars::ms_normal_fai, 2 );
 	}
 	}
 
 
 	if( r::pps::hdr::enabled )
 	if( r::pps::hdr::enabled )
 	{
 	{
-		r::pps::hdr::pass2_fai.Bind(3);
-		//r::bs::r_fai.Bind(3);
+		r::pps::hdr::pass2_fai.bind(3);
+		//r::bs::r_fai.bind(3);
 		glUniform1i( shdr_vars::hdr_fai, 3 );
 		glUniform1i( shdr_vars::hdr_fai, 3 );
 	}
 	}
 
 
 	if( r::pps::lscatt::enabled )
 	if( r::pps::lscatt::enabled )
 	{
 	{
-		r::pps::lscatt::fai.Bind(4);
+		r::pps::lscatt::fai.bind(4);
 		glUniform1i( shdr_vars::lscatt_fai, 4 );
 		glUniform1i( shdr_vars::lscatt_fai, 4 );
 	}
 	}
 
 
 
 
 	// draw quad
 	// draw quad
-	r::DrawQuad( shdr_post_proc_stage->GetAttributeLocation(0) );
+	r::DrawQuad( shdr_post_proc_stage->getAttribLoc(0) );
 
 
 	// unbind FBO
 	// unbind FBO
 	fbo.Unbind();
 	fbo.Unbind();

+ 23 - 23
src/renderer/r_pps_hdr.cpp

@@ -3,8 +3,8 @@ The file contains functions and vars used for the deferred shading/post-processi
 */
 */
 
 
 #include "renderer.h"
 #include "renderer.h"
-#include "resource.h"
-#include "texture.h"
+#include "Resource.h"
+#include "Texture.h"
 #include "scene.h"
 #include "scene.h"
 #include "r_private.h"
 #include "r_private.h"
 #include "fbo.h"
 #include "fbo.h"
@@ -27,11 +27,11 @@ float rendering_quality = 0.25; // 1/4 of the image
 static uint wwidth, wheight; // render width and height
 static uint wwidth, wheight; // render width and height
 
 
 // hdr images
 // hdr images
-texture_t pass0_fai; // for vertical blur pass
-texture_t pass1_fai; // with the horizontal blur
-texture_t pass2_fai;
+Texture pass0_fai; // for vertical blur pass
+Texture pass1_fai; // with the horizontal blur
+Texture pass2_fai;
 
 
-static shader_prog_t* pass0_shdr, * pass1_shdr, * pass2_shdr; // hdr pass 0 and pass 1 shaders
+static ShaderProg* pass0_shdr, * pass1_shdr, * pass2_shdr; // hdr pass 0 and pass 1 shaders
 
 
 
 
 /*
 /*
@@ -39,7 +39,7 @@ static shader_prog_t* pass0_shdr, * pass1_shdr, * pass2_shdr; // hdr pass 0 and
 InitFBOs                                                                                                                              =
 InitFBOs                                                                                                                              =
 =======================================================================================================================================
 =======================================================================================================================================
 */
 */
-static void InitFBOs( fbo_t& fbo, texture_t& fai, int internal_format )
+static void InitFBOs( fbo_t& fbo, Texture& fai, int internal_format )
 {
 {
 	// create FBO
 	// create FBO
 	fbo.Create();
 	fbo.Create();
@@ -49,12 +49,12 @@ static void InitFBOs( fbo_t& fbo, texture_t& fai, int internal_format )
 	fbo.SetNumOfColorAttachements(1);
 	fbo.SetNumOfColorAttachements(1);
 
 
 	// create the texes
 	// create the texes
-	fai.CreateEmpty2D( wwidth, wheight, internal_format, GL_RGB );
-	fai.TexParameter( GL_TEXTURE_MAG_FILTER, GL_LINEAR );
-	fai.TexParameter( GL_TEXTURE_MIN_FILTER, GL_NEAREST );
+	fai.createEmpty2D( wwidth, wheight, internal_format, GL_RGB );
+	fai.texParameter( GL_TEXTURE_MAG_FILTER, GL_LINEAR );
+	fai.texParameter( GL_TEXTURE_MIN_FILTER, GL_NEAREST );
 
 
 	// attach
 	// attach
-	glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, fai.GetGLID(), 0 );
+	glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, fai.getGlId(), 0 );
 
 
 	// test if success
 	// test if success
 	if( !fbo.IsGood() )
 	if( !fbo.IsGood() )
@@ -80,9 +80,9 @@ void Init()
 	InitFBOs( pass2_fbo, pass2_fai, GL_RGB );
 	InitFBOs( pass2_fbo, pass2_fai, GL_RGB );
 
 
 	// init shaders
 	// 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" );
+	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" );
 }
 }
 
 
 
 
@@ -102,34 +102,34 @@ void RunPass( const camera_t& /*cam*/ )
 	// pass 0
 	// pass 0
 	pass0_fbo.Bind();
 	pass0_fbo.Bind();
 
 
-	pass0_shdr->Bind();
+	pass0_shdr->bind();
 
 
-	pass0_shdr->LocTexUnit( pass0_shdr->GetUniformLocation(0), r::is::fai, 0 );
+	pass0_shdr->locTexUnit( pass0_shdr->GetUniLoc(0), r::is::fai, 0 );
 
 
 	// Draw quad
 	// Draw quad
-	r::DrawQuad( pass0_shdr->GetAttributeLocation(0) );
+	r::DrawQuad( pass0_shdr->getAttribLoc(0) );
 
 
 
 
 	// pass 1
 	// pass 1
 	pass1_fbo.Bind();
 	pass1_fbo.Bind();
 
 
-	pass1_shdr->Bind();
+	pass1_shdr->bind();
 
 
-	pass1_shdr->LocTexUnit( pass1_shdr->GetUniformLocation(0), pass0_fai, 0 );
+	pass1_shdr->locTexUnit( pass1_shdr->GetUniLoc(0), pass0_fai, 0 );
 
 
 	// Draw quad
 	// Draw quad
-	r::DrawQuad( pass1_shdr->GetAttributeLocation(0) );
+	r::DrawQuad( pass1_shdr->getAttribLoc(0) );
 
 
 
 
 	// pass 2
 	// pass 2
 	pass2_fbo.Bind();
 	pass2_fbo.Bind();
 
 
-	pass2_shdr->Bind();
+	pass2_shdr->bind();
 
 
-	pass2_shdr->LocTexUnit( pass2_shdr->GetUniformLocation(0), pass1_fai, 0 );
+	pass2_shdr->locTexUnit( pass2_shdr->GetUniLoc(0), pass1_fai, 0 );
 
 
 	// Draw quad
 	// Draw quad
-	r::DrawQuad( pass2_shdr->GetAttributeLocation(0) );
+	r::DrawQuad( pass2_shdr->getAttribLoc(0) );
 
 
 	// end
 	// end
 	fbo_t::Unbind();
 	fbo_t::Unbind();

+ 16 - 16
src/renderer/r_pps_lscatt.cpp

@@ -1,6 +1,6 @@
 #include "renderer.h"
 #include "renderer.h"
-#include "resource.h"
-#include "texture.h"
+#include "Resource.h"
+#include "Texture.h"
 #include "scene.h"
 #include "scene.h"
 #include "r_private.h"
 #include "r_private.h"
 #include "fbo.h"
 #include "fbo.h"
@@ -20,9 +20,9 @@ static fbo_t fbo; // yet another FBO
 float rendering_quality = 1.0;
 float rendering_quality = 1.0;
 bool enabled = false;
 bool enabled = false;
 
 
-texture_t fai;
+Texture fai;
 
 
-static shader_prog_t* shdr;
+static ShaderProg* shdr;
 static int ms_depth_fai_uni_loc;
 static int ms_depth_fai_uni_loc;
 static int is_fai_uni_loc;
 static int is_fai_uni_loc;
 
 
@@ -46,12 +46,12 @@ void Init()
 	fbo.SetNumOfColorAttachements(1);
 	fbo.SetNumOfColorAttachements(1);
 
 
 	// create the texes
 	// create the texes
-	fai.CreateEmpty2D( wwidth, wheight, GL_RGB, GL_RGB );
-	fai.TexParameter( GL_TEXTURE_MAG_FILTER, GL_LINEAR );
-	fai.TexParameter( GL_TEXTURE_MIN_FILTER, GL_LINEAR );
+	fai.createEmpty2D( wwidth, wheight, GL_RGB, GL_RGB );
+	fai.texParameter( GL_TEXTURE_MAG_FILTER, GL_LINEAR );
+	fai.texParameter( GL_TEXTURE_MIN_FILTER, GL_LINEAR );
 
 
 	// attach
 	// attach
-	glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, fai.GetGLID(), 0 );
+	glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, fai.getGlId(), 0 );
 
 
 	// test if success
 	// test if success
 	if( !fbo.IsGood() )
 	if( !fbo.IsGood() )
@@ -62,9 +62,9 @@ void Init()
 
 
 
 
 	// init shaders
 	// init shaders
-	shdr = rsrc::shaders.Load( "shaders/pps_lscatt.glsl" );
-	ms_depth_fai_uni_loc = shdr->GetUniformLocation( "ms_depth_fai" );
-	is_fai_uni_loc = shdr->GetUniformLocation( "is_fai" );
+	shdr = rsrc::shaders.load( "shaders/pps_lscatt.glsl" );
+	ms_depth_fai_uni_loc = shdr->getUniLoc( "ms_depth_fai" );
+	is_fai_uni_loc = shdr->getUniLoc( "is_fai" );
 }
 }
 
 
 
 
@@ -83,20 +83,20 @@ void RunPass( const camera_t& cam )
 	glDisable( GL_DEPTH_TEST );
 	glDisable( GL_DEPTH_TEST );
 
 
 	// set the shader
 	// set the shader
-	shdr->Bind();
+	shdr->bind();
 
 
-	shdr->LocTexUnit( ms_depth_fai_uni_loc, r::ms::depth_fai, 0 );
-	shdr->LocTexUnit( is_fai_uni_loc, r::is::fai, 1 );
+	shdr->locTexUnit( ms_depth_fai_uni_loc, r::ms::depth_fai, 0 );
+	shdr->locTexUnit( is_fai_uni_loc, r::is::fai, 1 );
 
 
 	// pass the light
 	// pass the light
 	vec4_t p = vec4_t( scene::SunPos(), 1.0 );
 	vec4_t p = vec4_t( scene::SunPos(), 1.0 );
 	p = cam.GetProjectionMatrix() * (cam.GetViewMatrix() * p);
 	p = cam.GetProjectionMatrix() * (cam.GetViewMatrix() * p);
 	p /= p.w;
 	p /= p.w;
 	p = p/2 + 0.5;
 	p = p/2 + 0.5;
-	glUniform2fv( shdr->GetUniformLocation("light_pos_screen_space"), 1, &p[0] );
+	glUniform2fv( shdr->getUniLoc("light_pos_screen_space"), 1, &p[0] );
 
 
 	// Draw quad
 	// Draw quad
-	r::DrawQuad( shdr->GetAttributeLocation(0) );
+	r::DrawQuad( shdr->getAttribLoc(0) );
 
 
 	// end
 	// end
 	fbo.Unbind();
 	fbo.Unbind();

+ 29 - 29
src/renderer/r_pps_ssao.cpp

@@ -3,8 +3,8 @@ The file contains functions and vars used for the deferred shading/post-processi
 */
 */
 
 
 #include "renderer.h"
 #include "renderer.h"
-#include "resource.h"
-#include "texture.h"
+#include "Resource.h"
+#include "Texture.h"
 #include "scene.h"
 #include "scene.h"
 #include "r_private.h"
 #include "r_private.h"
 #include "fbo.h"
 #include "fbo.h"
@@ -27,11 +27,11 @@ bool enabled = true;
 
 
 static uint wwidth, wheight; // window width and height
 static uint wwidth, wheight; // window width and height
 
 
-texture_t fai, blured_fai; // SSAO factor
+Texture fai, blured_fai; // SSAO factor
 
 
-static shader_prog_t* shdr_ppp_ssao, * blur_shdr;
+static ShaderProg* shdr_ppp_ssao, * blur_shdr;
 
 
-static texture_t* noise_map;
+static Texture* noise_map;
 
 
 
 
 //=====================================================================================================================================
 //=====================================================================================================================================
@@ -47,12 +47,12 @@ static void InitBlurFBO()
 	blur_fbo.SetNumOfColorAttachements(1);
 	blur_fbo.SetNumOfColorAttachements(1);
 
 
 	// create the texes
 	// create the texes
-	blured_fai.CreateEmpty2D( wwidth, wheight, GL_ALPHA8, GL_ALPHA );
-	blured_fai.TexParameter( GL_TEXTURE_MAG_FILTER, GL_LINEAR );
-	blured_fai.TexParameter( GL_TEXTURE_MIN_FILTER, GL_NEAREST );
+	blured_fai.createEmpty2D( wwidth, wheight, GL_ALPHA8, GL_ALPHA );
+	blured_fai.texParameter( GL_TEXTURE_MAG_FILTER, GL_LINEAR );
+	blured_fai.texParameter( GL_TEXTURE_MIN_FILTER, GL_NEAREST );
 
 
 	// attach
 	// attach
-	glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, blured_fai.GetGLID(), 0 );
+	glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, blured_fai.getGlId(), 0 );
 
 
 	// test if success
 	// test if success
 	if( !blur_fbo.IsGood() )
 	if( !blur_fbo.IsGood() )
@@ -82,12 +82,12 @@ void Init()
 	fbo.SetNumOfColorAttachements(1);
 	fbo.SetNumOfColorAttachements(1);
 
 
 	// create the texes
 	// create the texes
-	fai.CreateEmpty2D( wwidth, wheight, GL_ALPHA8, GL_ALPHA );
-	fai.TexParameter( GL_TEXTURE_MAG_FILTER, GL_NEAREST );
-	fai.TexParameter( GL_TEXTURE_MIN_FILTER, GL_NEAREST );
+	fai.createEmpty2D( wwidth, wheight, GL_ALPHA8, GL_ALPHA );
+	fai.texParameter( GL_TEXTURE_MAG_FILTER, GL_NEAREST );
+	fai.texParameter( GL_TEXTURE_MIN_FILTER, GL_NEAREST );
 
 
 	// attach
 	// attach
-	glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, fai.GetGLID(), 0 );
+	glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, fai.getGlId(), 0 );
 
 
 	// test if success
 	// test if success
 	if( !fbo.IsGood() )
 	if( !fbo.IsGood() )
@@ -98,24 +98,24 @@ void Init()
 
 
 
 
 	// init shaders
 	// init shaders
-	shdr_ppp_ssao = rsrc::shaders.Load( "shaders/pps_ssao.glsl" );
+	shdr_ppp_ssao = rsrc::shaders.load( "shaders/pps_ssao.glsl" );
 
 
 	// load noise map and disable temporaly the texture compression and enable mipmaping
 	// load noise map and disable temporaly the texture compression and enable mipmaping
 	bool tex_compr = r::texture_compression;
 	bool tex_compr = r::texture_compression;
 	bool mipmaping = r::mipmaping;
 	bool mipmaping = r::mipmaping;
 	r::texture_compression = false;
 	r::texture_compression = false;
 	r::mipmaping = true;
 	r::mipmaping = true;
-	noise_map = rsrc::textures.Load( "gfx/noise3.tga" );
-	noise_map->TexParameter( GL_TEXTURE_WRAP_S, GL_REPEAT );
-	noise_map->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 );
+	noise_map = rsrc::textures.load( "gfx/noise3.tga" );
+	noise_map->texParameter( GL_TEXTURE_WRAP_S, GL_REPEAT );
+	noise_map->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 );
 	r::texture_compression = tex_compr;
 	r::texture_compression = tex_compr;
 	r::mipmaping = mipmaping;
 	r::mipmaping = mipmaping;
 
 
 	// blur FBO
 	// blur FBO
 	InitBlurFBO();
 	InitBlurFBO();
-	blur_shdr = rsrc::shaders.Load( "shaders/pps_ssao_blur.glsl" );
+	blur_shdr = rsrc::shaders.load( "shaders/pps_ssao_blur.glsl" );
 }
 }
 
 
 
 
@@ -134,19 +134,19 @@ void RunPass( const camera_t& cam )
 	glDisable( GL_DEPTH_TEST );
 	glDisable( GL_DEPTH_TEST );
 
 
 	// fill SSAO FAI
 	// fill SSAO FAI
-	shdr_ppp_ssao->Bind();
-	glUniform2fv( shdr_ppp_ssao->GetUniformLocation(0), 1, &(vec2_t(cam.GetZNear(), cam.GetZFar()))[0] );
-	shdr_ppp_ssao->LocTexUnit( shdr_ppp_ssao->GetUniformLocation(1), ms::depth_fai, 0 );
-	shdr_ppp_ssao->LocTexUnit( shdr_ppp_ssao->GetUniformLocation(2), *noise_map, 1 );
-	shdr_ppp_ssao->LocTexUnit( shdr_ppp_ssao->GetUniformLocation(3), ms::normal_fai, 2 );
-	r::DrawQuad( shdr_ppp_ssao->GetAttributeLocation(0) ); // Draw quad
+	shdr_ppp_ssao->bind();
+	glUniform2fv( shdr_ppp_ssao->GetUniLoc(0), 1, &(vec2_t(cam.GetZNear(), cam.GetZFar()))[0] );
+	shdr_ppp_ssao->locTexUnit( shdr_ppp_ssao->GetUniLoc(1), ms::depth_fai, 0 );
+	shdr_ppp_ssao->locTexUnit( shdr_ppp_ssao->GetUniLoc(2), *noise_map, 1 );
+	shdr_ppp_ssao->locTexUnit( shdr_ppp_ssao->GetUniLoc(3), ms::normal_fai, 2 );
+	r::DrawQuad( shdr_ppp_ssao->getAttribLoc(0) ); // Draw quad
 
 
 
 
 	// second pass. blur
 	// second pass. blur
 	blur_fbo.Bind();
 	blur_fbo.Bind();
-	blur_shdr->Bind();
-	blur_shdr->LocTexUnit( blur_shdr->GetUniformLocation(0), fai, 0 );
-	r::DrawQuad( blur_shdr->GetAttributeLocation(0) ); // Draw quad
+	blur_shdr->bind();
+	blur_shdr->locTexUnit( blur_shdr->GetUniLoc(0), fai, 0 );
+	r::DrawQuad( blur_shdr->getAttribLoc(0) ); // Draw quad
 
 
 	// end
 	// end
 	fbo_t::Unbind();
 	fbo_t::Unbind();

+ 21 - 21
src/renderer/r_private.h

@@ -4,7 +4,7 @@ The file contains some externs of funcs and vars that no one else needs to know
 #ifndef _R_PRIVATE_H_
 #ifndef _R_PRIVATE_H_
 #define _R_PRIVATE_H_
 #define _R_PRIVATE_H_
 
 
-class texture_t;
+class Texture;
 class camera_t;
 class camera_t;
 
 
 namespace r {
 namespace r {
@@ -16,14 +16,14 @@ externs
 =======================================================================================================================================
 =======================================================================================================================================
 */
 */
 
 
-extern void DrawQuad( int vert_coords_uni_loc );
+extern void DrawQuad( int vertCoords_uni_loc );
 extern float quad_vert_cords [][2];
 extern float quad_vert_cords [][2];
 
 
 namespace ms
 namespace ms
 {
 {
 	extern void Init();
 	extern void Init();
 	extern void RunStage( const camera_t& cam );
 	extern void RunStage( const camera_t& cam );
-	extern texture_t normal_fai, diffuse_fai, specular_fai, depth_fai;
+	extern Texture normal_fai, diffuse_fai, specular_fai, depth_fai;
 	const int fbo_attachable_imgs_num = 4;
 	const int fbo_attachable_imgs_num = 4;
 
 
 #if defined( _EARLY_Z_ )
 #if defined( _EARLY_Z_ )
@@ -44,7 +44,7 @@ namespace is
 
 
 	namespace shadows
 	namespace shadows
 	{
 	{
-		extern texture_t shadow_map;
+		extern Texture shadow_map;
 		extern int shadow_resolution;
 		extern int shadow_resolution;
 		extern void RunPass( const camera_t& cam );
 		extern void RunPass( const camera_t& cam );
 		extern void Init();
 		extern void Init();
@@ -61,8 +61,8 @@ namespace pps
 	{
 	{
 		extern void Init();
 		extern void Init();
 		extern void RunPass( const camera_t& cam );
 		extern void RunPass( const camera_t& cam );
-		extern texture_t fai;
-		extern texture_t blured_fai;
+		extern Texture fai;
+		extern Texture blured_fai;
 		extern float rendering_quality;
 		extern float rendering_quality;
 	}
 	}
 
 
@@ -70,9 +70,9 @@ namespace pps
 	{
 	{
 		extern void Init();
 		extern void Init();
 		extern void RunPass( const camera_t& cam );
 		extern void RunPass( const camera_t& cam );
-		extern texture_t pass0_fai;
-		extern texture_t pass1_fai;
-		extern texture_t pass2_fai;
+		extern Texture pass0_fai;
+		extern Texture pass1_fai;
+		extern Texture pass2_fai;
 		extern float rendering_quality;
 		extern float rendering_quality;
 	}
 	}
 
 
@@ -80,7 +80,7 @@ namespace pps
 	{
 	{
 		extern void Init();
 		extern void Init();
 		extern void RunPass( const camera_t& cam );
 		extern void RunPass( const camera_t& cam );
-		extern texture_t fai;
+		extern Texture fai;
 		extern float rendering_quality;
 		extern float rendering_quality;
 	}
 	}
 }
 }
@@ -90,9 +90,9 @@ namespace bs
 {
 {
 	extern void Init();
 	extern void Init();
 	extern void RunStage( const camera_t& cam );
 	extern void RunStage( const camera_t& cam );
-	extern texture_t fai_bs_scene;
+	extern Texture fai_bs_scene;
 
 
-	extern texture_t r_fai; // ToDo: remove it
+	extern Texture r_fai; // ToDo: remove it
 }
 }
 
 
 
 
@@ -115,14 +115,14 @@ and by r::is::shadow::RunStage. Used like macro
 @param the shader to bind if the t's material IS NOT a grass like material
 @param the shader to bind if the t's material IS NOT a grass like material
 @param the shader to bind if the t's material IS a grass like material
 @param the shader to bind if the t's material IS a grass like material
 */
 */
-template <typename type_t, bool make_check_for_shadow_casting>
-void RenderDepth( type_t& t )
+template <typename Type, bool make_check_for_shadow_casting>
+void RenderDepth( Type& t )
 {
 {
 	DEBUG_ERR( !t.material ); // the object doesnt have material
 	DEBUG_ERR( !t.material ); // the object doesnt have material
 
 
 	// casts shadow?
 	// casts shadow?
 	if( make_check_for_shadow_casting )
 	if( make_check_for_shadow_casting )
-		if( !t.material->casts_shadow ) return;
+		if( !t.material->castsShadow ) return;
 
 
 	// blends?
 	// blends?
 	if( t.material->blends ) return;
 	if( t.material->blends ) return;
@@ -130,16 +130,16 @@ void RenderDepth( type_t& t )
 	// chose the appropriate shader
 	// chose the appropriate shader
 	if( t.material->grass_map )
 	if( t.material->grass_map )
 	{
 	{
-		r::is::shadows::shdr_depth_grass->Bind();
-		r::is::shadows::shdr_depth_grass->LocTexUnit( r::is::shadows::shdr_depth_grass->GetUniformLocation(0), *t.material->grass_map, 0 );
+		r::is::shadows::shdr_depth_grass->bind();
+		r::is::shadows::shdr_depth_grass->locTexUnit( r::is::shadows::shdr_depth_grass->GetUniLoc(0), *t.material->grass_map, 0 );
 	}
 	}
-	else if( t.material->attrib_locs.vert_weight_bones_num != -1 )
+	else if( t.material->attrib_locs.vertWeightBonesNum != -1 )
 	{
 	{
-		r::is::shadows::shdr_depth_hw_skinning->Bind();
+		r::is::shadows::shdr_depth_hw_skinning->bind();
 	}
 	}
 	else
 	else
 	{
 	{
-		r::is::shadows::shdr_depth->Bind();
+		r::is::shadows::shdr_depth->bind();
 	}
 	}
 
 
 	// wireframe ?
 	// wireframe ?
@@ -162,7 +162,7 @@ void RenderDepth( type_t& t )
 // Render                                                                                                                             =
 // Render                                                                                                                             =
 //=====================================================================================================================================
 //=====================================================================================================================================
 /// The template function renders an entity. Used by r::ms::RunStage and r::bs::RunStage. Used like macro
 /// The template function renders an entity. Used by r::ms::RunStage and r::bs::RunStage. Used like macro
-template <typename type_t, bool render_transparent> void Render( type_t* t )
+template <typename Type, bool render_transparent> void Render( Type* t )
 {
 {
 	DEBUG_ERR( !t->material );
 	DEBUG_ERR( !t->material );
 
 

+ 19 - 19
src/renderer/renderer.cpp

@@ -2,7 +2,7 @@
 #include <stdio.h>
 #include <stdio.h>
 #include <jpeglib.h>
 #include <jpeglib.h>
 #include "renderer.h"
 #include "renderer.h"
-#include "texture.h"
+#include "Texture.h"
 #include "scene.h"
 #include "scene.h"
 #include "r_private.h"
 #include "r_private.h"
 #include "camera.h"
 #include "camera.h"
@@ -26,7 +26,7 @@ int max_color_atachments = 0;
 //float rendering_quality = 1.0;
 //float rendering_quality = 1.0;
 int screenshot_jpeg_quality = 90;
 int screenshot_jpeg_quality = 90;
 
 
-static shader_prog_t* shdr_final;
+static ShaderProg* shdr_final;
 
 
 // for the pps and is quad rendering
 // for the pps and is quad rendering
 float quad_vert_cords [][2] = { {1.0,1.0}, {0.0,1.0}, {0.0,0.0}, {1.0,0.0} };
 float quad_vert_cords [][2] = { {1.0,1.0}, {0.0,1.0}, {0.0,0.0}, {1.0,0.0} };
@@ -48,16 +48,16 @@ bool texture_compression = false;
 //=====================================================================================================================================
 //=====================================================================================================================================
 // DrawQuad                                                                                                                           =
 // DrawQuad                                                                                                                           =
 //=====================================================================================================================================
 //=====================================================================================================================================
-void DrawQuad( int vert_coords_uni_loc )
+void DrawQuad( int vertCoords_uni_loc )
 {
 {
 	/*glEnableClientState( GL_VERTEX_ARRAY );
 	/*glEnableClientState( GL_VERTEX_ARRAY );
 	glVertexPointer( 2, GL_FLOAT, 0, quad_vert_cords );
 	glVertexPointer( 2, GL_FLOAT, 0, quad_vert_cords );
 	glDrawArrays( GL_QUADS, 0, 4 );
 	glDrawArrays( GL_QUADS, 0, 4 );
 	glDisableClientState( GL_VERTEX_ARRAY );*/
 	glDisableClientState( GL_VERTEX_ARRAY );*/
-	glVertexAttribPointer( vert_coords_uni_loc, 2, GL_FLOAT, false, 0, quad_vert_cords );
-	glEnableVertexAttribArray( vert_coords_uni_loc );
+	glVertexAttribPointer( vertCoords_uni_loc, 2, GL_FLOAT, false, 0, quad_vert_cords );
+	glEnableVertexAttribArray( vertCoords_uni_loc );
 	glDrawArrays( GL_QUADS, 0, 4 );
 	glDrawArrays( GL_QUADS, 0, 4 );
-	glDisableVertexAttribArray( vert_coords_uni_loc );
+	glDisableVertexAttribArray( vertCoords_uni_loc );
 }
 }
 
 
 
 
@@ -166,7 +166,7 @@ void Init()
 	BuildStdShaderPreProcStr();
 	BuildStdShaderPreProcStr();
 
 
 	// misc
 	// misc
-	shdr_final = rsrc::shaders.Load( "shaders/final.glsl" );
+	shdr_final = rsrc::shaders.load( "shaders/final.glsl" );
 
 
 	// init deferred stages
 	// init deferred stages
 	// WARNING: the order of the inits is crucial!!!!!
 	// WARNING: the order of the inits is crucial!!!!!
@@ -201,29 +201,29 @@ void Render( const camera_t& cam )
 	glDisable( GL_DEPTH_TEST );
 	glDisable( GL_DEPTH_TEST );
 	glDisable( GL_BLEND );
 	glDisable( GL_BLEND );
 
 
-	shdr_final->Bind();
-	shdr_final->LocTexUnit( shdr_final->GetUniformLocation(0), r::pps::fai, 0 );
+	shdr_final->bind();
+	shdr_final->locTexUnit( shdr_final->GetUniLoc(0), r::pps::fai, 0 );
 
 
 	/*const int step = 100;
 	/*const int step = 100;
 	if( r::frames_num < step )
 	if( r::frames_num < step )
-		shdr_final->LocTexUnit( shdr_final->GetUniformLocation(0), r::ms::diffuse_fai, 0 );
+		shdr_final->locTexUnit( shdr_final->getUniLoc(0), r::ms::diffuse_fai, 0 );
 	else if( r::frames_num < step*2 )
 	else if( r::frames_num < step*2 )
-		shdr_final->LocTexUnit( shdr_final->GetUniformLocation(0), r::ms::normal_fai, 0 );
+		shdr_final->locTexUnit( shdr_final->getUniLoc(0), r::ms::normal_fai, 0 );
 	else if( r::frames_num < step*3 )
 	else if( r::frames_num < step*3 )
-		shdr_final->LocTexUnit( shdr_final->GetUniformLocation(0), r::ms::specular_fai, 0 );
+		shdr_final->locTexUnit( shdr_final->getUniLoc(0), r::ms::specular_fai, 0 );
 	else if( r::frames_num < step*4 )
 	else if( r::frames_num < step*4 )
-		shdr_final->LocTexUnit( shdr_final->GetUniformLocation(0), r::ms::depth_fai, 0 );
+		shdr_final->locTexUnit( shdr_final->getUniLoc(0), r::ms::depth_fai, 0 );
 	else if( r::frames_num < step*5 )
 	else if( r::frames_num < step*5 )
-		shdr_final->LocTexUnit( shdr_final->GetUniformLocation(0), r::pps::ssao::blured_fai, 0 );
+		shdr_final->locTexUnit( shdr_final->getUniLoc(0), r::pps::ssao::blured_fai, 0 );
 	else if( r::frames_num < step*6 )
 	else if( r::frames_num < step*6 )
 	{
 	{
-		shdr_final->LocTexUnit( shdr_final->GetUniformLocation(0), r::pps::hdr::pass2_fai, 0 );
+		shdr_final->locTexUnit( shdr_final->getUniLoc(0), r::pps::hdr::pass2_fai, 0 );
 	}
 	}
 	else
 	else
-		shdr_final->LocTexUnit( shdr_final->GetUniformLocation(0), r::pps::fai, 0 );*/
+		shdr_final->locTexUnit( shdr_final->getUniLoc(0), r::pps::fai, 0 );*/
 
 
 
 
-	r::DrawQuad( shdr_final->GetAttributeLocation(0) );
+	r::DrawQuad( shdr_final->getAttribLoc(0) );
 }
 }
 
 
 
 
@@ -235,7 +235,7 @@ SetProjectionMatrix
 void SetProjectionMatrix( const camera_t& cam )
 void SetProjectionMatrix( const camera_t& cam )
 {
 {
 	glMatrixMode( GL_PROJECTION );
 	glMatrixMode( GL_PROJECTION );
-	LoadMatrix( cam.GetProjectionMatrix() );
+	loadMatrix( cam.GetProjectionMatrix() );
 }
 }
 
 
 
 
@@ -247,7 +247,7 @@ SetViewMatrix
 void SetViewMatrix( const camera_t& cam )
 void SetViewMatrix( const camera_t& cam )
 {
 {
 	glMatrixMode( GL_MODELVIEW );
 	glMatrixMode( GL_MODELVIEW );
-	LoadMatrix( cam.GetViewMatrix() );
+	loadMatrix( cam.GetViewMatrix() );
 }
 }
 
 
 
 

+ 14 - 14
src/renderer/renderer.h

@@ -6,7 +6,7 @@
 #include <GL/gl.h>
 #include <GL/gl.h>
 #include <GL/glu.h>
 #include <GL/glu.h>
 #include "gmath.h"
 #include "gmath.h"
-#include "shader_prog.h"
+#include "ShaderProg.h"
 #include "camera.h"
 #include "camera.h"
 
 
 
 
@@ -27,10 +27,10 @@ extern int   screenshot_jpeg_quality; ///< The quality of the JPEG screenshots.
 extern int  max_color_atachments; ///< Max color atachements a FBO can accept
 extern int  max_color_atachments; ///< Max color atachements a FBO can accept
 
 
 // texture stuff
 // texture stuff
-extern bool texture_compression; ///< Used in texture_t::Load to enable texture compression. Decreases video memory usage
-extern int  max_texture_units; ///< Used in texture_t::Bind so we wont bind in a nonexistent texture unit. Readonly
-extern bool mipmaping; ///< Used in texture_t::Load. Enables mipmaping increases video memory usage
-extern int  max_anisotropy; ///< Max texture anisotropy. Used in texture_t::Load
+extern bool texture_compression; ///< Used in Texture::load to enable texture compression. Decreases video memory usage
+extern int  max_texture_units; ///< Used in Texture::bind so we wont bind in a nonexistent texture unit. Readonly
+extern bool mipmaping; ///< Used in Texture::load. Enables mipmaping increases video memory usage
+extern int  max_anisotropy; ///< Max texture anisotropy. Used in Texture::load
 
 
 // misc
 // misc
 extern void TakeScreenshot( const char* filename ); ///< Save the colorbuffer as 24bit uncompressed TGA image
 extern void TakeScreenshot( const char* filename ); ///< Save the colorbuffer as 24bit uncompressed TGA image
@@ -51,11 +51,11 @@ extern void SetGLState_AlphaSolid();
 
 
 // ogl and glu wrappers
 // ogl and glu wrappers
 inline void   MultMatrix( const mat4_t& m4 ) { glMultMatrixf( &(m4.GetTransposed())(0,0) ); } ///< OpenGL wrapper
 inline void   MultMatrix( const mat4_t& m4 ) { glMultMatrixf( &(m4.GetTransposed())(0,0) ); } ///< OpenGL wrapper
-inline void   LoadMatrix( const mat4_t& m4 ) { glLoadMatrixf( &(m4.GetTransposed())(0,0) ); } ///< OpenGL wrapper
+inline void   loadMatrix( const mat4_t& m4 ) { glLoadMatrixf( &(m4.GetTransposed())(0,0) ); } ///< OpenGL wrapper
 
 
 inline void   Color3( const vec3_t& v ) { glColor3fv( &((vec3_t&)v)[0] ); } ///< OpenGL wrapper
 inline void   Color3( const vec3_t& v ) { glColor3fv( &((vec3_t&)v)[0] ); } ///< OpenGL wrapper
 inline void   Color4( const vec4_t& v ) { glColor4fv( &((vec4_t&)v)[0] ); } ///< OpenGL wrapper
 inline void   Color4( const vec4_t& v ) { glColor4fv( &((vec4_t&)v)[0] ); } ///< OpenGL wrapper
-inline void   NoShaders() { shader_prog_t::Unbind(); } ///< Unbind shaders
+inline void   NoShaders() { ShaderProg::unbind(); } ///< unbind shaders
 extern bool   Unproject( float winX, float winY, float winZ, const mat4_t& modelview_mat, const mat4_t& projection_mat, const int* view, float& objX, float& objY, float& objZ ); ///< My version of gluUnproject
 extern bool   Unproject( float winX, float winY, float winZ, const mat4_t& modelview_mat, const mat4_t& projection_mat, const int* view, float& objX, float& objY, float& objZ ); ///< My version of gluUnproject
 extern mat4_t Ortho( float left, float right, float bottom, float top, float near, float far );
 extern mat4_t Ortho( float left, float right, float bottom, float top, float near, float far );
 
 
@@ -70,21 +70,21 @@ inline void SetViewport( uint x, uint y, uint w, uint h ) { glViewport(x,y,w,h);
 /// material stage namespace
 /// material stage namespace
 namespace ms
 namespace ms
 {
 {
-	extern texture_t normal_fai;
-	extern texture_t depth_fai;
+	extern Texture normal_fai;
+	extern Texture depth_fai;
 }
 }
 
 
 /// illumination stage namespace
 /// illumination stage namespace
 namespace is
 namespace is
 {
 {
-	extern texture_t fai;
+	extern Texture fai;
 
 
 	/// illumination stage shadows namesapce
 	/// illumination stage shadows namesapce
 	namespace shadows
 	namespace shadows
 	{
 	{
-		extern shader_prog_t* shdr_depth;
-		extern shader_prog_t* shdr_depth_grass;
-		extern shader_prog_t* shdr_depth_hw_skinning;
+		extern ShaderProg* shdr_depth;
+		extern ShaderProg* shdr_depth_grass;
+		extern ShaderProg* shdr_depth_hw_skinning;
 		extern bool pcf; ///< PCF on/off
 		extern bool pcf; ///< PCF on/off
 		extern bool bilinear; ///< Shadowmap bilinear filtering on/off
 		extern bool bilinear; ///< Shadowmap bilinear filtering on/off
 	}
 	}
@@ -117,7 +117,7 @@ namespace pps
 		extern bool enabled; ///< Light scattering on/of
 		extern bool enabled; ///< Light scattering on/of
 	}
 	}
 
 
-	extern texture_t fai;
+	extern Texture fai;
 }
 }
 
 
 /// debug stage namespace
 /// debug stage namespace

+ 14 - 14
src/renderer/vbo.h

@@ -9,17 +9,17 @@
 class vbo_t
 class vbo_t
 {
 {
 	protected:
 	protected:
-		uint gl_id; ///< The OpenGL id of the VBO
+		uint glId; ///< The OpenGL id of the VBO
 		// the below vars can be extracted by quering OpenGL but I suppose keeping them here is faster
 		// the below vars can be extracted by quering OpenGL but I suppose keeping them here is faster
 		GLenum target;
 		GLenum target;
 		GLenum usage;
 		GLenum usage;
 
 
 	public:
 	public:
-		vbo_t(): gl_id(0) {}
+		vbo_t(): glId(0) {}
 		virtual ~vbo_t() { Delete(); }
 		virtual ~vbo_t() { Delete(); }
-		uint   GetGLID() const { DEBUG_ERR(gl_id==0); return gl_id; }
-		GLenum GetBufferTarget() const { DEBUG_ERR(gl_id==0); return target; }
-		GLenum GetBufferUsage() const { DEBUG_ERR(gl_id==0); return usage; }
+		uint   getGlId() const { DEBUG_ERR(glId==0); return glId; }
+		GLenum GetBufferTarget() const { DEBUG_ERR(glId==0); return target; }
+		GLenum GetBufferUsage() const { DEBUG_ERR(glId==0); return usage; }
 
 
 		/**
 		/**
 		 * Creates a new VBO with the given params and checks if everything went OK
 		 * Creates a new VBO with the given params and checks if everything went OK
@@ -30,7 +30,7 @@ class vbo_t
 		 */
 		 */
 		void Create( GLenum target_, uint size_in_bytes, const void* data_ptr, GLenum usage_ )
 		void Create( GLenum target_, uint size_in_bytes, const void* data_ptr, GLenum usage_ )
 		{
 		{
-			DEBUG_ERR( gl_id!=0 ); // VBO allready initialized
+			DEBUG_ERR( glId!=0 ); // VBO allready initialized
 			DEBUG_ERR( target_!=GL_ARRAY_BUFFER && target_!=GL_ELEMENT_ARRAY_BUFFER ); // unacceptable target_
 			DEBUG_ERR( target_!=GL_ARRAY_BUFFER && target_!=GL_ELEMENT_ARRAY_BUFFER ); // unacceptable target_
 			DEBUG_ERR( usage_!=GL_STREAM_DRAW && usage_!=GL_STATIC_DRAW && usage_!=GL_DYNAMIC_DRAW ); // unacceptable usage_
 			DEBUG_ERR( usage_!=GL_STREAM_DRAW && usage_!=GL_STATIC_DRAW && usage_!=GL_DYNAMIC_DRAW ); // unacceptable usage_
 			DEBUG_ERR( size_in_bytes < 1 ); // unacceptable size
 			DEBUG_ERR( size_in_bytes < 1 ); // unacceptable size
@@ -38,7 +38,7 @@ class vbo_t
 			usage = usage_;
 			usage = usage_;
 			target = target_;
 			target = target_;
 
 
-			glGenBuffers( 1, &gl_id );
+			glGenBuffers( 1, &glId );
 			Bind();
 			Bind();
 			glBufferData( target, size_in_bytes, data_ptr, usage ); // allocate memory and copy data from data_ptr to the VBO. If data_ptr is NULL just allocate
 			glBufferData( target, size_in_bytes, data_ptr, usage ); // allocate memory and copy data from data_ptr to the VBO. If data_ptr is NULL just allocate
 
 
@@ -60,18 +60,18 @@ class vbo_t
 		 */
 		 */
 		void Delete()
 		void Delete()
 		{
 		{
-			DEBUG_ERR( gl_id==0 ); // VBO unitialized
-			glDeleteBuffers( 1, &gl_id );
-			gl_id = 0;
+			DEBUG_ERR( glId==0 ); // VBO unitialized
+			glDeleteBuffers( 1, &glId );
+			glId = 0;
 		}
 		}
 
 
 		/**
 		/**
-		 * Bind the VBO
+		 * bind the VBO
 		 */
 		 */
 		void Bind() const
 		void Bind() const
 		{
 		{
-			DEBUG_ERR( gl_id==0 ); // VBO unitialized
-			glBindBuffer( target, gl_id );
+			DEBUG_ERR( glId==0 ); // VBO unitialized
+			glBindBuffer( target, glId );
 		}
 		}
 
 
 		/**
 		/**
@@ -79,7 +79,7 @@ class vbo_t
 		 */
 		 */
 		void Unbind() const
 		void Unbind() const
 		{
 		{
-			DEBUG_ERR( gl_id==0 ); // VBO unitialized
+			DEBUG_ERR( glId==0 ); // VBO unitialized
 			glBindBuffer( target, 0 );
 			glBindBuffer( target, 0 );
 		}
 		}
 
 

+ 5 - 5
src/renderer2/r_is.cpp

@@ -25,7 +25,7 @@ void renderer_t::illumination_stage_t::point_light_pass_t::DrawSMOUVS( const poi
 	const float scale = 1.2;
 	const float scale = 1.2;
 	renderer.matrices.model = mat4_t( light.translation_wspace, mat3_t::GetIdentity(), light.radius*scale );
 	renderer.matrices.model = mat4_t( light.translation_wspace, mat3_t::GetIdentity(), light.radius*scale );
 
 
-	shader_progs.smouvs.Bind();
+	shader_progs.smouvs.bind();
 
 
 	renderer.UpdateMatrices();
 	renderer.UpdateMatrices();
 
 
@@ -88,7 +88,7 @@ void renderer_t::illumination_stage_t::CalcPlanes()
 //=====================================================================================================================================
 //=====================================================================================================================================
 void renderer_t::illumination_stage_t::ambient_pass_t::Init()
 void renderer_t::illumination_stage_t::ambient_pass_t::Init()
 {
 {
-	shader_prog.CustomLoad( "shaders/is_ap.glsl", "" );
+	shaderProg.customload( "shaders/is_ap.glsl", "" );
 }
 }
 
 
 
 
@@ -100,11 +100,11 @@ void renderer_t::illumination_stage_t::ambient_pass_t::Run() const
 	glDisable( GL_BLEND );
 	glDisable( GL_BLEND );
 
 
 	// set the shader
 	// set the shader
-	shader_prog.Bind();
+	shaderProg.bind();
 
 
 	// set the uniforms
 	// set the uniforms
-	glUniform3fv( shader_prog.GetUniformLocation(0), 1, &((vec3_t)scene::GetAmbientColor())[0] );
-	shader_prog.LocTexUnit( shader_prog.GetUniformLocation(1), renderer.ms.fais.diffuse, 0 );
+	glUniform3fv( shaderProg.getUniLoc(0), 1, &((vec3_t)scene::GetAmbientColor())[0] );
+	shaderProg.locTexUnit( shaderProg.getUniLoc(1), renderer.ms.fais.diffuse, 0 );
 
 
 	// Draw quad
 	// Draw quad
 	renderer.DrawQuad();
 	renderer.DrawQuad();

+ 11 - 11
src/renderer2/r_ms.cpp

@@ -10,7 +10,7 @@ void renderer_t::material_stage_t::Init()
 {
 {
 	// create FBO
 	// create FBO
 	fbo.Create();
 	fbo.Create();
-	fbo.Bind();
+	fbo.bind();
 
 
 	// inform in what buffers we draw
 	// inform in what buffers we draw
 	fbo.SetNumOfColorAttachements(3);
 	fbo.SetNumOfColorAttachements(3);
@@ -23,22 +23,22 @@ void renderer_t::material_stage_t::Init()
 
 
 	fais.depth.CreateEmpty( renderer.width, renderer.height, GL_DEPTH_COMPONENT, GL_DEPTH_COMPONENT );
 	fais.depth.CreateEmpty( renderer.width, renderer.height, GL_DEPTH_COMPONENT, GL_DEPTH_COMPONENT );
 	// you could use the above for SSAO but the difference is minimal.
 	// you could use the above for SSAO but the difference is minimal.
-	//depth_fai.TexParameter( GL_TEXTURE_MAG_FILTER, GL_LINEAR );
-	//depth_fai.TexParameter( GL_TEXTURE_MIN_FILTER, GL_LINEAR );
+	//depth_fai.texParameter( GL_TEXTURE_MAG_FILTER, GL_LINEAR );
+	//depth_fai.texParameter( GL_TEXTURE_MIN_FILTER, GL_LINEAR );
 
 
 	// attach the buffers to the FBO
 	// attach the buffers to the FBO
-	glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, fais.normal.GetGLID(), 0 );
-	glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT1_EXT, GL_TEXTURE_2D, fais.diffuse.GetGLID(), 0 );
-	glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT2_EXT, GL_TEXTURE_2D, fais.specular.GetGLID(), 0 );
+	glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, fais.normal.getGlId(), 0 );
+	glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT1_EXT, GL_TEXTURE_2D, fais.diffuse.getGlId(), 0 );
+	glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT2_EXT, GL_TEXTURE_2D, fais.specular.getGlId(), 0 );
 
 
-	glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT,  GL_TEXTURE_2D, fais.depth.GetGLID(), 0 );
+	glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT,  GL_TEXTURE_2D, fais.depth.getGlId(), 0 );
 
 
 	// test if success
 	// test if success
 	if( !fbo.IsGood() )
 	if( !fbo.IsGood() )
 		FATAL( "Cannot create deferred shading material pass FBO" );
 		FATAL( "Cannot create deferred shading material pass FBO" );
 
 
 	// unbind
 	// unbind
-	fbo.Unbind();
+	fbo.unbind();
 }
 }
 
 
 
 
@@ -47,7 +47,7 @@ void renderer_t::material_stage_t::Init()
 //=====================================================================================================================================
 //=====================================================================================================================================
 void renderer_t::material_stage_t::Run() const
 void renderer_t::material_stage_t::Run() const
 {
 {
-	fbo.Bind();
+	fbo.bind();
 
 
 	glClear( GL_DEPTH_BUFFER_BIT );
 	glClear( GL_DEPTH_BUFFER_BIT );
 	renderer.matrices.view = renderer.camera->GetViewMatrix();
 	renderer.matrices.view = renderer.camera->GetViewMatrix();
@@ -61,7 +61,7 @@ void renderer_t::material_stage_t::Run() const
 
 
 	// render the meshes
 	// render the meshes
 	for( uint i=0; i<scene::meshes.size(); i++ )
 	for( uint i=0; i<scene::meshes.size(); i++ )
-		Render<mesh_t, false>( scene::meshes[i] );
+		Render<Mesh, false>( scene::meshes[i] );
 
 
 	// render the smodels
 	// render the smodels
 	for( uint i=0; i<scene::smodels.size(); i++ )
 	for( uint i=0; i<scene::smodels.size(); i++ )
@@ -70,6 +70,6 @@ void renderer_t::material_stage_t::Run() const
 	glPolygonMode( GL_FRONT, GL_FILL ); // the rendering above fucks the polygon mode
 	glPolygonMode( GL_FRONT, GL_FILL ); // the rendering above fucks the polygon mode
 
 
 
 
-	fbo.Unbind();
+	fbo.unbind();
 }
 }
 */
 */

+ 12 - 12
src/renderer2/renderer.hpp

@@ -30,7 +30,7 @@ struct renderer_t
 
 
 		struct
 		struct
 		{
 		{
-			texture_t normal, diffuse, specular, depth;
+			Texture normal, diffuse, specular, depth;
 		} fais;
 		} fais;
 
 
 		material_stage_t( renderer_t& r ): knowyourfather_t(r) {}
 		material_stage_t( renderer_t& r ): knowyourfather_t(r) {}
@@ -45,7 +45,7 @@ struct renderer_t
 		/// ambient pass
 		/// ambient pass
 		struct ambient_pass_t: knowyourfather_t
 		struct ambient_pass_t: knowyourfather_t
 		{
 		{
-			shader_prog_t shader_prog;
+			ShaderProg shaderProg;
 
 
 			ambient_pass_t( renderer_t& r ): knowyourfather_t(r) {}
 			ambient_pass_t( renderer_t& r ): knowyourfather_t(r) {}
 			void Init();
 			void Init();
@@ -64,7 +64,7 @@ struct renderer_t
 
 
 			struct
 			struct
 			{
 			{
-				shader_prog_t main, smouvs;
+				ShaderProg main, smouvs;
 			} shader_progs;
 			} shader_progs;
 
 
 			point_light_pass_t( renderer_t& r ): knowyourfather_t(r) {}
 			point_light_pass_t( renderer_t& r ): knowyourfather_t(r) {}
@@ -79,7 +79,7 @@ struct renderer_t
 
 
 			struct
 			struct
 			{
 			{
-				shader_prog_t shadow, no_shadow, smouvs;
+				ShaderProg shadow, no_shadow, smouvs;
 			} shader_progs;
 			} shader_progs;
 
 
 			spot_light_pass_t( renderer_t& r ): knowyourfather_t(r) {}
 			spot_light_pass_t( renderer_t& r ): knowyourfather_t(r) {}
@@ -90,7 +90,7 @@ struct renderer_t
 
 
 		// data
 		// data
 		fbo_t fbo;
 		fbo_t fbo;
-		texture_t fai;
+		Texture fai;
 		vec3_t view_vectors[4];
 		vec3_t view_vectors[4];
 		vec2_t planes;
 		vec2_t planes;
 
 
@@ -145,12 +145,12 @@ struct renderer_t
 
 
 				struct
 				struct
 				{
 				{
-					shader_prog_t pass0, pass1, pass2;
+					ShaderProg pass0, pass1, pass2;
 				} shader_progs;
 				} shader_progs;
 
 
 				struct
 				struct
 				{
 				{
-					texture_t pass0, pass1, pass2;
+					Texture pass0, pass1, pass2;
 				} fais;
 				} fais;
 
 
 				hdr_pass_t( renderer_t& r ): knowyourfather_t(r) {}
 				hdr_pass_t( renderer_t& r ): knowyourfather_t(r) {}
@@ -168,12 +168,12 @@ struct renderer_t
 
 
 				struct
 				struct
 				{
 				{
-					shader_prog_t main, blured;
+					ShaderProg main, blured;
 				} shader_progs;
 				} shader_progs;
 
 
 				struct
 				struct
 				{
 				{
-					texture_t main, blured;
+					Texture main, blured;
 				} fais;
 				} fais;
 
 
 				ssao_pass_t( renderer_t& r ): knowyourfather_t(r) {}
 				ssao_pass_t( renderer_t& r ): knowyourfather_t(r) {}
@@ -194,12 +194,12 @@ struct renderer_t
 
 
 			struct
 			struct
 			{
 			{
-				shader_prog_t main;
+				ShaderProg main;
 			} shader_progs;
 			} shader_progs;
 
 
 			struct
 			struct
 			{
 			{
-				texture_t main;
+				Texture main;
 			} fais;
 			} fais;
 
 
 			hdr_pass_t hdr;
 			hdr_pass_t hdr;
@@ -249,7 +249,7 @@ struct renderer_t
 
 
 	void UpdateMatrices();
 	void UpdateMatrices();
 	static void SetViewport( uint x, uint y, uint w, uint h ) { glViewport(x,y,w,h); };
 	static void SetViewport( uint x, uint y, uint w, uint h ) { glViewport(x,y,w,h); };
-	static void NoShaders() { shader_prog_t::Unbind(); }
+	static void NoShaders() { ShaderProg::unbind(); }
 	static void DrawQuad();
 	static void DrawQuad();
 	void Init();
 	void Init();
 	void Run( camera_t* cam );
 	void Run( camera_t* cam );

+ 33 - 0
src/resources/Extension.cpp

@@ -0,0 +1,33 @@
+#include <dlfcn.h>
+#include "Extension.h"
+
+
+bool Extension::load( const char* filename )
+{
+	// load libary
+	libHandle = dlopen( filename, RTLD_LAZY );
+	if( libHandle == NULL )
+	{
+		ERROR( "File \"" << filename << "\": " << dlerror() );
+		return false;
+	}
+	
+	// get FooBar
+	foobarPtr = (int(*)(void*))( dlsym(libHandle, "FooBar") );
+	if( foobarPtr == NULL )
+	{
+		ERROR( "File \"" << filename << "\": \"FooBar\" entry symbol not found: " << dlerror() );
+		return false;
+	}
+	
+	return true;
+}
+
+
+void Extension::unload()
+{
+	DEBUG_ERR( libHandle==NULL || foobarPtr==NULL );
+	dlclose( libHandle );
+	libHandle = NULL;
+	foobarPtr = NULL;
+}

+ 24 - 0
src/resources/Extension.h

@@ -0,0 +1,24 @@
+#ifndef _EXTENSION_H_
+#define _EXTENSION_H_
+
+#include "common.h"
+#include "Resource.h"
+
+
+/// Extension resource
+class Extension: public Resource
+{
+	private:
+		void* libHandle;
+		int(*foobarPtr)(void*);
+	
+	public:
+		Extension(): libHandle(NULL), foobarPtr(NULL) {}
+		~Extension() {}
+		bool load( const char* filename );
+		void unload();
+		template<typename Type> int FooBar( Type* ptr ) { DEBUG_ERR(foobarPtr==NULL); return (*foobarPtr)( reinterpret_cast<Type*>(ptr) ); }
+};
+
+
+#endif

+ 14 - 14
src/resources/light_props.cpp → src/resources/LightProps.cpp

@@ -1,12 +1,12 @@
-#include "light_props.h"
+#include "LightProps.h"
 #include "parser.h"
 #include "parser.h"
-#include "texture.h"
+#include "Texture.h"
 
 
 
 
 //=====================================================================================================================================
 //=====================================================================================================================================
-// Load                                                                                                                               =
+// load                                                                                                                               =
 //=====================================================================================================================================
 //=====================================================================================================================================
-bool light_props_t::Load( const char* filename )
+bool LightProps::load( const char* filename )
 {
 {
 Scanner scanner;
 Scanner scanner;
 	if( !scanner.loadFile( filename ) ) return false;
 	if( !scanner.loadFile( filename ) ) return false;
@@ -20,12 +20,12 @@ Scanner scanner;
 		//** DIFFUSE_COL **
 		//** DIFFUSE_COL **
 		if( token->code == Scanner::TC_IDENTIFIER && !strcmp( token->value.string, "DIFFUSE_COLOR" ) )
 		if( token->code == Scanner::TC_IDENTIFIER && !strcmp( token->value.string, "DIFFUSE_COLOR" ) )
 		{
 		{
-			ParseArrOfNumbers<float>( scanner, true, true, 3, &diffuse_col[0] );
+			ParseArrOfNumbers<float>( scanner, true, true, 3, &diffuseCol[0] );
 		}
 		}
 		//** SPECULAR_COL **
 		//** SPECULAR_COL **
 		else if( token->code == Scanner::TC_IDENTIFIER && !strcmp( token->value.string, "SPECULAR_COLOR" ) )
 		else if( token->code == Scanner::TC_IDENTIFIER && !strcmp( token->value.string, "SPECULAR_COLOR" ) )
 		{
 		{
-			ParseArrOfNumbers<float>( scanner, true, true, 3, &specular_col[0] );
+			ParseArrOfNumbers<float>( scanner, true, true, 3, &specularCol[0] );
 		}
 		}
 		//** RADIUS **
 		//** RADIUS **
 		else if( token->code == Scanner::TC_IDENTIFIER && !strcmp( token->value.string, "RADIUS" ) )
 		else if( token->code == Scanner::TC_IDENTIFIER && !strcmp( token->value.string, "RADIUS" ) )
@@ -49,7 +49,7 @@ Scanner scanner;
 				return false;
 				return false;
 			}
 			}
 
 
-			casts_shadow = token->value.int_;
+			castsShadow_ = token->value.int_;
 		}
 		}
 		//** DISTANCE **
 		//** DISTANCE **
 		else if( token->code == Scanner::TC_IDENTIFIER && !strcmp( token->value.string, "DISTANCE" ) )
 		else if( token->code == Scanner::TC_IDENTIFIER && !strcmp( token->value.string, "DISTANCE" ) )
@@ -73,7 +73,7 @@ Scanner scanner;
 				return false;
 				return false;
 			}
 			}
 
 
-			fov_x = (token->type == Scanner::DT_FLOAT) ? token->value.float_ : float(token->value.int_);
+			fovX = (token->type == Scanner::DT_FLOAT) ? token->value.float_ : float(token->value.int_);
 		}
 		}
 		//** FOV_Y **
 		//** FOV_Y **
 		else if( token->code == Scanner::TC_IDENTIFIER && !strcmp( token->value.string, "FOV_Y" ) )
 		else if( token->code == Scanner::TC_IDENTIFIER && !strcmp( token->value.string, "FOV_Y" ) )
@@ -85,7 +85,7 @@ Scanner scanner;
 				return false;
 				return false;
 			}
 			}
 
 
-			fov_y = (token->type == Scanner::DT_FLOAT) ? token->value.float_ : float(token->value.int_);
+			fovY = (token->type == Scanner::DT_FLOAT) ? token->value.float_ : float(token->value.int_);
 		}
 		}
 		//** TEXTURE **
 		//** TEXTURE **
 		else if( token->code == Scanner::TC_IDENTIFIER && !strcmp( token->value.string, "TEXTURE" ) )
 		else if( token->code == Scanner::TC_IDENTIFIER && !strcmp( token->value.string, "TEXTURE" ) )
@@ -97,8 +97,8 @@ Scanner scanner;
 				return false;
 				return false;
 			}
 			}
 				
 				
-			texture = rsrc::textures.Load( token->value.string );
-			texture->TexParameter( GL_TEXTURE_MAX_ANISOTROPY_EXT, 0 );
+			texture = rsrc::textures.load( token->value.string );
+			texture->texParameter( GL_TEXTURE_MAX_ANISOTROPY_EXT, 0 );
 		}
 		}
 		// end of file
 		// end of file
 		else if( token->code == Scanner::TC_EOF )
 		else if( token->code == Scanner::TC_EOF )
@@ -119,10 +119,10 @@ Scanner scanner;
 
 
 
 
 //=====================================================================================================================================
 //=====================================================================================================================================
-// Unload                                                                                                                             =
+// unload                                                                                                                             =
 //=====================================================================================================================================
 //=====================================================================================================================================
-void light_props_t::Unload()
+void LightProps::unload()
 {
 {
 	if( texture != NULL )
 	if( texture != NULL )
-		rsrc::textures.Unload( texture );
+		rsrc::textures.unload( texture );
 }
 }

+ 46 - 0
src/resources/LightProps.h

@@ -0,0 +1,46 @@
+#ifndef _LIGHTPROPS_H_
+#define _LIGHTPROPS_H_
+
+#include "common.h"
+#include "Resource.h"
+#include "gmath.h"
+
+
+class Texture;
+
+
+/// Light properties resource
+class LightProps: public Resource
+{
+	// data
+	PROPERTY_R( vec3_t, diffuseCol, getDiffuseColor )
+	PROPERTY_R( vec3_t, specularCol, getSpecularColor )
+	PROPERTY_R( float, radius, getRadius ) ///< For point lights
+	PROPERTY_R( bool, castsShadow_, castsShadow ) ///< For spot lights
+	PROPERTY_R( float, distance, getDistance ) ///< For spot lights. A.K.A.: camera's zfar
+	PROPERTY_R( float, fovX, getFovX ) ///< For spot lights
+	PROPERTY_R( float, fovY, getFovY ) ///< For spot lights
+		
+	private:
+		Texture* texture; ///< For spot lights
+	public:
+		const Texture* getTexture() const { DEBUG_ERR(texture==NULL); return texture; }
+	
+	// funcs	
+	public:
+		LightProps():
+			diffuseCol(0.5),
+			specularCol(0.5),
+			radius(1.0),
+			castsShadow_(false),
+			distance(3.0),
+			fovX(m::PI/4.0),
+			fovY(m::PI/4.0),
+			texture(NULL) 
+		{}
+		virtual ~LightProps() { /* ToDo */ }
+		bool load( const char* filename );
+		void unload();
+};
+
+#endif

+ 82 - 82
src/resources/material.cpp → src/resources/Material.cpp

@@ -1,14 +1,14 @@
 #include <string.h>
 #include <string.h>
-#include "material.h"
-#include "resource.h"
+#include "Material.h"
+#include "Resource.h"
 #include "Scanner.h"
 #include "Scanner.h"
 #include "parser.h"
 #include "parser.h"
-#include "texture.h"
-#include "shader_prog.h"
+#include "Texture.h"
+#include "ShaderProg.h"
 #include "renderer.h"
 #include "renderer.h"
 
 
 
 
-#define MTL_ERROR( x ) ERROR( "Material (" << GetPath() << GetName() << "): " << x );
+#define MTL_ERROR( x ) ERROR( "Material (" << getPath() << getName() << "): " << x );
 
 
 
 
 /*
 /*
@@ -55,10 +55,10 @@ static bool SearchBlendEnum( const char* str, int& gl_enum )
 
 
 /*
 /*
 =======================================================================================================================================
 =======================================================================================================================================
-Load                                                                                                                                  =
+load                                                                                                                                  =
 =======================================================================================================================================
 =======================================================================================================================================
 */
 */
-bool material_t::Load( const char* filename )
+bool Material::load( const char* filename )
 {
 {
 	Scanner scanner;
 	Scanner scanner;
 	if( !scanner.loadFile( filename ) ) return false;
 	if( !scanner.loadFile( filename ) ) return false;
@@ -72,7 +72,7 @@ bool material_t::Load( const char* filename )
 		//** SHADER_PROG **
 		//** SHADER_PROG **
 		if( token->code == Scanner::TC_IDENTIFIER && !strcmp( token->value.string, "SHADER_PROG" ) )
 		if( token->code == Scanner::TC_IDENTIFIER && !strcmp( token->value.string, "SHADER_PROG" ) )
 		{
 		{
-			if( shader_prog ) ERROR( "Shader program allready loaded" );
+			if( shaderProg ) ERROR( "Shader program allready loaded" );
 
 
 			token = &scanner.getNextToken();
 			token = &scanner.getNextToken();
 			if( token->code != Scanner::TC_STRING )
 			if( token->code != Scanner::TC_STRING )
@@ -80,12 +80,12 @@ bool material_t::Load( const char* filename )
 				PARSE_ERR_EXPECTED( "string" );
 				PARSE_ERR_EXPECTED( "string" );
 				return false;
 				return false;
 			}
 			}
-			shader_prog = rsrc::shaders.Load( token->value.string );
+			shaderProg = rsrc::shaders.load( token->value.string );
 		}
 		}
 		/*//** DEPTH_SHADER_PROG **
 		/*//** DEPTH_SHADER_PROG **
 		else if( token->code == Scanner::TC_IDENTIFIER && !strcmp( token->value.string, "DEPTH_SHADER_PROG" ) )
 		else if( token->code == Scanner::TC_IDENTIFIER && !strcmp( token->value.string, "DEPTH_SHADER_PROG" ) )
 		{
 		{
-			if( depth.shader_prog ) ERROR( "Depth shader program allready loaded" );
+			if( depth.shaderProg ) ERROR( "Depth shader program allready loaded" );
 
 
 			token = &scanner.getNextToken();
 			token = &scanner.getNextToken();
 			if( token->code != Scanner::TC_STRING )
 			if( token->code != Scanner::TC_STRING )
@@ -93,7 +93,7 @@ bool material_t::Load( const char* filename )
 				PARSE_ERR_EXPECTED( "string" );
 				PARSE_ERR_EXPECTED( "string" );
 				return false;
 				return false;
 			}
 			}
-			depth.shader_prog = rsrc::shaders.Load( token->value.string );
+			depth.shaderProg = rsrc::shaders.load( token->value.string );
 		}*/
 		}*/
 		//** DEPTH_MATERIAL **
 		//** DEPTH_MATERIAL **
 		else if( token->code == Scanner::TC_IDENTIFIER && !strcmp( token->value.string, "DEPTH_PASS_MATERIAL" ) )
 		else if( token->code == Scanner::TC_IDENTIFIER && !strcmp( token->value.string, "DEPTH_PASS_MATERIAL" ) )
@@ -106,7 +106,7 @@ bool material_t::Load( const char* filename )
 				PARSE_ERR_EXPECTED( "string" );
 				PARSE_ERR_EXPECTED( "string" );
 				return false;
 				return false;
 			}
 			}
-			dp_mtl = rsrc::materials.Load( token->value.string );
+			dp_mtl = rsrc::materials.load( token->value.string );
 		}
 		}
 		//** BLENDS **
 		//** BLENDS **
 		else if( token->code == Scanner::TC_IDENTIFIER && !strcmp( token->value.string, "BLENDS" ) )
 		else if( token->code == Scanner::TC_IDENTIFIER && !strcmp( token->value.string, "BLENDS" ) )
@@ -145,7 +145,7 @@ bool material_t::Load( const char* filename )
 				PARSE_ERR( "Incorrect blending factor \"" << token->value.string << "\"" );
 				PARSE_ERR( "Incorrect blending factor \"" << token->value.string << "\"" );
 				return false;
 				return false;
 			}
 			}
-			blending_sfactor = gl_enum;
+			blendingSfactor = gl_enum;
 		}
 		}
 		//** BLENDING_DFACTOR **
 		//** BLENDING_DFACTOR **
 		else if( token->code == Scanner::TC_IDENTIFIER && !strcmp( token->value.string, "BLENDING_DFACTOR" ) )
 		else if( token->code == Scanner::TC_IDENTIFIER && !strcmp( token->value.string, "BLENDING_DFACTOR" ) )
@@ -162,7 +162,7 @@ bool material_t::Load( const char* filename )
 				PARSE_ERR( "Incorrect blending factor \"" << token->value.string << "\"" );
 				PARSE_ERR( "Incorrect blending factor \"" << token->value.string << "\"" );
 				return false;
 				return false;
 			}
 			}
-			blending_dfactor = gl_enum;
+			blendingDfactor = gl_enum;
 		}
 		}
 		//** DEPTH_TESTING **
 		//** DEPTH_TESTING **
 		else if( token->code == Scanner::TC_IDENTIFIER && !strcmp( token->value.string, "DEPTH_TESTING" ) )
 		else if( token->code == Scanner::TC_IDENTIFIER && !strcmp( token->value.string, "DEPTH_TESTING" ) )
@@ -173,7 +173,7 @@ bool material_t::Load( const char* filename )
 				PARSE_ERR_EXPECTED( "number" );
 				PARSE_ERR_EXPECTED( "number" );
 				return false;
 				return false;
 			}
 			}
-			depth_testing = token->value.int_;
+			depthTesting = token->value.int_;
 		}
 		}
 		//** GRASS_MAP **
 		//** GRASS_MAP **
 		else if( token->code == Scanner::TC_IDENTIFIER && !strcmp( token->value.string, "GRASS_MAP" ) )
 		else if( token->code == Scanner::TC_IDENTIFIER && !strcmp( token->value.string, "GRASS_MAP" ) )
@@ -184,7 +184,7 @@ bool material_t::Load( const char* filename )
 				PARSE_ERR_EXPECTED( "string" );
 				PARSE_ERR_EXPECTED( "string" );
 				return false;
 				return false;
 			}
 			}
-			grass_map = rsrc::textures.Load( token->value.string );
+			grassMap = rsrc::textures.load( token->value.string );
 		}
 		}
 		//** WIREFRAME **
 		//** WIREFRAME **
 		else if( token->code == Scanner::TC_IDENTIFIER && !strcmp( token->value.string, "WIREFRAME" ) )
 		else if( token->code == Scanner::TC_IDENTIFIER && !strcmp( token->value.string, "WIREFRAME" ) )
@@ -206,7 +206,7 @@ bool material_t::Load( const char* filename )
 				PARSE_ERR_EXPECTED( "number" );
 				PARSE_ERR_EXPECTED( "number" );
 				return false;
 				return false;
 			}
 			}
-			casts_shadow = token->value.int_;
+			castsShadow = token->value.int_;
 		}
 		}
 		//** USER_DEFINED_VARS **
 		//** USER_DEFINED_VARS **
 		else if( token->code == Scanner::TC_IDENTIFIER && !strcmp( token->value.string, "USER_DEFINED_VARS" ) )
 		else if( token->code == Scanner::TC_IDENTIFIER && !strcmp( token->value.string, "USER_DEFINED_VARS" ) )
@@ -222,26 +222,26 @@ bool material_t::Load( const char* filename )
 			do
 			do
 			{
 			{
 				// read var type
 				// read var type
-				user_defined_var_t::type_e type;
+				UserDefinedVar::type_e type;
 				token = &scanner.getNextToken();
 				token = &scanner.getNextToken();
 				if( token->code == Scanner::TC_RBRACKET )
 				if( token->code == Scanner::TC_RBRACKET )
 					break;
 					break;
 				else if( token->code == Scanner::TC_IDENTIFIER && !strcmp( token->value.string, "TEXTURE" ) )
 				else if( token->code == Scanner::TC_IDENTIFIER && !strcmp( token->value.string, "TEXTURE" ) )
-					type = user_defined_var_t::VT_TEXTURE;
+					type = UserDefinedVar::VT_TEXTURE;
 				else if( token->code == Scanner::TC_IDENTIFIER && !strcmp( token->value.string, "FLOAT" ) )
 				else if( token->code == Scanner::TC_IDENTIFIER && !strcmp( token->value.string, "FLOAT" ) )
-					type = user_defined_var_t::VT_FLOAT;
+					type = UserDefinedVar::VT_FLOAT;
 				else if( token->code == Scanner::TC_IDENTIFIER && !strcmp( token->value.string, "VEC3" ) )
 				else if( token->code == Scanner::TC_IDENTIFIER && !strcmp( token->value.string, "VEC3" ) )
-					type = user_defined_var_t::VT_VEC3;
+					type = UserDefinedVar::VT_VEC3;
 				else if( token->code == Scanner::TC_IDENTIFIER && !strcmp( token->value.string, "VEC4" ) )
 				else if( token->code == Scanner::TC_IDENTIFIER && !strcmp( token->value.string, "VEC4" ) )
-					type = user_defined_var_t::VT_VEC4;
+					type = UserDefinedVar::VT_VEC4;
 				else
 				else
 				{
 				{
 					PARSE_ERR_EXPECTED( "TEXTURE or FLOAT or VEC3 or VEC4 or }" );
 					PARSE_ERR_EXPECTED( "TEXTURE or FLOAT or VEC3 or VEC4 or }" );
 					return false;
 					return false;
 				}
 				}
 
 
-				user_defined_vars.push_back( user_defined_var_t() ); // create new var
-				user_defined_var_t& var = user_defined_vars.back();
+				user_defined_vars.push_back( UserDefinedVar() ); // create new var
+				UserDefinedVar& var = user_defined_vars.back();
 				var.type = type;
 				var.type = type;
 
 
 				// read the name
 				// read the name
@@ -258,11 +258,11 @@ bool material_t::Load( const char* filename )
 				switch( type )
 				switch( type )
 				{
 				{
 					// texture
 					// texture
-					case user_defined_var_t::VT_TEXTURE:
+					case UserDefinedVar::VT_TEXTURE:
 						token = &scanner.getNextToken();
 						token = &scanner.getNextToken();
 						if( token->code == Scanner::TC_STRING )
 						if( token->code == Scanner::TC_STRING )
 						{
 						{
-							var.value.texture = rsrc::textures.Load( token->value.string );
+							var.value.texture = rsrc::textures.load( token->value.string );
 						}
 						}
 						else if( token->code == Scanner::TC_IDENTIFIER && !strcmp( token->value.string, "IS_FAI" ) )
 						else if( token->code == Scanner::TC_IDENTIFIER && !strcmp( token->value.string, "IS_FAI" ) )
 						{
 						{
@@ -287,7 +287,7 @@ bool material_t::Load( const char* filename )
 						}
 						}
 						break;
 						break;
 					// float
 					// float
-					case user_defined_var_t::VT_FLOAT:
+					case UserDefinedVar::VT_FLOAT:
 						token = &scanner.getNextToken();
 						token = &scanner.getNextToken();
 						if( token->code == Scanner::TC_NUMBER && token->type == Scanner::DT_FLOAT )
 						if( token->code == Scanner::TC_NUMBER && token->type == Scanner::DT_FLOAT )
 							var.value.float_ = token->value.float_;
 							var.value.float_ = token->value.float_;
@@ -298,15 +298,15 @@ bool material_t::Load( const char* filename )
 						}
 						}
 						break;
 						break;
 					// vec2
 					// vec2
-					case user_defined_var_t::VT_VEC2:
+					case UserDefinedVar::VT_VEC2:
 						ERROR( "Unimplemented" );
 						ERROR( "Unimplemented" );
 						break;
 						break;
 					// vec3
 					// vec3
-					case user_defined_var_t::VT_VEC3:
+					case UserDefinedVar::VT_VEC3:
 						if( !ParseArrOfNumbers<float>( scanner, true, true, 3, &var.value.vec3[0] ) ) return false;
 						if( !ParseArrOfNumbers<float>( scanner, true, true, 3, &var.value.vec3[0] ) ) return false;
 						break;
 						break;
 					// vec4
 					// vec4
-					case user_defined_var_t::VT_VEC4:
+					case UserDefinedVar::VT_VEC4:
 						if( !ParseArrOfNumbers<float>( scanner, true, true, 4, &var.value.vec4[0] ) ) return false;
 						if( !ParseArrOfNumbers<float>( scanner, true, true, 4, &var.value.vec4[0] ) ) return false;
 						break;
 						break;
 				};
 				};
@@ -328,57 +328,57 @@ bool material_t::Load( const char* filename )
 
 
 	}while( true );
 	}while( true );
 
 
-	return AdditionalInit();
+	return additionalInit();
 }
 }
 
 
 
 
 //=====================================================================================================================================
 //=====================================================================================================================================
-// AdditionalInit                                                                                                                     =
+// additionalInit                                                                                                                     =
 //=====================================================================================================================================
 //=====================================================================================================================================
-bool material_t::AdditionalInit()
+bool Material::additionalInit()
 {
 {
 	// sanity checks
 	// sanity checks
-	if( !shader_prog )
+	if( !shaderProg )
 	{
 	{
 		MTL_ERROR( "Without shader is like cake without sugar (missing SHADER_PROG)" );
 		MTL_ERROR( "Without shader is like cake without sugar (missing SHADER_PROG)" );
 		return false;
 		return false;
 	}
 	}
 
 
-	/*if( !depth.shader_prog )
+	/*if( !depth.shaderProg )
 	{
 	{
 		MTL_ERROR( "Without depth shader is like cake without shadow (missing DEPTH_SHADER_PROG)" );
 		MTL_ERROR( "Without depth shader is like cake without shadow (missing DEPTH_SHADER_PROG)" );
 		return false;
 		return false;
 	}*/
 	}*/
 
 
 	// for all user defined vars get their location
 	// for all user defined vars get their location
-	shader_prog->Bind();
+	shaderProg->bind();
 	for( uint i=0; i<user_defined_vars.size(); i++ )
 	for( uint i=0; i<user_defined_vars.size(); i++ )
 	{
 	{
-		int loc = shader_prog->GetUniformLocation( user_defined_vars[i].name.c_str() );
+		int loc = shaderProg->getUniLoc( user_defined_vars[i].name.c_str() );
 		if( loc == -1 )
 		if( loc == -1 )
 		{
 		{
-			MTL_ERROR( "Shader \"" << shader_prog->GetName() << "\" and user defined var \"" << user_defined_vars[i].name <<
+			MTL_ERROR( "Shader \"" << shaderProg->getName() << "\" and user defined var \"" << user_defined_vars[i].name <<
 			           "\" do not combine. Incorrect location" );
 			           "\" do not combine. Incorrect location" );
 			return false;
 			return false;
 		}
 		}
-		user_defined_vars[i].uniform_location = loc;
+		user_defined_vars[i].uniLoc = loc;
 	}
 	}
-	shader_prog->Unbind();
+	shaderProg->unbind();
 
 
 	// init the attribute locations
 	// init the attribute locations
-	attrib_locs.tanget = shader_prog->GetAttributeLocationSilently( "tangent" );
-	attrib_locs.position = shader_prog->GetAttributeLocationSilently( "position" );
-	attrib_locs.normal = shader_prog->GetAttributeLocationSilently( "normal" );
-	attrib_locs.tex_coords = shader_prog->GetAttributeLocationSilently( "tex_coords" );
+	attribLocs.tanget = shaderProg->getAttribLocSilently( "tangent" );
+	attribLocs.position = shaderProg->getAttribLocSilently( "position" );
+	attribLocs.normal = shaderProg->getAttribLocSilently( "normal" );
+	attribLocs.texCoords = shaderProg->getAttribLocSilently( "texCoords" );
 
 
 	// vertex weights
 	// vertex weights
-	attrib_locs.vert_weight_bones_num = shader_prog->GetAttributeLocationSilently( "vert_weight_bones_num" );
-	if( attrib_locs.vert_weight_bones_num != -1 )
+	attribLocs.vertWeightBonesNum = shaderProg->getAttribLocSilently( "vertWeightBonesNum" );
+	if( attribLocs.vertWeightBonesNum != -1 )
 	{
 	{
-		attrib_locs.vert_weight_bone_ids = shader_prog->GetAttributeLocation( "vert_weight_bone_ids" );
-		attrib_locs.vert_weight_weights = shader_prog->GetAttributeLocation( "vert_weight_weights" );
-		uni_locs.skinning_rotations = shader_prog->GetUniformLocation( "skinning_rotations" );
-		uni_locs.skinning_translations = shader_prog->GetUniformLocation( "skinning_translations" );
+		attribLocs.vertWeightBoneIds = shaderProg->getAttribLoc( "vertWeightBoneIds" );
+		attribLocs.vertWeightWeights = shaderProg->getAttribLoc( "vertWeightWeights" );
+		uniLocs.skinningRotations = shaderProg->getUniLoc( "skinningRotations" );
+		uniLocs.skinningTranslations = shaderProg->getUniLoc( "skinningTranslations" );
 	}
 	}
 
 
 	return true;
 	return true;
@@ -387,65 +387,65 @@ bool material_t::AdditionalInit()
 
 
 /*
 /*
 =======================================================================================================================================
 =======================================================================================================================================
-Unload                                                                                                                                =
+unload                                                                                                                                =
 =======================================================================================================================================
 =======================================================================================================================================
 */
 */
-void material_t::Unload()
+void Material::unload()
 {
 {
-	rsrc::shaders.Unload( shader_prog );
+	rsrc::shaders.unload( shaderProg );
 
 
 	// loop all user defined vars and unload the textures
 	// loop all user defined vars and unload the textures
 	for( uint i=0; i<user_defined_vars.size(); i++ )
 	for( uint i=0; i<user_defined_vars.size(); i++ )
 	{
 	{
-		if( user_defined_vars[i].type == user_defined_var_t::VT_TEXTURE )
-			rsrc::textures.Unload( user_defined_vars[i].value.texture );
+		if( user_defined_vars[i].type == UserDefinedVar::VT_TEXTURE )
+			rsrc::textures.unload( user_defined_vars[i].value.texture );
 	}
 	}
 
 
 	// the grass map
 	// the grass map
-	if( grass_map )
-		rsrc::textures.Unload( grass_map );
+	if( grassMap )
+		rsrc::textures.unload( grassMap );
 }
 }
 
 
 /*
 /*
 =======================================================================================================================================
 =======================================================================================================================================
-SetToDefault                                                                                                                          =
+setToDefault                                                                                                                          =
 =======================================================================================================================================
 =======================================================================================================================================
 */
 */
-void material_t::SetToDefault()
+void Material::setToDefault()
 {
 {
-	shader_prog = NULL;
+	shaderProg = NULL;
 	blends = false;
 	blends = false;
-	blending_sfactor = GL_ONE;
-	blending_dfactor = GL_ZERO;
-	depth_testing = true;
+	blendingSfactor = GL_ONE;
+	blendingDfactor = GL_ZERO;
+	depthTesting = true;
 	wireframe = false;
 	wireframe = false;
-	grass_map = NULL;
-	casts_shadow = true;
+	grassMap = NULL;
+	castsShadow = true;
 	refracts = false;
 	refracts = false;
 	dp_mtl = NULL;
 	dp_mtl = NULL;
-	/*depth.shader_prog = NULL;
+	/*depth.shaderProg = NULL;
 	depth.alpha_testing_map = NULL;*/
 	depth.alpha_testing_map = NULL;*/
 }
 }
 
 
 
 
 //=====================================================================================================================================
 //=====================================================================================================================================
-// Setup                                                                                                                              =
+// setup                                                                                                                              =
 //=====================================================================================================================================
 //=====================================================================================================================================
-void material_t::Setup()
+void Material::setup()
 {
 {
-	shader_prog->Bind();
+	shaderProg->bind();
 
 
 	if( blends )
 	if( blends )
 	{
 	{
 		glEnable( GL_BLEND );
 		glEnable( GL_BLEND );
 		//glDisable( GL_BLEND );
 		//glDisable( GL_BLEND );
-		glBlendFunc( blending_sfactor, blending_dfactor );
+		glBlendFunc( blendingSfactor, blendingDfactor );
 	}
 	}
 	else
 	else
 		glDisable( GL_BLEND );
 		glDisable( GL_BLEND );
 
 
 
 
-	if( depth_testing )  glEnable( GL_DEPTH_TEST );
+	if( depthTesting )  glEnable( GL_DEPTH_TEST );
 	else                 glDisable( GL_DEPTH_TEST );
 	else                 glDisable( GL_DEPTH_TEST );
 
 
 	if( wireframe )  glPolygonMode( GL_FRONT, GL_LINE );
 	if( wireframe )  glPolygonMode( GL_FRONT, GL_LINE );
@@ -454,30 +454,30 @@ void material_t::Setup()
 
 
 	// now loop all the user defined vars and set them
 	// now loop all the user defined vars and set them
 	uint texture_unit = 0;
 	uint texture_unit = 0;
-	vec_t<user_defined_var_t>::iterator udv;
+	Vec<UserDefinedVar>::iterator udv;
 	for( udv=user_defined_vars.begin(); udv!=user_defined_vars.end(); udv++ )
 	for( udv=user_defined_vars.begin(); udv!=user_defined_vars.end(); udv++ )
 	{
 	{
 		switch( udv->type )
 		switch( udv->type )
 		{
 		{
 			// texture
 			// texture
-			case user_defined_var_t::VT_TEXTURE:
-				shader_prog->LocTexUnit( udv->uniform_location, *udv->value.texture, texture_unit++ );
+			case UserDefinedVar::VT_TEXTURE:
+				shaderProg->locTexUnit( udv->uniLoc, *udv->value.texture, texture_unit++ );
 				break;
 				break;
 			// float
 			// float
-			case user_defined_var_t::VT_FLOAT:
-				glUniform1f( udv->uniform_location, udv->value.float_ );
+			case UserDefinedVar::VT_FLOAT:
+				glUniform1f( udv->uniLoc, udv->value.float_ );
 				break;
 				break;
 			// vec2
 			// vec2
-			case user_defined_var_t::VT_VEC2:
-				glUniform2fv( udv->uniform_location, 1, &udv->value.vec2[0] );
+			case UserDefinedVar::VT_VEC2:
+				glUniform2fv( udv->uniLoc, 1, &udv->value.vec2[0] );
 				break;
 				break;
 			// vec3
 			// vec3
-			case user_defined_var_t::VT_VEC3:
-				glUniform3fv( udv->uniform_location, 1, &udv->value.vec3[0] );
+			case UserDefinedVar::VT_VEC3:
+				glUniform3fv( udv->uniLoc, 1, &udv->value.vec3[0] );
 				break;
 				break;
 			// vec4
 			// vec4
-			case user_defined_var_t::VT_VEC4:
-				glUniform4fv( udv->uniform_location, 1, &udv->value.vec4[0] );
+			case UserDefinedVar::VT_VEC4:
+				glUniform4fv( udv->uniLoc, 1, &udv->value.vec4[0] );
 				break;
 				break;
 		}
 		}
 	}
 	}

+ 40 - 40
src/resources/material.h → src/resources/Material.h

@@ -3,17 +3,17 @@
 
 
 #include "common.h"
 #include "common.h"
 #include "gmath.h"
 #include "gmath.h"
-#include "resource.h"
+#include "Resource.h"
 
 
 /// Mesh material resource
 /// Mesh material resource
-class material_t: public resource_t
+class Material: public Resource
 {
 {
 	//===================================================================================================================================
 	//===================================================================================================================================
 	// User defined variables                                                                                                           =
 	// User defined variables                                                                                                           =
 	//===================================================================================================================================
 	//===================================================================================================================================
 	public:
 	public:
 		/// class for user defined material variables that will be passes in to the shader
 		/// class for user defined material variables that will be passes in to the shader
-		class user_defined_var_t
+		class UserDefinedVar
 		{
 		{
 			public:
 			public:
 				enum type_e
 				enum type_e
@@ -25,39 +25,39 @@ class material_t: public resource_t
 					VT_VEC4
 					VT_VEC4
 				};
 				};
 
 
-				struct value_t       // unfortunately we cannot use union because of vec3_t and vec4_t
+				struct Value       // unfortunately we cannot use union because of vec3_t and vec4_t
 				{
 				{
-					texture_t* texture;
+					Texture* texture;
 					float      float_;
 					float      float_;
 					vec2_t     vec2;
 					vec2_t     vec2;
 					vec3_t     vec3;
 					vec3_t     vec3;
 					vec4_t     vec4;
 					vec4_t     vec4;
-					value_t(): texture(NULL) {}
+					Value(): texture(NULL) {}
 				};
 				};
 
 
 				type_e type;
 				type_e type;
-				value_t value;
-				int uniform_location;
+				Value value;
+				int uniLoc;
 				string name;
 				string name;
-		}; // end class user_defined_var_t
+		}; // end class UserDefinedVar
 
 
-		vec_t<user_defined_var_t> user_defined_vars;
+		Vec<UserDefinedVar> user_defined_vars;
 
 
 
 
 	//===================================================================================================================================
 	//===================================================================================================================================
 	// data                                                                                                                             =
 	// data                                                                                                                             =
 	//===================================================================================================================================
 	//===================================================================================================================================
 	public:
 	public:
-		shader_prog_t* shader_prog; ///< The most imortant asspect of materials
+		ShaderProg* shaderProg; ///< The most imortant asspect of materials
 
 
 		bool blends; ///< The entities with blending are being rendered in blending stage and those without in material stage
 		bool blends; ///< The entities with blending are being rendered in blending stage and those without in material stage
 		bool refracts;
 		bool refracts;
-		int  blending_sfactor;
-		int  blending_dfactor;
-		bool depth_testing;
+		int  blendingSfactor;
+		int  blendingDfactor;
+		bool depthTesting;
 		bool wireframe;
 		bool wireframe;
-		bool casts_shadow; ///< Used in shadowmapping passes but not in EarlyZ
-		texture_t* grass_map; // ToDo remove this
+		bool castsShadow; ///< Used in shadowmapping passes but not in EarlyZ
+		Texture* grassMap; // ToDo remove this
 
 
 		// vertex attributes
 		// vertex attributes
 		struct
 		struct
@@ -65,61 +65,61 @@ class material_t: public resource_t
 			int position;
 			int position;
 			int tanget;
 			int tanget;
 			int normal;
 			int normal;
-			int tex_coords;
+			int texCoords;
 
 
 			// for hw skinning
 			// for hw skinning
-			int vert_weight_bones_num;
-			int vert_weight_bone_ids;
-			int vert_weight_weights;
-		} attrib_locs;
+			int vertWeightBonesNum;
+			int vertWeightBoneIds;
+			int vertWeightWeights;
+		} attribLocs;
 
 
 		// uniforms
 		// uniforms
 		struct
 		struct
 		{
 		{
-			int skinning_rotations;
-			int skinning_translations;
-		} uni_locs;
+			int skinningRotations;
+			int skinningTranslations;
+		} uniLocs;
 
 
 		// for depth passing
 		// for depth passing
 		/*struct
 		/*struct
 		{
 		{
-			shader_prog_t* shader_prog; ///< Depth pass shader program
-			texture_t* alpha_testing_map;
+			ShaderProg* shaderProg; ///< Depth pass shader program
+			Texture* alpha_testing_map;
 			
 			
 			struct
 			struct
 			{
 			{
 				int position;
 				int position;
-				int tex_coords;
+				int texCoords;
 
 
 				// for hw skinning
 				// for hw skinning
-				int vert_weight_bones_num;
-				int vert_weight_bone_ids;
-				int vert_weight_weights;
+				int vertWeightBonesNum;
+				int vertWeightBoneIds;
+				int vertWeightWeights;
 			} attribute_locs;
 			} attribute_locs;
 			
 			
 			struct
 			struct
 			{
 			{
 				int alpha_testing_map;
 				int alpha_testing_map;
-			} uni_locs;
+			} uniLocs;
 		} depth;*/
 		} depth;*/
 
 
-		material_t* dp_mtl;
+		Material* dp_mtl;
 
 
 	//===================================================================================================================================
 	//===================================================================================================================================
 	// funcs                                                                                                                            =
 	// funcs                                                                                                                            =
 	//===================================================================================================================================
 	//===================================================================================================================================
 	protected:
 	protected:
-		void SetToDefault();
-		bool AdditionalInit(); ///< The func is for not polluting Load with extra code
+		void setToDefault();
+		bool additionalInit(); ///< The func is for not polluting load with extra code
 		
 		
 	public:
 	public:
-		material_t() { SetToDefault(); }
-		void Setup();
-		bool Load( const char* filename );
-		void Unload();
+		Material() { setToDefault(); }
+		void setup();
+		bool load( const char* filename );
+		void unload();
 
 
-		bool HasHWSkinning() const { return attrib_locs.vert_weight_bones_num != -1; }
-		bool HasAlphaTesting() const { return dp_mtl!=NULL && dp_mtl->attrib_locs.tex_coords!=-1; }
+		bool hasHWSkinning() const { return attribLocs.vertWeightBonesNum != -1; }
+		bool hasAlphaTesting() const { return dp_mtl!=NULL && dp_mtl->attribLocs.texCoords!=-1; }
 };
 };
 
 
 
 

+ 92 - 92
src/resources/mesh.cpp → src/resources/Mesh.cpp

@@ -1,14 +1,14 @@
-#include "mesh.h"
+#include "Mesh.h"
 #include "renderer.h"
 #include "renderer.h"
-#include "resource.h"
+#include "Resource.h"
 #include "Scanner.h"
 #include "Scanner.h"
 #include "parser.h"
 #include "parser.h"
 
 
 
 
 //=====================================================================================================================================
 //=====================================================================================================================================
-// Load                                                                                                                               =
+// load                                                                                                                               =
 //=====================================================================================================================================
 //=====================================================================================================================================
-bool mesh_t::Load( const char* filename )
+bool Mesh::load( const char* filename )
 {
 {
 	Scanner scanner;
 	Scanner scanner;
 	if( !scanner.loadFile( filename ) ) return false;
 	if( !scanner.loadFile( filename ) ) return false;
@@ -23,7 +23,7 @@ bool mesh_t::Load( const char* filename )
 		PARSE_ERR_EXPECTED( "string" );
 		PARSE_ERR_EXPECTED( "string" );
 		return false;
 		return false;
 	}
 	}
-	material_name = token->value.string;
+	materialName = token->value.string;
 
 
 	//** DP_MATERIAL **
 	//** DP_MATERIAL **
 	/*token = &scanner.getNextToken();
 	/*token = &scanner.getNextToken();
@@ -32,7 +32,7 @@ bool mesh_t::Load( const char* filename )
 		PARSE_ERR_EXPECTED( "string" );
 		PARSE_ERR_EXPECTED( "string" );
 		return false;
 		return false;
 	}
 	}
-	dp_material_name = token->value.string;*/
+	dp_materialName = token->value.string;*/
 
 
 	//** VERTS **
 	//** VERTS **
 	// verts num
 	// verts num
@@ -42,12 +42,12 @@ bool mesh_t::Load( const char* filename )
 		PARSE_ERR_EXPECTED( "integer" );
 		PARSE_ERR_EXPECTED( "integer" );
 		return false;
 		return false;
 	}
 	}
-	vert_coords.resize( token->value.int_ );
+	vertCoords.resize( token->value.int_ );
 
 
 	// read the verts
 	// read the verts
-	for( uint i=0; i<vert_coords.size(); i++ )
+	for( uint i=0; i<vertCoords.size(); i++ )
 	{
 	{
-		if( !ParseArrOfNumbers<float>( scanner, false, true, 3, &vert_coords[i][0] ) ) return false;
+		if( !ParseArrOfNumbers<float>( scanner, false, true, 3, &vertCoords[i][0] ) ) return false;
 	}
 	}
 
 
 	//** FACES **
 	//** FACES **
@@ -62,7 +62,7 @@ bool mesh_t::Load( const char* filename )
 	// read the faces
 	// read the faces
 	for( uint i=0; i<tris.size(); i++ )
 	for( uint i=0; i<tris.size(); i++ )
 	{
 	{
-		if( !ParseArrOfNumbers<uint>( scanner, false, true, 3, tris[i].vert_ids ) ) return false;
+		if( !ParseArrOfNumbers<uint>( scanner, false, true, 3, tris[i].vertIds ) ) return false;
 	}
 	}
 
 
 	//** UVS **
 	//** UVS **
@@ -73,11 +73,11 @@ bool mesh_t::Load( const char* filename )
 		PARSE_ERR_EXPECTED( "integer" );
 		PARSE_ERR_EXPECTED( "integer" );
 		return false;
 		return false;
 	}
 	}
-	tex_coords.resize( token->value.int_ );
-	// read the tex_coords
-	for( uint i=0; i<tex_coords.size(); i++ )
+	texCoords.resize( token->value.int_ );
+	// read the texCoords
+	for( uint i=0; i<texCoords.size(); i++ )
 	{
 	{
-		if( !ParseArrOfNumbers( scanner, false, true, 2, &tex_coords[i][0] ) ) return false;
+		if( !ParseArrOfNumbers( scanner, false, true, 2, &texCoords[i][0] ) ) return false;
 	}
 	}
 
 
 	//** VERTEX WEIGHTS **
 	//** VERTEX WEIGHTS **
@@ -87,8 +87,8 @@ bool mesh_t::Load( const char* filename )
 		PARSE_ERR_EXPECTED( "integer" );
 		PARSE_ERR_EXPECTED( "integer" );
 		return false;
 		return false;
 	}
 	}
-	vert_weights.resize( token->value.int_ );
-	for( uint i=0; i<vert_weights.size(); i++ )
+	vertWeights.resize( token->value.int_ );
+	for( uint i=0; i<vertWeights.size(); i++ )
 	{
 	{
 		// get the bone connections num
 		// get the bone connections num
 		token = &scanner.getNextToken();
 		token = &scanner.getNextToken();
@@ -106,15 +106,15 @@ bool mesh_t::Load( const char* filename )
 		}
 		}
 
 
 		// and here is another possible error
 		// and here is another possible error
-		if( token->value.int_ > vertex_weight_t::MAX_BONES_PER_VERT )
+		if( token->value.int_ > VertexWeight::MAX_BONES_PER_VERT )
 		{
 		{
-			ERROR( "Cannot have more than " << vertex_weight_t::MAX_BONES_PER_VERT << " bones per vertex" );
+			ERROR( "Cannot have more than " << VertexWeight::MAX_BONES_PER_VERT << " bones per vertex" );
 			return false;
 			return false;
 		}
 		}
-		vert_weights[i].bones_num = token->value.int_;
+		vertWeights[i].bonesNum = token->value.int_;
 
 
 		// for all the weights of the current vertes
 		// for all the weights of the current vertes
-		for( uint j=0; j<vert_weights[i].bones_num; j++ )
+		for( uint j=0; j<vertWeights[i].bonesNum; j++ )
 		{
 		{
 			// read bone id
 			// read bone id
 			token = &scanner.getNextToken();
 			token = &scanner.getNextToken();
@@ -123,7 +123,7 @@ bool mesh_t::Load( const char* filename )
 				PARSE_ERR_EXPECTED( "integer" );
 				PARSE_ERR_EXPECTED( "integer" );
 				return false;
 				return false;
 			}
 			}
-			vert_weights[i].bone_ids[j] = token->value.int_;
+			vertWeights[i].boneIds[j] = token->value.int_;
 
 
 			// read the weight of that bone
 			// read the weight of that bone
 			token = &scanner.getNextToken();
 			token = &scanner.getNextToken();
@@ -132,74 +132,74 @@ bool mesh_t::Load( const char* filename )
 				PARSE_ERR_EXPECTED( "float" );
 				PARSE_ERR_EXPECTED( "float" );
 				return false;
 				return false;
 			}
 			}
-			vert_weights[i].weights[j] = token->value.float_;
+			vertWeights[i].weights[j] = token->value.float_;
 		}
 		}
 	}
 	}
 
 
 	// Sanity checks
 	// Sanity checks
-	if( vert_coords.size()<1 || tris.size()<1 )
+	if( vertCoords.size()<1 || tris.size()<1 )
 	{
 	{
 		ERROR( "Vert coords and tris must be filled \"" << filename << "\"" );
 		ERROR( "Vert coords and tris must be filled \"" << filename << "\"" );
 		return false;
 		return false;
 	}
 	}
-	if( tex_coords.size()!=0 && tex_coords.size()!=vert_coords.size() )
+	if( texCoords.size()!=0 && texCoords.size()!=vertCoords.size() )
 	{
 	{
 		ERROR( "Tex coords num must be zero or equal to vertex coords num \"" << filename << "\"" );
 		ERROR( "Tex coords num must be zero or equal to vertex coords num \"" << filename << "\"" );
 		return false;
 		return false;
 	}
 	}
-	if( vert_weights.size()!=0 && vert_weights.size()!=vert_coords.size() )
+	if( vertWeights.size()!=0 && vertWeights.size()!=vertCoords.size() )
 	{
 	{
 		ERROR( "Vert weights num must be zero or equal to vertex coords num \"" << filename << "\"" );
 		ERROR( "Vert weights num must be zero or equal to vertex coords num \"" << filename << "\"" );
 		return false;
 		return false;
 	}
 	}
 
 
-	CreateAllNormals();
-	if( tex_coords.size() > 0 ) CreateVertTangents();
-	CreateVertIndeces();
-	CreateVBOs();
-	CalcBSphere();
+	createAllNormals();
+	if( texCoords.size() > 0 ) createVertTangents();
+	createVertIndeces();
+	createVBOs();
+	calcBSphere();
 
 
 	return true;
 	return true;
 }
 }
 
 
 
 
 //=====================================================================================================================================
 //=====================================================================================================================================
-// Unload                                                                                                                             =
+// unload                                                                                                                             =
 //=====================================================================================================================================
 //=====================================================================================================================================
-void mesh_t::Unload()
+void Mesh::unload()
 {
 {
 	// ToDo: add when finalized
 	// ToDo: add when finalized
 }
 }
 
 
 
 
 //=====================================================================================================================================
 //=====================================================================================================================================
-// CreateFaceNormals                                                                                                                  =
+// createFaceNormals                                                                                                                  =
 //=====================================================================================================================================
 //=====================================================================================================================================
-void mesh_t::CreateVertIndeces()
+void Mesh::createVertIndeces()
 {
 {
-	DEBUG_ERR( vert_indeces.size() > 0 );
+	DEBUG_ERR( vertIndeces.size() > 0 );
 
 
-	vert_indeces.resize( tris.size() * 3 );
+	vertIndeces.resize( tris.size() * 3 );
 	for( uint i=0; i<tris.size(); i++ )
 	for( uint i=0; i<tris.size(); i++ )
 	{
 	{
-		vert_indeces[i*3+0] = tris[i].vert_ids[0];
-		vert_indeces[i*3+1] = tris[i].vert_ids[1];
-		vert_indeces[i*3+2] = tris[i].vert_ids[2];
+		vertIndeces[i*3+0] = tris[i].vertIds[0];
+		vertIndeces[i*3+1] = tris[i].vertIds[1];
+		vertIndeces[i*3+2] = tris[i].vertIds[2];
 	}
 	}
 }
 }
 
 
 
 
 //=====================================================================================================================================
 //=====================================================================================================================================
-// CreateFaceNormals                                                                                                                  =
+// createFaceNormals                                                                                                                  =
 //=====================================================================================================================================
 //=====================================================================================================================================
-void mesh_t::CreateFaceNormals()
+void Mesh::createFaceNormals()
 {
 {
 	for( uint i=0; i<tris.size(); i++ )
 	for( uint i=0; i<tris.size(); i++ )
 	{
 	{
-		triangle_t& tri = tris[i];
-		const vec3_t& v0 = vert_coords[ tri.vert_ids[0] ];
-		const vec3_t& v1 = vert_coords[ tri.vert_ids[1] ];
-		const vec3_t& v2 = vert_coords[ tri.vert_ids[2] ];
+		Triangle& tri = tris[i];
+		const vec3_t& v0 = vertCoords[ tri.vertIds[0] ];
+		const vec3_t& v1 = vertCoords[ tri.vertIds[1] ];
+		const vec3_t& v2 = vertCoords[ tri.vertIds[2] ];
 
 
 		tri.normal = ( v1 - v0 ).Cross( v2 - v0 );
 		tri.normal = ( v1 - v0 ).Cross( v2 - v0 );
 
 
@@ -209,56 +209,56 @@ void mesh_t::CreateFaceNormals()
 
 
 
 
 //=====================================================================================================================================
 //=====================================================================================================================================
-// CreateVertNormals                                                                                                                  =
+// createVertNormals                                                                                                                  =
 //=====================================================================================================================================
 //=====================================================================================================================================
-void mesh_t::CreateVertNormals()
+void Mesh::createVertNormals()
 {
 {
-	vert_normals.resize( vert_coords.size() ); // alloc
+	vertNormals.resize( vertCoords.size() ); // alloc
 
 
-	for( uint i=0; i<vert_coords.size(); i++ )
-		vert_normals[i] = vec3_t( 0.0, 0.0, 0.0 );
+	for( uint i=0; i<vertCoords.size(); i++ )
+		vertNormals[i] = vec3_t( 0.0, 0.0, 0.0 );
 
 
 	for( uint i=0; i<tris.size(); i++ )
 	for( uint i=0; i<tris.size(); i++ )
 	{
 	{
-		const triangle_t& tri = tris[i];
-		vert_normals[ tri.vert_ids[0] ] += tri.normal;
-		vert_normals[ tri.vert_ids[1] ] += tri.normal;
-		vert_normals[ tri.vert_ids[2] ] += tri.normal;
+		const Triangle& tri = tris[i];
+		vertNormals[ tri.vertIds[0] ] += tri.normal;
+		vertNormals[ tri.vertIds[1] ] += tri.normal;
+		vertNormals[ tri.vertIds[2] ] += tri.normal;
 	}
 	}
 
 
-	for( uint i=0; i<vert_normals.size(); i++ )
-		vert_normals[i].Normalize();
+	for( uint i=0; i<vertNormals.size(); i++ )
+		vertNormals[i].Normalize();
 }
 }
 
 
 
 
 //=====================================================================================================================================
 //=====================================================================================================================================
-// CreateVertTangents                                                                                                                 =
+// createVertTangents                                                                                                                 =
 //=====================================================================================================================================
 //=====================================================================================================================================
-void mesh_t::CreateVertTangents()
+void Mesh::createVertTangents()
 {
 {
-	vert_tangents.resize( vert_coords.size() ); // alloc
+	vertTangents.resize( vertCoords.size() ); // alloc
 
 
-	vec_t<vec3_t> bitagents( vert_coords.size() );
+	Vec<vec3_t> bitagents( vertCoords.size() );
 
 
-	for( uint i=0; i<vert_tangents.size(); i++ )
+	for( uint i=0; i<vertTangents.size(); i++ )
 	{
 	{
-		vert_tangents[i] = vec4_t( 0.0 );
+		vertTangents[i] = vec4_t( 0.0 );
 		bitagents[i] = vec3_t( 0.0 );
 		bitagents[i] = vec3_t( 0.0 );
 	}
 	}
 
 
 	for( uint i=0; i<tris.size(); i++ )
 	for( uint i=0; i<tris.size(); i++ )
 	{
 	{
-		const triangle_t& tri = tris[i];
-		const int i0 = tri.vert_ids[0];
-		const int i1 = tri.vert_ids[1];
-		const int i2 = tri.vert_ids[2];
-		const vec3_t& v0 = vert_coords[ i0 ];
-		const vec3_t& v1 = vert_coords[ i1 ];
-		const vec3_t& v2 = vert_coords[ i2 ];
+		const Triangle& tri = tris[i];
+		const int i0 = tri.vertIds[0];
+		const int i1 = tri.vertIds[1];
+		const int i2 = tri.vertIds[2];
+		const vec3_t& v0 = vertCoords[ i0 ];
+		const vec3_t& v1 = vertCoords[ i1 ];
+		const vec3_t& v2 = vertCoords[ i2 ];
 		vec3_t edge01 = v1 - v0;
 		vec3_t edge01 = v1 - v0;
 		vec3_t edge02 = v2 - v0;
 		vec3_t edge02 = v2 - v0;
-		vec2_t uvedge01 = tex_coords[i1] - tex_coords[i0];
-		vec2_t uvedge02 = tex_coords[i2] - tex_coords[i0];
+		vec2_t uvedge01 = texCoords[i1] - texCoords[i0];
+		vec2_t uvedge02 = texCoords[i2] - texCoords[i0];
 
 
 
 
 		float det = (uvedge01.y * uvedge02.x) - (uvedge01.x * uvedge02.y);
 		float det = (uvedge01.y * uvedge02.x) - (uvedge01.x * uvedge02.y);
@@ -270,19 +270,19 @@ void mesh_t::CreateVertTangents()
 		t.Normalize();
 		t.Normalize();
 		b.Normalize();
 		b.Normalize();
 
 
-		vert_tangents[i0] += vec4_t(t, 1.0);
-		vert_tangents[i1] += vec4_t(t, 1.0);
-		vert_tangents[i2] += vec4_t(t, 1.0);
+		vertTangents[i0] += vec4_t(t, 1.0);
+		vertTangents[i1] += vec4_t(t, 1.0);
+		vertTangents[i2] += vec4_t(t, 1.0);
 
 
 		bitagents[i0] += b;
 		bitagents[i0] += b;
 		bitagents[i1] += b;
 		bitagents[i1] += b;
 		bitagents[i2] += b;
 		bitagents[i2] += b;
 	}
 	}
 
 
-	for( uint i=0; i<vert_tangents.size(); i++ )
+	for( uint i=0; i<vertTangents.size(); i++ )
 	{
 	{
-		vec3_t t = vec3_t(vert_tangents[i]);
-		const vec3_t& n = vert_normals[i];
+		vec3_t t = vec3_t(vertTangents[i]);
+		const vec3_t& n = vertNormals[i];
 		vec3_t& b = bitagents[i];
 		vec3_t& b = bitagents[i];
 
 
 		//t = t - n * n.Dot(t);
 		//t = t - n * n.Dot(t);
@@ -292,7 +292,7 @@ void mesh_t::CreateVertTangents()
 
 
 		float w = ( (n.Cross(t)).Dot( b ) < 0.0) ? 1.0 : -1.0;
 		float w = ( (n.Cross(t)).Dot( b ) < 0.0) ? 1.0 : -1.0;
 
 
-		vert_tangents[i] = vec4_t( t, w );
+		vertTangents[i] = vec4_t( t, w );
 	}
 	}
 
 
 	bitagents.clear();
 	bitagents.clear();
@@ -300,26 +300,26 @@ void mesh_t::CreateVertTangents()
 
 
 
 
 //=====================================================================================================================================
 //=====================================================================================================================================
-// CreateVBOs                                                                                                                         =
+// createVBOs                                                                                                                         =
 //=====================================================================================================================================
 //=====================================================================================================================================
-void mesh_t::CreateVBOs()
+void Mesh::createVBOs()
 {
 {
-	vbos.vert_indeces.Create( GL_ELEMENT_ARRAY_BUFFER, vert_indeces.GetSizeInBytes(), &vert_indeces[0], GL_STATIC_DRAW );
-	vbos.vert_coords.Create( GL_ARRAY_BUFFER, vert_coords.GetSizeInBytes(), &vert_coords[0], GL_STATIC_DRAW );
-	vbos.vert_normals.Create( GL_ARRAY_BUFFER, vert_normals.GetSizeInBytes(), &vert_normals[0], GL_STATIC_DRAW );
-	if( vert_tangents.size() > 1 )
-		vbos.vert_tangents.Create( GL_ARRAY_BUFFER, vert_tangents.GetSizeInBytes(), &vert_tangents[0], GL_STATIC_DRAW );
-	if( tex_coords.size() > 1 )
-		vbos.tex_coords.Create( GL_ARRAY_BUFFER, tex_coords.GetSizeInBytes(), &tex_coords[0], GL_STATIC_DRAW );
-	if( vert_weights.size() > 1 )
-		vbos.vert_weights.Create( GL_ARRAY_BUFFER, vert_weights.GetSizeInBytes(), &vert_weights[0], GL_STATIC_DRAW );
+	vbos.vertIndeces.Create( GL_ELEMENT_ARRAY_BUFFER, vertIndeces.GetSizeInBytes(), &vertIndeces[0], GL_STATIC_DRAW );
+	vbos.vertCoords.Create( GL_ARRAY_BUFFER, vertCoords.GetSizeInBytes(), &vertCoords[0], GL_STATIC_DRAW );
+	vbos.vertNormals.Create( GL_ARRAY_BUFFER, vertNormals.GetSizeInBytes(), &vertNormals[0], GL_STATIC_DRAW );
+	if( vertTangents.size() > 1 )
+		vbos.vertTangents.Create( GL_ARRAY_BUFFER, vertTangents.GetSizeInBytes(), &vertTangents[0], GL_STATIC_DRAW );
+	if( texCoords.size() > 1 )
+		vbos.texCoords.Create( GL_ARRAY_BUFFER, texCoords.GetSizeInBytes(), &texCoords[0], GL_STATIC_DRAW );
+	if( vertWeights.size() > 1 )
+		vbos.vertWeights.Create( GL_ARRAY_BUFFER, vertWeights.GetSizeInBytes(), &vertWeights[0], GL_STATIC_DRAW );
 }
 }
 
 
 
 
 //=====================================================================================================================================
 //=====================================================================================================================================
-// CalcBSphere                                                                                                                        =
+// calcBSphere                                                                                                                        =
 //=====================================================================================================================================
 //=====================================================================================================================================
-void mesh_t::CalcBSphere()
+void Mesh::calcBSphere()
 {
 {
-	bsphere.Set( &vert_coords[0], 0, vert_coords.size() );
+	bsphere.Set( &vertCoords[0], 0, vertCoords.size() );
 }
 }

+ 75 - 0
src/resources/Mesh.h

@@ -0,0 +1,75 @@
+#ifndef _MESH_H_
+#define _MESH_H_
+
+#include "common.h"
+#include "gmath.h"
+#include "vbo.h"
+#include "Resource.h"
+#include "collision.h"
+
+
+/// Mesh resource
+class Mesh: public Resource
+{
+	// data
+	public:
+		class VertexWeight
+		{
+			public:
+				static const uint MAX_BONES_PER_VERT = 4; ///< Dont change or change the skinning code in shader
+
+				// ToDo: change the vals to uint when change drivers
+				float bonesNum;
+				float boneIds[MAX_BONES_PER_VERT];
+				float weights[MAX_BONES_PER_VERT];
+		};
+
+		class Triangle
+		{
+			public:
+				uint   vertIds[3]; // an array with the vertex indexes in the mesh class
+				vec3_t normal;
+		};
+
+		Vec<vec3_t>       vertCoords;
+		Vec<vec3_t>       vertNormals;
+		Vec<vec4_t>       vertTangents;
+		Vec<vec2_t>       texCoords;    ///< One for every vert so we can use vertex arrays
+		Vec<VertexWeight> vertWeights;
+		Vec<Triangle>     tris;
+		Vec<ushort>       vertIndeces; ///< Used for vertex arrays
+
+		struct
+		{
+			vbo_t vertCoords;
+			vbo_t vertNormals;
+			vbo_t vertTangents;
+			vbo_t texCoords;
+			vbo_t vertIndeces;
+			vbo_t vertWeights;
+		} vbos;
+
+		string materialName;
+
+		bsphere_t bsphere;
+
+	// funcs
+	protected:
+		void createFaceNormals();
+		void createVertNormals();
+		void createAllNormals() { createFaceNormals(); createVertNormals(); }
+		void createVertTangents();
+		void createVertIndeces();
+		void createVBOs();
+		void calcBSphere();
+
+	public:
+		Mesh() {}
+		virtual ~Mesh() { /*ToDo*/ }
+		bool load( const char* filename );
+		void unload();
+
+};
+
+
+#endif

+ 25 - 0
src/resources/Path.h

@@ -0,0 +1,25 @@
+#ifndef _PATH_H_
+#define _PATH_H_
+
+#include "common.h"
+#include "Resource.h"
+#include "gmath.h"
+
+
+/// Path resource
+class Path: public Resource
+{
+	public:
+		Vec<vec3_t> positions; ///< AKA translations
+		Vec<mat3_t> rotations;
+		Vec<float>  scales;
+		float         step;
+
+		Path() {}
+		~Path() {}
+		bool load( const char* filename );
+		void unload() { points.clear(); }
+};
+
+
+#endif

+ 14 - 14
src/resources/resource.cpp → src/resources/Resource.cpp

@@ -1,10 +1,10 @@
-#include "resource.h"
-#include "texture.h"
-#include "material.h"
-#include "shader_prog.h"
-#include "mesh.h"
-#include "skel_anim.h"
-#include "light_props.h"
+#include "Resource.h"
+#include "Texture.h"
+#include "Material.h"
+#include "ShaderProg.h"
+#include "Mesh.h"
+#include "SkelAnim.h"
+#include "LightProps.h"
 
 
 
 
 namespace rsrc {
 namespace rsrc {
@@ -15,12 +15,12 @@ namespace rsrc {
 DATA OBJECTS                                                                                                                          =
 DATA OBJECTS                                                                                                                          =
 =======================================================================================================================================
 =======================================================================================================================================
 */
 */
-container_t<texture_t>     textures;
-container_t<shader_prog_t> shaders;
-container_t<material_t>    materials;
-container_t<mesh_t>        meshes;
-container_t<skeleton_t>    skeletons;
-container_t<skel_anim_t>   skel_anims;
-container_t<light_props_t> light_props;
+Container<Texture>     textures;
+Container<ShaderProg> shaders;
+Container<Material>    materials;
+Container<Mesh>        meshes;
+Container<Skeleton>    skeletons;
+Container<SkelAnim>   skel_anims;
+Container<LightProps> light_props;
 
 
 } // end namespace
 } // end namespace

+ 197 - 0
src/resources/Resource.h

@@ -0,0 +1,197 @@
+#ifndef _RESOURCE_H_
+#define _RESOURCE_H_
+
+#include "common.h"
+#include "engine_class.h"
+#include "util.h"
+
+
+// forward decls
+class Texture;
+class Material;
+class ShaderProg;
+class Mesh;
+class Skeleton;
+class SkelAnim;
+class LightProps;
+
+namespace rsrc {
+template< typename Type > class Container;
+}
+
+
+/**
+ * Every class that it is considered resource should be derivative of this one. This step is not
+ * necessary because of the Container template but ensures that loading will be made by the
+ * resource manager and not the class itself
+ */
+class Resource
+{
+	PROPERTY_R( string, path, getPath );
+	PROPERTY_R( string, name, getName );
+	PROPERTY_R( uint, usersNum, getUsersNum );
+
+	// friends
+	friend class rsrc::Container<Texture>;
+	friend class rsrc::Container<Material>;
+	friend class rsrc::Container<ShaderProg>;
+	friend class rsrc::Container<Skeleton>;
+	friend class rsrc::Container<Mesh>;
+	friend class rsrc::Container<SkelAnim>;
+	friend class rsrc::Container<LightProps>;
+	friend class ShaderProg;
+
+	public:
+		virtual bool load( const char* ) = 0;
+		virtual void unload() = 0;
+
+		Resource(): usersNum(0) {}
+		virtual ~Resource() {};
+};
+
+
+/// resource namespace
+namespace rsrc {
+
+
+extern Container<Texture>     textures;
+extern Container<ShaderProg> shaders;
+extern Container<Material>    materials;
+extern Container<Mesh>        meshes;
+extern Container<Skeleton>    skeletons;
+extern Container<SkelAnim>   skel_anims;
+extern Container<LightProps> light_props;
+
+
+/// resource container template class
+template<typename Type> class Container: public Vec<Type*>
+{
+	private:
+		typedef typename Container<Type>::iterator Iterator; ///< Just to save me time from typing
+		typedef Vec<Type*> BaseClass;
+
+		/**
+		 * Search inside the container by name
+		 * @param name The name of the resource
+		 * @return The iterator of the content end of vector if not found
+		 */
+		Iterator findByName( const char* name )
+		{
+			Iterator it = BaseClass::begin();
+			while( it != BaseClass::end() )
+			{
+				if( (*it).name == name )
+					return it;
+				++it;
+			}
+
+			return it;
+		}
+
+
+		/**
+		 * Search inside the container by name and path
+		 * @param name The name of the resource
+		 * @param path The path of the resource
+		 * @return The iterator of the content end of vector if not found
+		 */
+		Iterator findByNameAndPath( const char* name, const char* path )
+		{
+			Iterator it = BaseClass::begin();
+			while( it != BaseClass::end() )
+			{
+				if( (*it)->name == name && (*it)->path == path )
+					return it;
+				++it;
+			}
+
+			return it;
+		}
+
+
+		/**
+	   * Search inside the container by pointer
+		 * @param name The name of the resource object
+		 * @return The iterator of the content end of vector if not found
+		 */
+		Iterator findByPtr( Type* ptr )
+		{
+			Iterator it = BaseClass::begin();
+			while( it != BaseClass::end() )
+			{
+				if( ptr == (*it) )
+					return it;
+				++it;
+			}
+
+			return it;
+		}
+
+		public:
+		/**
+		 * load an object and register it. If its allready loaded return its pointer
+		 * @param fname The filename that initializes the object
+		 * @return A pointer of a new resource or NULL on fail
+		 */
+		Type* load( const char* fname )
+		{
+			char* name = util::CutPath( fname );
+			string path = util::GetPath( fname );
+			Iterator it = findByNameAndPath( name, path.c_str() );
+
+			// if allready loaded then inc the users and return the pointer
+			if( it != BaseClass::end() )
+			{
+				++ (*it)->usersNum;
+				return (*it);
+			}
+
+			// else create new, loaded and update the container
+			Type* new_instance = new Type();
+			new_instance->name = name;
+			new_instance->path = path;
+			new_instance->usersNum = 1;
+
+			if( !new_instance->load( fname ) )
+			{
+				ERROR( "Cannot load \"" << fname << '\"' );
+				delete new_instance;
+				return NULL;
+			}
+			BaseClass::push_back( new_instance );
+
+			return new_instance;
+		}
+
+
+		/**
+		 * unload item. If nobody else uses it then delete it completely
+		 * @param x Pointer to the instance we want to unload
+		 */
+		void unload( Type* x )
+		{
+			Iterator it = findByPtr( x );
+			if( it == BaseClass::end() )
+			{
+				ERROR( "Cannot find resource with pointer 0x" << x );
+				return;
+			}
+
+			Type* del_ = (*it);
+			DEBUG_ERR( del_->usersNum < 1 ); // WTF?
+
+			--del_->usersNum;
+
+			// if no other users then call unload and update the container
+			if( del_->usersNum == 0 )
+			{
+				del_->unload();
+				delete del_;
+				BaseClass::erase( it );
+			}
+		}
+}; // end class Container
+
+
+} // end namespace
+#endif

+ 73 - 73
src/resources/ShaderParser.cpp

@@ -6,40 +6,40 @@
 
 
 
 
 //=====================================================================================================================================
 //=====================================================================================================================================
-// FindShaderVar                                                                                                                      =
+// printSourceLines                                                                                                                   =
 //=====================================================================================================================================
 //=====================================================================================================================================
-void ShaderParser::PrintSourceLines() const
+void ShaderParser::printSourceLines() const
 {
 {
-	for( uint i=0; i<source_lines.size(); ++i )
+	for( uint i=0; i<sourceLines.size(); ++i )
 	{
 	{
-		PRINT( setw(3) << i+1 << ": " << source_lines[i] );
+		PRINT( setw(3) << i+1 << ": " << sourceLines[i] );
 	}
 	}
 }
 }
 
 
 
 
 //=====================================================================================================================================
 //=====================================================================================================================================
-// PrintShaderVars                                                                                                                    =
+// printShaderVars                                                                                                                    =
 //=====================================================================================================================================
 //=====================================================================================================================================
-void ShaderParser::PrintShaderVars() const
+void ShaderParser::printShaderVars() const
 {
 {
 	PRINT( "TYPE" << setw(20) << "NAME" << setw(4) << "LOC" );
 	PRINT( "TYPE" << setw(20) << "NAME" << setw(4) << "LOC" );
-	for( uint i=0; i<uniforms.size(); ++i )
+	for( uint i=0; i<output.uniforms.size(); ++i )
 	{
 	{
-		PRINT( setw(4) << "U" << setw(20) << uniforms[i].name << setw(4) << uniforms[i].custom_loc );
+		PRINT( setw(4) << "U" << setw(20) << output.uniforms[i].name << setw(4) << output.uniforms[i].customLoc );
 	}
 	}
-	for( uint i=0; i<attributes.size(); ++i )
+	for( uint i=0; i<output.attributes.size(); ++i )
 	{
 	{
-		PRINT( setw(4) << "A" << setw(20) << attributes[i].name << setw(4) << attributes[i].custom_loc );
+		PRINT( setw(4) << "A" << setw(20) << output.attributes[i].name << setw(4) << output.attributes[i].customLoc );
 	}
 	}
 }
 }
 
 
 
 
 //=====================================================================================================================================
 //=====================================================================================================================================
-// FindShaderVar                                                                                                                      =
+// findShaderVar                                                                                                                      =
 //=====================================================================================================================================
 //=====================================================================================================================================
-vec_t<ShaderParser::ShaderVarPragma>::iterator ShaderParser::FindShaderVar( vec_t<ShaderVarPragma>& vec, const string& name ) const
+Vec<ShaderParser::ShaderVarPragma>::iterator ShaderParser::findShaderVar( Vec<ShaderVarPragma>& vec, const string& name ) const
 {
 {
-	vec_t<ShaderVarPragma>::iterator it = vec.begin();
+	Vec<ShaderVarPragma>::iterator it = vec.begin();
 	while( it != vec.end() && it->name != name )
 	while( it != vec.end() && it->name != name )
 	{
 	{
 		++it;
 		++it;
@@ -49,12 +49,12 @@ vec_t<ShaderParser::ShaderVarPragma>::iterator ShaderParser::FindShaderVar( vec_
 
 
 
 
 //=====================================================================================================================================
 //=====================================================================================================================================
-// ParseFileForPragmas                                                                                                                =
+// parseFileForPragmas                                                                                                                =
 //=====================================================================================================================================
 //=====================================================================================================================================
-bool ShaderParser::ParseFileForPragmas( const string& filename, int id )
+bool ShaderParser::parseFileForPragmas( const string& filename, int id )
 {
 {
 	// load file in lines
 	// load file in lines
-	vec_t<string> lines = util::GetFileLines( filename.c_str() );
+	Vec<string> lines = util::GetFileLines( filename.c_str() );
 	if( lines.size() < 1 )
 	if( lines.size() < 1 )
 	{
 	{
 		ERROR( "Cannot parse file \"" << filename << "\"" );
 		ERROR( "Cannot parse file \"" << filename << "\"" );
@@ -80,49 +80,49 @@ bool ShaderParser::ParseFileForPragmas( const string& filename, int id )
 				if( token->code == Scanner::TC_IDENTIFIER && strcmp(token->value.string, "anki") == 0 )
 				if( token->code == Scanner::TC_IDENTIFIER && strcmp(token->value.string, "anki") == 0 )
 				{
 				{
 					token = &scanner.getNextToken();
 					token = &scanner.getNextToken();
-/* vert_shader_begins */
-					if( token->code == Scanner::TC_IDENTIFIER && strcmp(token->value.string, "vert_shader_begins") == 0 )
+/* vertShaderBegins */
+					if( token->code == Scanner::TC_IDENTIFIER && strcmp(token->value.string, "vertShaderBegins") == 0 )
 					{
 					{
 						// play
 						// play
-						if( frag_shader_begins.defined_in_line != -1 ) // check if frag shader allready defined
+						if( fragShaderBegins.definedInLine != -1 ) // check if frag shader allready defined
 						{
 						{
-							PARSE_ERR( "vert_shader_begins must precede frag_shader_begins defined at " << frag_shader_begins.definedInFile <<
-							           ":" << frag_shader_begins.defined_in_line );
+							PARSE_ERR( "vertShaderBegins must precede fragShaderBegins defined at " << fragShaderBegins.definedInFile <<
+							           ":" << fragShaderBegins.definedInLine );
 							return false;
 							return false;
 						}
 						}
 						
 						
-						if( vert_shader_begins.defined_in_line != -1 ) // allready defined elseware so throw error
+						if( vertShaderBegins.definedInLine != -1 ) // allready defined elseware so throw error
 						{
 						{
-							PARSE_ERR( "vert_shader_begins allready defined at " << vert_shader_begins.definedInFile << ":" <<
-							           vert_shader_begins.defined_in_line );
+							PARSE_ERR( "vertShaderBegins allready defined at " << vertShaderBegins.definedInFile << ":" <<
+							           vertShaderBegins.definedInLine );
 							return false;
 							return false;
 						}
 						}
-						vert_shader_begins.definedInFile = filename;
-						vert_shader_begins.defined_in_line = scanner.getLineNmbr();
-						vert_shader_begins.global_line = source_lines.size() + 1;
-						source_lines.push_back( string("#line ") + IntToStr(scanner.getLineNmbr()) + ' ' + IntToStr(id) + " // " + lines[scanner.getLineNmbr()-1] );
+						vertShaderBegins.definedInFile = filename;
+						vertShaderBegins.definedInLine = scanner.getLineNmbr();
+						vertShaderBegins.globalLine = sourceLines.size() + 1;
+						sourceLines.push_back( string("#line ") + IntToStr(scanner.getLineNmbr()) + ' ' + IntToStr(id) + " // " + lines[scanner.getLineNmbr()-1] );
 						// stop play
 						// stop play
 					}
 					}
-/* frag_shader_begins */
-					else if( token->code == Scanner::TC_IDENTIFIER && strcmp(token->value.string, "frag_shader_begins") == 0 )
+/* fragShaderBegins */
+					else if( token->code == Scanner::TC_IDENTIFIER && strcmp(token->value.string, "fragShaderBegins") == 0 )
 					{
 					{
 						// play
 						// play
-						if( vert_shader_begins.defined_in_line == -1 )
+						if( vertShaderBegins.definedInLine == -1 )
 						{
 						{
-							PARSE_ERR( "frag_shader_begins should be defined after vert_shader_begins" );
+							PARSE_ERR( "fragShaderBegins should be defined after vertShaderBegins" );
 							return false;
 							return false;
 						}
 						}
 						
 						
-						if( frag_shader_begins.defined_in_line != -1 ) // if allready defined elseware throw error
+						if( fragShaderBegins.definedInLine != -1 ) // if allready defined elseware throw error
 						{
 						{
-							PARSE_ERR( "frag_shader_begins allready defined at " << frag_shader_begins.definedInFile << ":" <<
-							           frag_shader_begins.defined_in_line );
+							PARSE_ERR( "fragShaderBegins allready defined at " << fragShaderBegins.definedInFile << ":" <<
+							           fragShaderBegins.definedInLine );
 							return false;
 							return false;
 						}
 						}
-						frag_shader_begins.definedInFile = filename;
-						frag_shader_begins.defined_in_line = scanner.getLineNmbr();
-						frag_shader_begins.global_line = source_lines.size() + 1;
-						source_lines.push_back( string("#line ") + IntToStr(scanner.getLineNmbr()) + ' ' + IntToStr(id) + " // " + lines[scanner.getLineNmbr()-1] );
+						fragShaderBegins.definedInFile = filename;
+						fragShaderBegins.definedInLine = scanner.getLineNmbr();
+						fragShaderBegins.globalLine = sourceLines.size() + 1;
+						sourceLines.push_back( string("#line ") + IntToStr(scanner.getLineNmbr()) + ' ' + IntToStr(id) + " // " + lines[scanner.getLineNmbr()-1] );
 						// stop play
 						// stop play
 					}
 					}
 /* include */
 /* include */
@@ -132,10 +132,10 @@ bool ShaderParser::ParseFileForPragmas( const string& filename, int id )
 						if( token->code == Scanner::TC_STRING )
 						if( token->code == Scanner::TC_STRING )
 						{
 						{
 							// play
 							// play
-							//int line = source_lines.size();
-							source_lines.push_back( string("#line 0 ") + IntToStr(id+1) + " // " + lines[scanner.getLineNmbr()-1] );
-							if( !ParseFileForPragmas( token->value.string, id+1 ) ) return false;
-							source_lines.push_back( string("#line ") + IntToStr(scanner.getLineNmbr()) + ' ' + IntToStr(id) +  " // end of " + lines[scanner.getLineNmbr()-1] );
+							//int line = sourceLines.size();
+							sourceLines.push_back( string("#line 0 ") + IntToStr(id+1) + " // " + lines[scanner.getLineNmbr()-1] );
+							if( !parseFileForPragmas( token->value.string, id+1 ) ) return false;
+							sourceLines.push_back( string("#line ") + IntToStr(scanner.getLineNmbr()) + ' ' + IntToStr(id) +  " // end of " + lines[scanner.getLineNmbr()-1] );
 							// stop play
 							// stop play
 						}
 						}
 						else
 						else
@@ -155,15 +155,15 @@ bool ShaderParser::ParseFileForPragmas( const string& filename, int id )
 							if( token->code == Scanner::TC_NUMBER && token->type == Scanner::DT_INT )
 							if( token->code == Scanner::TC_NUMBER && token->type == Scanner::DT_INT )
 							{
 							{
 								// play
 								// play
-								vec_t<ShaderVarPragma>::iterator uniform = FindShaderVar( uniforms, var_name );
-								if( uniform != uniforms.end() )
+								Vec<ShaderVarPragma>::iterator uniform = findShaderVar( output.uniforms, var_name );
+								if( uniform != output.uniforms.end() )
 								{
 								{
-									PARSE_ERR( "Uniform allready defined at " << uniform->definedInFile << ":" << uniform->defined_in_line );
+									PARSE_ERR( "Uniform allready defined at " << uniform->definedInFile << ":" << uniform->definedInLine );
 									return false;
 									return false;
 								}
 								}
 								
 								
-								uniforms.push_back( ShaderVarPragma( filename, scanner.getLineNmbr(), var_name, token->value.int_ ) );
-								source_lines.push_back( lines[scanner.getLineNmbr()-1] );
+								output.uniforms.push_back( ShaderVarPragma( filename, scanner.getLineNmbr(), var_name, token->value.int_ ) );
+								sourceLines.push_back( lines[scanner.getLineNmbr()-1] );
 								// stop play
 								// stop play
 							}
 							}
 							else
 							else
@@ -189,15 +189,15 @@ bool ShaderParser::ParseFileForPragmas( const string& filename, int id )
 							if( token->code == Scanner::TC_NUMBER && token->type == Scanner::DT_INT )
 							if( token->code == Scanner::TC_NUMBER && token->type == Scanner::DT_INT )
 							{
 							{
 								// play
 								// play
-								vec_t<ShaderVarPragma>::iterator attrib = FindShaderVar( attributes, var_name );
-								if( attrib != attributes.end() )
+								Vec<ShaderVarPragma>::iterator attrib = findShaderVar( output.attributes, var_name );
+								if( attrib != output.attributes.end() )
 								{
 								{
-									PARSE_ERR( "Attribute allready defined at " << attrib->definedInFile << ":" << attrib->defined_in_line );
+									PARSE_ERR( "Attribute allready defined at " << attrib->definedInFile << ":" << attrib->definedInLine );
 									return false;
 									return false;
 								}
 								}
 								
 								
-								attributes.push_back( ShaderVarPragma( filename, scanner.getLineNmbr(), var_name, token->value.int_ ) );
-								source_lines.push_back( lines[scanner.getLineNmbr()-1] );
+								output.attributes.push_back( ShaderVarPragma( filename, scanner.getLineNmbr(), var_name, token->value.int_ ) );
+								sourceLines.push_back( lines[scanner.getLineNmbr()-1] );
 								// stop play
 								// stop play
 							}
 							}
 							else
 							else
@@ -233,13 +233,13 @@ bool ShaderParser::ParseFileForPragmas( const string& filename, int id )
 /* newline */		
 /* newline */		
 		else if( token->code == Scanner::TC_NEWLINE )
 		else if( token->code == Scanner::TC_NEWLINE )
 		{
 		{
-			source_lines.push_back( lines[ scanner.getLineNmbr() - 2 ] );
+			sourceLines.push_back( lines[ scanner.getLineNmbr() - 2 ] );
 			//PRINT( lines[ scanner.getLineNmbr() - 2 ] )
 			//PRINT( lines[ scanner.getLineNmbr() - 2 ] )
 		}
 		}
 /* EOF */
 /* EOF */
 		else if( token->code == Scanner::TC_EOF )
 		else if( token->code == Scanner::TC_EOF )
 		{
 		{
-			source_lines.push_back( lines[ scanner.getLineNmbr() - 1 ] );
+			sourceLines.push_back( lines[ scanner.getLineNmbr() - 1 ] );
 			//PRINT( lines[ scanner.getLineNmbr() - 1 ] )
 			//PRINT( lines[ scanner.getLineNmbr() - 1 ] )
 			break;
 			break;
 		}
 		}
@@ -256,44 +256,44 @@ bool ShaderParser::ParseFileForPragmas( const string& filename, int id )
 
 
 
 
 //=====================================================================================================================================
 //=====================================================================================================================================
-// Load                                                                                                                               =
+// parseFile                                                                                                                          =
 //=====================================================================================================================================
 //=====================================================================================================================================
-bool ShaderParser::ParseFile( const char* filename )
+bool ShaderParser::parseFile( const char* filename )
 {
 {
 	// parse master file
 	// parse master file
-	if( !ParseFileForPragmas( filename ) ) return false;
+	if( !parseFileForPragmas( filename ) ) return false;
 
 
 	// sanity checks
 	// sanity checks
-	if( vert_shader_begins.global_line == -1 )
+	if( vertShaderBegins.globalLine == -1 )
 	{
 	{
-		ERROR( "Entry point \"vert_shader_begins\" is not defined in file \"" << filename << "\"" );
+		ERROR( "Entry point \"vertShaderBegins\" is not defined in file \"" << filename << "\"" );
 		return false;
 		return false;
 	}
 	}
-	if( frag_shader_begins.global_line == -1 )
+	if( fragShaderBegins.globalLine == -1 )
 	{
 	{
-		ERROR( "Entry point \"frag_shader_begins\" is not defined in file \"" << filename << "\"" );
+		ERROR( "Entry point \"fragShaderBegins\" is not defined in file \"" << filename << "\"" );
 		return false;
 		return false;
 	}
 	}
 	
 	
 	// construct shader's source code
 	// construct shader's source code
-	vert_shader_source = "";
-	frag_shader_source = "";
-	for( int i=0; i<vert_shader_begins.global_line-1; ++i )
+	output.vertShaderSource = "";
+	output.fragShaderSource = "";
+	for( int i=0; i<vertShaderBegins.globalLine-1; ++i )
 	{
 	{
-		vert_shader_source += source_lines[i] + "\n";
-		frag_shader_source += source_lines[i] + "\n";
+		output.vertShaderSource += sourceLines[i] + "\n";
+		output.fragShaderSource += sourceLines[i] + "\n";
 	}	
 	}	
-	for( int i=vert_shader_begins.global_line-1; i<frag_shader_begins.global_line-1; ++i )
+	for( int i=vertShaderBegins.globalLine-1; i<fragShaderBegins.globalLine-1; ++i )
 	{
 	{
-		vert_shader_source += source_lines[i] + "\n";
+		output.vertShaderSource += sourceLines[i] + "\n";
 	}
 	}
-	for( int i=frag_shader_begins.global_line-1; i<int(source_lines.size()); ++i )
+	for( int i=fragShaderBegins.globalLine-1; i<int(sourceLines.size()); ++i )
 	{
 	{
-		frag_shader_source += source_lines[i] + "\n";
+		output.fragShaderSource += sourceLines[i] + "\n";
 	}
 	}
 	
 	
-	//PRINT( "vert_shader_begins.global_line: " << vert_shader_begins.global_line )
-	//PRINT( "frag_shader_begins.global_line: " << frag_shader_begins.global_line )
+	//PRINT( "vertShaderBegins.globalLine: " << vertShaderBegins.globalLine )
+	//PRINT( "fragShaderBegins.globalLine: " << fragShaderBegins.globalLine )
 	//PrintSourceLines();
 	//PrintSourceLines();
 	//PrintShaderVars();
 	//PrintShaderVars();
 
 

+ 66 - 25
src/resources/ShaderParser.h

@@ -7,7 +7,7 @@
 
 
 /**
 /**
  * The class fills some of the GLSL spec deficiencies. It adds the include preprocessor directive and the support to have all the
  * 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
+ * shaders in the same file. The file that includes all the shaders is called ShaderParser-compatible
  */
  */
 class ShaderParser
 class ShaderParser
 {
 {
@@ -19,10 +19,10 @@ class ShaderParser
 		{
 		{
 			
 			
 			string definedInFile;
 			string definedInFile;
-			int    defined_in_line;
-			Pragma(): defined_in_line(-1) {}
-			Pragma( const string& definedInFile_, int defined_in_line_ ):
-				definedInFile(definedInFile_), defined_in_line(defined_in_line_)
+			int    definedInLine;
+			Pragma(): definedInLine(-1) {}
+			Pragma( const string& definedInFile_, int definedInLine_ ):
+				definedInFile(definedInFile_), definedInLine(definedInLine_)
 			{}
 			{}
 		};
 		};
 		
 		
@@ -34,39 +34,80 @@ class ShaderParser
 		struct ShaderVarPragma: Pragma
 		struct ShaderVarPragma: Pragma
 		{
 		{
 			string name;
 			string name;
-			uint   custom_loc;
-			ShaderVarPragma( const string& defined_in_file_, int defined_in_line_, const string& name_, uint custom_loc_ ):
-				Pragma( defined_in_file_, defined_in_line_ ), name(name_), custom_loc(custom_loc_)
+			uint   customLoc;
+			ShaderVarPragma( const string& definedInFile_, int definedInLine_, const string& name_, uint customLoc_ ):
+				Pragma( definedInFile_, definedInLine_ ), name(name_), customLoc(customLoc_)
 			{}
 			{}
 		};
 		};
 	
 	
-		struct code_beginning_t: Pragma
+		struct CodeBeginningPragma: Pragma
 		{
 		{
-			int global_line;
+			int globalLine; ///< The line number in the ShaderParser-compatible file
 
 
-			code_beginning_t(): global_line(-1) {}
+			CodeBeginningPragma(): globalLine(-1) {}
 		};
 		};
 		
 		
-		vec_t<string> source_lines;
-		code_beginning_t vert_shader_begins;
-		code_beginning_t frag_shader_begins;
+		Vec<string> sourceLines;  ///< The parseFileForPragmas fills this
+		CodeBeginningPragma vertShaderBegins;
+		CodeBeginningPragma fragShaderBegins;
 		
 		
-		bool ParseFileForPragmas( const string& filename, int id = 0 );
-		vec_t<ShaderVarPragma>::iterator FindShaderVar( vec_t<ShaderVarPragma>& vec, const string& name ) const;
-		void PrintSourceLines() const;  ///< For debugging
-		void PrintShaderVars() const;  ///< For debugging
+		/**
+		 * 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
+		 * @return True on success
+		 */
+		bool parseFileForPragmas( const string& filename, int id = 0 );
+
+		/**
+		 * Searches inside the Output::uniforms or Output::attributes vectors
+		 * @param vec Output::uniforms or Output::attributes
+		 * @param name The name of the location
+		 * @return Iterator to the vector
+		 */
+		Vec<ShaderVarPragma>::iterator findShaderVar( Vec<ShaderVarPragma>& vec, const string& name ) const;
+
+		void printSourceLines() const;  ///< For debugging
+		void printShaderVars() const;  ///< For debugging
+
+		/**
+		 * The output of the class packed in this struct
+		 */
+		struct Output
+		{
+			friend class ShaderParser;
+
+			private:
+				Vec<ShaderVarPragma> uniforms;  ///< It holds the name and the custom location
+				Vec<ShaderVarPragma> attributes;  ///< It holds the name and the custom location
+				string vertShaderSource; ///< This is the vert shader source
+				string fragShaderSource; ///< This is the frag shader source
+
+			public:
+				const Vec<ShaderVarPragma>& getUniLocs() const { return uniforms; }
+				const Vec<ShaderVarPragma>& getAttribLocs() const { return attributes; }
+				const string& getVertShaderSource() const { return vertShaderSource; }
+				const string& getFragShaderSource() const { return fragShaderSource; }
+		};
+
+		Output output; ///< The output of the parser. parseFile fills it
 
 
 	public:
 	public:
-		// the output
-		vec_t<ShaderVarPragma> uniforms;
-		vec_t<ShaderVarPragma> attributes;
-		string vert_shader_source;
-		string frag_shader_source;
-		
 		ShaderParser() {}
 		ShaderParser() {}
 		~ShaderParser() {}
 		~ShaderParser() {}
 
 
-		bool ParseFile( const char* fname ); ///< Parse a file and its includes 
+		/**
+		 * Parse a ShaderParser formated GLSL file. Use getOutput to get the output
+		 * @param fname The file to parse
+		 * @return True on success
+		 */
+		bool parseFile( const char* fname );
+
+		/**
+		 * Wrapper func to get the output. Use it after calling parseFile
+		 * @return The output
+		 */
+		const Output& getOutput() const { return output; }
 };
 };
 
 
 
 

+ 106 - 106
src/resources/shader_prog.cpp → src/resources/ShaderProg.cpp

@@ -1,35 +1,35 @@
-#include "shader_prog.h"
+#include "ShaderProg.h"
 #include "renderer.h"
 #include "renderer.h"
 #include "ShaderParser.h"
 #include "ShaderParser.h"
-#include "texture.h"
+#include "Texture.h"
 
 
 
 
-#define SHADER_ERROR( x ) ERROR( "Shader (" << GetName() << "): " << x )
-#define SHADER_WARNING( x ) WARNING( "Shader (" << GetName() << "): " << x )
+#define SHADER_ERROR( x ) ERROR( "Shader (" << getName() << "): " << x )
+#define SHADER_WARNING( x ) WARNING( "Shader (" << getName() << "): " << x )
 
 
 
 
 
 
 //=====================================================================================================================================
 //=====================================================================================================================================
-// CreateAndCompileShader                                                                                                             =
+// createAndCompileShader                                                                                                             =
 //=====================================================================================================================================
 //=====================================================================================================================================
-uint shader_prog_t::CreateAndCompileShader( const char* source_code, const char* preproc, int type ) const
+uint ShaderProg::createAndCompileShader( const char* source_code, const char* preproc, int type ) const
 {
 {
-	uint gl_id = 0;
+	uint glId = 0;
 	const char* source_strs[2] = {NULL, NULL};
 	const char* source_strs[2] = {NULL, NULL};
 
 
 	// create the shader
 	// create the shader
-	gl_id = glCreateShader( type );
+	glId = glCreateShader( type );
 
 
 	// attach the source
 	// attach the source
 	source_strs[1] = source_code;
 	source_strs[1] = source_code;
 	source_strs[0] = preproc;
 	source_strs[0] = preproc;
 
 
 	// compile
 	// compile
-	glShaderSource( gl_id, 2, source_strs, NULL );
-	glCompileShader( gl_id );
+	glShaderSource( glId, 2, source_strs, NULL );
+	glCompileShader( glId );
 
 
 	int success;
 	int success;
-	glGetShaderiv( gl_id, GL_COMPILE_STATUS, &success );
+	glGetShaderiv( glId, GL_COMPILE_STATUS, &success );
 
 
 	if( !success )
 	if( !success )
 	{
 	{
@@ -38,9 +38,9 @@ uint shader_prog_t::CreateAndCompileShader( const char* source_code, const char*
 		int chars_written = 0;
 		int chars_written = 0;
 		char* info_log = NULL;
 		char* info_log = NULL;
 
 
-		glGetShaderiv( gl_id, GL_INFO_LOG_LENGTH, &info_len );
+		glGetShaderiv( glId, GL_INFO_LOG_LENGTH, &info_len );
 		info_log = (char*)malloc( (info_len+1)*sizeof(char) );
 		info_log = (char*)malloc( (info_len+1)*sizeof(char) );
-		glGetShaderInfoLog( gl_id, info_len, &chars_written, info_log );
+		glGetShaderInfoLog( glId, info_len, &chars_written, info_log );
 		
 		
 		const char* shader_type;
 		const char* shader_type;
 		switch( type )
 		switch( type )
@@ -60,21 +60,21 @@ uint shader_prog_t::CreateAndCompileShader( const char* source_code, const char*
 		return 0;
 		return 0;
 	}
 	}
 
 
-	return gl_id;
+	return glId;
 }
 }
 
 
 
 
 //=====================================================================================================================================
 //=====================================================================================================================================
-// Link                                                                                                                               =
+// link                                                                                                                               =
 //=====================================================================================================================================
 //=====================================================================================================================================
-bool shader_prog_t::Link()
+bool ShaderProg::link()
 {
 {
 	// link
 	// link
-	glLinkProgram( gl_id );
+	glLinkProgram( glId );
 
 
 	// check if linked correctly
 	// check if linked correctly
 	int success;
 	int success;
-	glGetProgramiv( gl_id, GL_LINK_STATUS, &success );
+	glGetProgramiv( glId, GL_LINK_STATUS, &success );
 
 
 	if( !success )
 	if( !success )
 	{
 	{
@@ -82,10 +82,10 @@ bool shader_prog_t::Link()
 		int chars_written = 0;
 		int chars_written = 0;
 		char* info_log_txt = NULL;
 		char* info_log_txt = NULL;
 
 
-		glGetProgramiv( gl_id, GL_INFO_LOG_LENGTH, &info_len );
+		glGetProgramiv( glId, GL_INFO_LOG_LENGTH, &info_len );
 
 
 		info_log_txt = (char*)malloc( (info_len+1)*sizeof(char) );
 		info_log_txt = (char*)malloc( (info_len+1)*sizeof(char) );
-		glGetProgramInfoLog( gl_id, info_len, &chars_written, info_log_txt );
+		glGetProgramInfoLog( glId, info_len, &chars_written, info_log_txt );
 		SHADER_ERROR( "Link log follows:\n" << info_log_txt );
 		SHADER_ERROR( "Link log follows:\n" << info_log_txt );
 		free( info_log_txt );
 		free( info_log_txt );
 		return false;
 		return false;
@@ -96,9 +96,9 @@ bool shader_prog_t::Link()
 
 
 
 
 //=====================================================================================================================================
 //=====================================================================================================================================
-// GetUniAndAttribLocs                                                                                                                =
+// getUniAndAttribLocs                                                                                                                =
 //=====================================================================================================================================
 //=====================================================================================================================================
-void shader_prog_t::GetUniAndAttribLocs()
+void ShaderProg::getUniAndAttribLocs()
 {
 {
 	int num;
 	int num;
 	char name_[256];
 	char name_[256];
@@ -108,101 +108,101 @@ void shader_prog_t::GetUniAndAttribLocs()
 
 
 
 
 	// attrib locations
 	// attrib locations
-	glGetProgramiv( gl_id, GL_ACTIVE_ATTRIBUTES, &num );
+	glGetProgramiv( glId, GL_ACTIVE_ATTRIBUTES, &num );
 	for( int i=0; i<num; i++ ) // loop all attributes
 	for( int i=0; i<num; i++ ) // loop all attributes
 	{
 	{
-		glGetActiveAttrib( gl_id, i, sizeof(name_)/sizeof(char), &length, &size, &type, name_ );
+		glGetActiveAttrib( glId, i, sizeof(name_)/sizeof(char), &length, &size, &type, name_ );
 		name_[ length ] = '\0';
 		name_[ length ] = '\0';
 
 
 		// check if its FFP location
 		// check if its FFP location
-		int loc = glGetAttribLocation(gl_id, name_);
+		int loc = glGetAttribLocation(glId, name_);
 		if( loc == -1 )
 		if( loc == -1 )
 		{
 		{
 			//SHADER_WARNING( "You are using FFP vertex attributes (\"" << name_ << "\")" );
 			//SHADER_WARNING( "You are using FFP vertex attributes (\"" << name_ << "\")" );
 			continue;
 			continue;
 		}
 		}
 
 
-		attrib_name_to_loc[ name_ ] = loc;
+		attribNameToLoc[ name_ ] = loc;
 	}
 	}
 
 
 
 
 	// uni locations
 	// uni locations
-	glGetProgramiv( gl_id, GL_ACTIVE_UNIFORMS, &num );
+	glGetProgramiv( glId, GL_ACTIVE_UNIFORMS, &num );
 	for( int i=0; i<num; i++ ) // loop all uniforms
 	for( int i=0; i<num; i++ ) // loop all uniforms
 	{
 	{
-		glGetActiveUniform( gl_id, i, sizeof(name_)/sizeof(char), &length, &size, &type, name_ );
+		glGetActiveUniform( glId, i, sizeof(name_)/sizeof(char), &length, &size, &type, name_ );
 		name_[ length ] = '\0';
 		name_[ length ] = '\0';
 
 
 		// check if its FFP location
 		// check if its FFP location
-		int loc = glGetUniformLocation(gl_id, name_);
+		int loc = glGetUniformLocation(glId, name_);
 		if( loc == -1 )
 		if( loc == -1 )
 		{
 		{
 			//SHADER_WARNING( "You are using FFP uniforms (\"" << name_ << "\")" );
 			//SHADER_WARNING( "You are using FFP uniforms (\"" << name_ << "\")" );
 			continue;
 			continue;
 		}
 		}
 
 
-		uni_name_to_loc[ name_ ] = loc;
+		uniNameToLoc[ name_ ] = loc;
 	}
 	}
 }
 }
 
 
 
 
 //=====================================================================================================================================
 //=====================================================================================================================================
-// FillTheCustomLocationsVectors                                                                                                      =
+// fillTheCustomLocationsVectors                                                                                                      =
 //=====================================================================================================================================
 //=====================================================================================================================================
-bool shader_prog_t::FillTheCustomLocationsVectors( const ShaderParser& pars )
+bool ShaderProg::fillTheCustomLocationsVectors( const ShaderParser& pars )
 {
 {
-	Bind();
+	bind();
 	uint max = 0;
 	uint max = 0;
 
 
 	// uniforms
 	// uniforms
-	for( uint i=0; i<pars.uniforms.size(); ++i )
+	for( uint i=0; i<pars.getOutput().getUniLocs().size(); ++i )
 	{
 	{
-		if( pars.uniforms[i].custom_loc > max ) 
-			max = pars.uniforms[i].custom_loc;
+		if( pars.getOutput().getUniLocs()[i].customLoc > max )
+			max = pars.getOutput().getUniLocs()[i].customLoc;
 	}
 	}
-	custom_uni_loc_to_real_loc.assign( max + 1, -1 );
+	customUniLocToRealLoc.assign( max + 1, -1 );
 
 
-	for( uint i=0; i<pars.uniforms.size(); ++i )
+	for( uint i=0; i<pars.getOutput().getUniLocs().size(); ++i )
 	{
 	{
-		if( custom_uni_loc_to_real_loc[ pars.uniforms[i].custom_loc ] != -1 )
+		if( customUniLocToRealLoc[ pars.getOutput().getUniLocs()[i].customLoc ] != -1 )
 		{
 		{
-			SHADER_ERROR( "The uniform \"" << pars.uniforms[i].name << "\" has the same value with another one" );
+			SHADER_ERROR( "The uniform \"" << pars.getOutput().getUniLocs()[i].name << "\" has the same value with another one" );
 			return false;
 			return false;
 		}
 		}
-		int loc = GetUniformLocation( pars.uniforms[i].name.c_str() );
+		int loc = getUniLoc( pars.getOutput().getUniLocs()[i].name.c_str() );
 		if( loc == -1 )
 		if( loc == -1 )
 		{
 		{
 			SHADER_WARNING( "Check the previous error" );
 			SHADER_WARNING( "Check the previous error" );
 			continue;
 			continue;
 		}
 		}
-		custom_uni_loc_to_real_loc[pars.uniforms[i].custom_loc] = loc;
+		customUniLocToRealLoc[pars.getOutput().getUniLocs()[i].customLoc] = loc;
 	}
 	}
 	
 	
 	
 	
 	// attributes
 	// attributes
 	max = 0;
 	max = 0;
 	
 	
-	for( uint i=0; i<pars.attributes.size(); ++i )
+	for( uint i=0; i<pars.getOutput().getAttribLocs().size(); ++i )
 	{
 	{
-		if( pars.attributes[i].custom_loc > max ) 
-			max = pars.attributes[i].custom_loc;
+		if( pars.getOutput().getAttribLocs()[i].customLoc > max )
+			max = pars.getOutput().getAttribLocs()[i].customLoc;
 	}
 	}
-	custom_attrib_loc_to_real_loc.assign( max + 1, -1 );
+	customAttribLocToRealLoc.assign( max + 1, -1 );
 
 
-	for( uint i=0; i<pars.attributes.size(); ++i )
+	for( uint i=0; i<pars.getOutput().getAttribLocs().size(); ++i )
 	{
 	{
-		if( custom_attrib_loc_to_real_loc[ pars.attributes[i].custom_loc ] != -1 )
+		if( customAttribLocToRealLoc[ pars.getOutput().getAttribLocs()[i].customLoc ] != -1 )
 		{
 		{
-			SHADER_ERROR( "The attribute \"" << pars.attributes[i].name << "\" has the same value with another one" );
+			SHADER_ERROR( "The attribute \"" << pars.getOutput().getAttribLocs()[i].name << "\" has the same value with another one" );
 			return false;
 			return false;
 		}
 		}
-		int loc = GetAttributeLocation( pars.attributes[i].name.c_str() );
+		int loc = getAttribLoc( pars.getOutput().getAttribLocs()[i].name.c_str() );
 		if( loc == -1 )
 		if( loc == -1 )
 		{
 		{
 			SHADER_ERROR( "Check the previous error" );
 			SHADER_ERROR( "Check the previous error" );
 			return false;
 			return false;
 		}
 		}
-		custom_attrib_loc_to_real_loc[pars.attributes[i].custom_loc] = loc;
+		customAttribLocToRealLoc[pars.getOutput().getAttribLocs()[i].customLoc] = loc;
 	}
 	}
 
 
 	return true;
 	return true;
@@ -210,21 +210,21 @@ bool shader_prog_t::FillTheCustomLocationsVectors( const ShaderParser& pars )
 
 
 
 
 //=====================================================================================================================================
 //=====================================================================================================================================
-// Load                                                                                                                               =
+// load                                                                                                                               =
 //=====================================================================================================================================
 //=====================================================================================================================================
-bool shader_prog_t::Load( const char* filename )
+bool ShaderProg::load( const char* filename )
 {
 {
-	if( !CustomLoad( filename, "" ) ) return false;
+	if( !customload( filename, "" ) ) return false;
 	return true;
 	return true;
 }
 }
 
 
 
 
 //=====================================================================================================================================
 //=====================================================================================================================================
-// CustomLoad                                                                                                                         =
+// customload                                                                                                                         =
 //=====================================================================================================================================
 //=====================================================================================================================================
-bool shader_prog_t::CustomLoad( const char* filename, const char* extra_source )
+bool ShaderProg::customload( const char* filename, const char* extra_source )
 {
 {
-	if( GetName().length() == 0 )
+	if( getName().length() == 0 )
 	{
 	{
 		name = util::CutPath( filename );
 		name = util::CutPath( filename );
 		path = util::GetPath( filename );
 		path = util::GetPath( filename );
@@ -232,39 +232,39 @@ bool shader_prog_t::CustomLoad( const char* filename, const char* extra_source )
 
 
 	ShaderParser pars;
 	ShaderParser pars;
 
 
-	if( !pars.ParseFile( filename ) ) return false;
+	if( !pars.parseFile( filename ) ) return false;
 
 
 	// create, compile, attach and link
 	// create, compile, attach and link
 	string preproc_source = r::GetStdShaderPreprocDefines() + extra_source;
 	string preproc_source = r::GetStdShaderPreprocDefines() + extra_source;
-	uint vert_gl_id = CreateAndCompileShader( pars.vert_shader_source.c_str(), preproc_source.c_str(), GL_VERTEX_SHADER );
-	if( vert_gl_id == 0 ) return false;
+	uint vert_glId = createAndCompileShader( pars.getOutput().getVertShaderSource().c_str(), preproc_source.c_str(), GL_VERTEX_SHADER );
+	if( vert_glId == 0 ) return false;
 
 
-	uint frag_gl_id = CreateAndCompileShader( pars.frag_shader_source.c_str(), preproc_source.c_str(), GL_FRAGMENT_SHADER );
-	if( frag_gl_id == 0 ) return false;
+	uint frag_glId = createAndCompileShader( pars.getOutput().getFragShaderSource().c_str(), preproc_source.c_str(), GL_FRAGMENT_SHADER );
+	if( frag_glId == 0 ) return false;
 
 
-	gl_id = glCreateProgram();
-	glAttachShader( gl_id, vert_gl_id );
-	glAttachShader( gl_id, frag_gl_id );
+	glId = glCreateProgram();
+	glAttachShader( glId, vert_glId );
+	glAttachShader( glId, frag_glId );
 
 
-	if( !Link() ) return false;
+	if( !link() ) return false;
 	
 	
 	
 	
 	// init the rest
 	// init the rest
-	GetUniAndAttribLocs();
-	if( !FillTheCustomLocationsVectors( pars ) ) return false;
+	getUniAndAttribLocs();
+	if( !fillTheCustomLocationsVectors( pars ) ) return false;
 
 
 	return true;
 	return true;
 }
 }
 
 
 
 
 //=====================================================================================================================================
 //=====================================================================================================================================
-// GetUniformLocation                                                                                                                 =
+// getUniLoc                                                                                                                 =
 //=====================================================================================================================================
 //=====================================================================================================================================
-int shader_prog_t::GetUniformLocation( const char* name ) const
+int ShaderProg::getUniLoc( const char* name ) const
 {
 {
-	DEBUG_ERR( gl_id == 0 ); // not initialized
-	ntlit_t it = uni_name_to_loc.find( name );
-	if( it == uni_name_to_loc.end() )
+	DEBUG_ERR( glId == 0 ); // not initialized
+	NameToLocIterator it = uniNameToLoc.find( name );
+	if( it == uniNameToLoc.end() )
 	{
 	{
 		SHADER_ERROR( "Cannot get uniform loc \"" << name << '\"' );
 		SHADER_ERROR( "Cannot get uniform loc \"" << name << '\"' );
 		return -1;
 		return -1;
@@ -274,13 +274,13 @@ int shader_prog_t::GetUniformLocation( const char* name ) const
 
 
 
 
 //=====================================================================================================================================
 //=====================================================================================================================================
-// GetAttributeLocation                                                                                                               =
+// getAttribLoc                                                                                                               =
 //=====================================================================================================================================
 //=====================================================================================================================================
-int shader_prog_t::GetAttributeLocation( const char* name ) const
+int ShaderProg::getAttribLoc( const char* name ) const
 {
 {
-	DEBUG_ERR( gl_id == 0 ); // not initialized
-	ntlit_t it = attrib_name_to_loc.find( name );
-	if( it == attrib_name_to_loc.end() )
+	DEBUG_ERR( glId == 0 ); // not initialized
+	NameToLocIterator it = attribNameToLoc.find( name );
+	if( it == attribNameToLoc.end() )
 	{
 	{
 		SHADER_ERROR( "Cannot get attrib loc \"" << name << '\"' );
 		SHADER_ERROR( "Cannot get attrib loc \"" << name << '\"' );
 		return -1;
 		return -1;
@@ -290,13 +290,13 @@ int shader_prog_t::GetAttributeLocation( const char* name ) const
 
 
 
 
 //=====================================================================================================================================
 //=====================================================================================================================================
-// GetUniformLocationSilently                                                                                                         =
+// getUniLocSilently                                                                                                         =
 //=====================================================================================================================================
 //=====================================================================================================================================
-int shader_prog_t::GetUniformLocationSilently( const char* name ) const
+int ShaderProg::getUniLocSilently( const char* name ) const
 {
 {
-	DEBUG_ERR( gl_id == 0 ); // not initialized
-	ntlit_t it = uni_name_to_loc.find( name );
-	if( it == uni_name_to_loc.end() )
+	DEBUG_ERR( glId == 0 ); // not initialized
+	NameToLocIterator it = uniNameToLoc.find( name );
+	if( it == uniNameToLoc.end() )
 	{
 	{
 		return -1;
 		return -1;
 	}
 	}
@@ -305,13 +305,13 @@ int shader_prog_t::GetUniformLocationSilently( const char* name ) const
 
 
 
 
 //=====================================================================================================================================
 //=====================================================================================================================================
-// GetAttributeLocationSilently                                                                                                       =
+// getAttribLocSilently                                                                                                       =
 //=====================================================================================================================================
 //=====================================================================================================================================
-int shader_prog_t::GetAttributeLocationSilently( const char* name ) const
+int ShaderProg::getAttribLocSilently( const char* name ) const
 {
 {
-	DEBUG_ERR( gl_id == 0 ); // not initialized
-	ntlit_t it = attrib_name_to_loc.find( name );
-	if( it == attrib_name_to_loc.end() )
+	DEBUG_ERR( glId == 0 ); // not initialized
+	NameToLocIterator it = attribNameToLoc.find( name );
+	if( it == attribNameToLoc.end() )
 	{
 	{
 		return -1;
 		return -1;
 	}
 	}
@@ -320,41 +320,41 @@ int shader_prog_t::GetAttributeLocationSilently( const char* name ) const
 
 
 
 
 //=====================================================================================================================================
 //=====================================================================================================================================
-// GetUniformLocation                                                                                                                 =
+// getUniLoc                                                                                                                 =
 //=====================================================================================================================================
 //=====================================================================================================================================
-int shader_prog_t::GetUniformLocation( int id ) const
+int ShaderProg::GetUniLoc( int id ) const
 {
 {
-	DEBUG_ERR( uint(id) >= custom_uni_loc_to_real_loc.size() );
-	DEBUG_ERR( custom_uni_loc_to_real_loc[id] == -1 );
-	return custom_uni_loc_to_real_loc[id];
+	DEBUG_ERR( uint(id) >= customUniLocToRealLoc.size() );
+	DEBUG_ERR( customUniLocToRealLoc[id] == -1 );
+	return customUniLocToRealLoc[id];
 }
 }
 
 
 
 
 //=====================================================================================================================================
 //=====================================================================================================================================
-// GetAttributeLocation                                                                                                               =
+// getAttribLoc                                                                                                               =
 //=====================================================================================================================================
 //=====================================================================================================================================
-int shader_prog_t::GetAttributeLocation( int id ) const
+int ShaderProg::getAttribLoc( int id ) const
 {
 {
-	DEBUG_ERR( uint(id) >= custom_attrib_loc_to_real_loc.size() );
-	DEBUG_ERR( custom_attrib_loc_to_real_loc[id] == -1 );
-	return custom_attrib_loc_to_real_loc[id];
+	DEBUG_ERR( uint(id) >= customAttribLocToRealLoc.size() );
+	DEBUG_ERR( customAttribLocToRealLoc[id] == -1 );
+	return customAttribLocToRealLoc[id];
 }
 }
 
 
 
 
 //=====================================================================================================================================
 //=====================================================================================================================================
-// LocTexUnit                                                                                                                         =
+// locTexUnit                                                                                                                         =
 //=====================================================================================================================================
 //=====================================================================================================================================
-void shader_prog_t::LocTexUnit( int loc, const texture_t& tex, uint tex_unit ) const
+void ShaderProg::locTexUnit( int loc, const Texture& tex, uint tex_unit ) const
 {
 {
 	DEBUG_ERR( loc == -1 );
 	DEBUG_ERR( loc == -1 );
-	DEBUG_ERR( GetCurrentProgram() != gl_id );
-	tex.Bind( tex_unit );
+	DEBUG_ERR( getCurrentProgram() != glId );
+	tex.bind( tex_unit );
 	glUniform1i( loc, tex_unit );
 	glUniform1i( loc, tex_unit );
 }
 }
 
 
-void shader_prog_t::LocTexUnit( const char* loc, const texture_t& tex, uint tex_unit ) const
+void ShaderProg::locTexUnit( const char* loc, const Texture& tex, uint tex_unit ) const
 {
 {
-	DEBUG_ERR( GetCurrentProgram() != gl_id );
-	tex.Bind( tex_unit );
-	glUniform1i( GetUniformLocation(loc), tex_unit );
+	DEBUG_ERR( getCurrentProgram() != glId );
+	tex.bind( tex_unit );
+	glUniform1i( getUniLoc(loc), tex_unit );
 }
 }

+ 55 - 0
src/resources/ShaderProg.h

@@ -0,0 +1,55 @@
+#ifndef _SHADER_PROG_H_
+#define _SHADER_PROG_H_
+
+#include <GL/glew.h>
+#include <map>
+#include "common.h"
+#include "Resource.h"
+
+class ShaderParser;
+class Texture;
+
+/// Shader program. Combines a fragment and a vertex shader
+class ShaderProg: public Resource
+{
+	PROPERTY_R( uint, glId, getGlId )
+	
+	private:
+		typedef map<string,int>::const_iterator NameToLocIterator; ///< name to location iterator
+	
+		Vec<int> customUniLocToRealLoc;
+		Vec<int> customAttribLocToRealLoc;
+		map<string,int> uniNameToLoc;
+		map<string,int> attribNameToLoc;
+		
+		void getUniAndAttribLocs();
+		bool fillTheCustomLocationsVectors( const ShaderParser& pars );
+		uint createAndCompileShader( const char* source_code, const char* preproc, int type ) const; ///< @return Returns zero on falure
+		bool link();
+		
+	public:
+		ShaderProg(): glId(0) {}
+		virtual ~ShaderProg() {}
+		
+		inline void bind() const { DEBUG_ERR( glId==0 ); glUseProgram(glId); }
+		static void unbind() { glUseProgram(0); }
+		static uint getCurrentProgram() { int i; glGetIntegerv( GL_CURRENT_PROGRAM, &i ); return i; }
+
+		bool load( const char* filename );
+		bool customload( const char* filename, const char* extra_source );
+		void unload() { /* ToDo: add code */ }
+
+		int getUniLoc( const char* name ) const; ///< Returns -1 if fail and throws error
+		int getAttribLoc( const char* name ) const; ///< Returns -1 if fail and throws error
+		int getUniLocSilently( const char* name ) const;
+		int getAttribLocSilently( const char* name ) const;
+
+		int GetUniLoc( int id ) const;
+		int getAttribLoc( int id ) const;
+
+		// The function's code is being used way to often so a function has to be made
+		void locTexUnit( int location, const Texture& tex, uint tex_unit ) const;
+		void locTexUnit( const char* name, const Texture& tex, uint tex_unit ) const;
+}; 
+
+#endif

+ 3 - 3
src/resources/skel_anim.cpp → src/resources/SkelAnim.cpp

@@ -1,12 +1,12 @@
-#include "skel_anim.h"
+#include "SkelAnim.h"
 #include "Scanner.h"
 #include "Scanner.h"
 #include "parser.h"
 #include "parser.h"
 
 
 
 
 //=====================================================================================================================================
 //=====================================================================================================================================
-// Load                                                                                                                               =
+// load                                                                                                                               =
 //=====================================================================================================================================
 //=====================================================================================================================================
-bool skel_anim_t::Load( const char* filename )
+bool SkelAnim::load( const char* filename )
 {
 {
 	Scanner scanner;
 	Scanner scanner;
 	if( !scanner.loadFile( filename ) ) return false;
 	if( !scanner.loadFile( filename ) ) return false;

+ 45 - 0
src/resources/SkelAnim.h

@@ -0,0 +1,45 @@
+#ifndef _SKEL_ANIM_H_
+#define _SKEL_ANIM_H_
+
+#include "common.h"
+#include "Resource.h"
+#include "gmath.h"
+
+
+/// Skeleton animation
+class SkelAnim: public Resource
+{
+	public:
+		/// BonePose
+		class BonePose
+		{
+			public:
+				quat_t rotation;
+				vec3_t translation;
+		};
+
+
+		/// BoneAnim
+		class BoneAnim
+		{
+			public:
+				Vec<BonePose> keyframes; ///< The poses for every keyframe. Its empty if the bone doesnt have any animation
+
+				BoneAnim() {}
+				~BoneAnim() { if(keyframes.size()) keyframes.clear();}
+		};
+		
+		Vec<uint> keyframes;
+		uint frames_num;
+
+		Vec<BoneAnim> bones;
+
+		SkelAnim() {}
+		~SkelAnim() {}
+		bool load( const char* filename );
+		void unload() { keyframes.clear(); bones.clear(); frames_num=0; }
+};
+
+
+
+#endif

+ 12 - 12
src/resources/skeleton.cpp → src/resources/Skeleton.cpp

@@ -1,12 +1,12 @@
-#include "skeleton.h"
+#include "Skeleton.h"
 #include "Scanner.h"
 #include "Scanner.h"
 #include "parser.h"
 #include "parser.h"
 
 
 
 
 //=====================================================================================================================================
 //=====================================================================================================================================
-// Load                                                                                                                               =
+// load                                                                                                                               =
 //=====================================================================================================================================
 //=====================================================================================================================================
-bool skeleton_t::Load( const char* filename )
+bool Skeleton::load( const char* filename )
 {
 {
 	Scanner scanner;
 	Scanner scanner;
 	if( !scanner.loadFile( filename ) ) return false;
 	if( !scanner.loadFile( filename ) ) return false;
@@ -21,11 +21,11 @@ bool skeleton_t::Load( const char* filename )
 		PARSE_ERR_EXPECTED( "integer" );
 		PARSE_ERR_EXPECTED( "integer" );
 		return false;
 		return false;
 	}
 	}
-	bones.resize( token->value.int_, bone_t() );
+	bones.resize( token->value.int_, Bone() );
 
 
 	for( uint i=0; i<bones.size(); i++ )
 	for( uint i=0; i<bones.size(); i++ )
 	{
 	{
-		bone_t& bone = bones[i];
+		Bone& bone = bones[i];
 		bone.id = i;
 		bone.id = i;
 
 
 		// NAME
 		// NAME
@@ -48,11 +48,11 @@ bool skeleton_t::Load( const char* filename )
 		if( !ParseArrOfNumbers<float>( scanner, false, true, 16, &m4[0] ) ) return false;
 		if( !ParseArrOfNumbers<float>( scanner, false, true, 16, &m4[0] ) ) return false;
 
 
 		// matrix for real
 		// matrix for real
-		bone.rot_skel_space = m4.GetRotationPart();
-		bone.tsl_skel_space = m4.GetTranslationPart();
+		bone.rotSkelSpace = m4.GetRotationPart();
+		bone.tslSkelSpace = m4.GetTranslationPart();
 		mat4_t MAi( m4.GetInverse() );
 		mat4_t MAi( m4.GetInverse() );
-		bone.rot_skel_space_inv = MAi.GetRotationPart();
-		bone.tsl_skel_space_inv = MAi.GetTranslationPart();
+		bone.rotSkelSpaceInv = MAi.GetRotationPart();
+		bone.tslSkelSpaceInv = MAi.GetTranslationPart();
 
 
 		// parent
 		// parent
 		token = &scanner.getNextToken();
 		token = &scanner.getNextToken();
@@ -75,13 +75,13 @@ bool skeleton_t::Load( const char* filename )
 			PARSE_ERR_EXPECTED( "integer" );
 			PARSE_ERR_EXPECTED( "integer" );
 			return false;
 			return false;
 		}
 		}
-		if( token->value.int_ > bone_t::MAX_CHILDS_PER_BONE )
+		if( token->value.int_ > Bone::MAX_CHILDS_PER_BONE )
 		{
 		{
 			ERROR( "Childs for bone \"" << bone.GetName() << "\" exceed the max" );
 			ERROR( "Childs for bone \"" << bone.GetName() << "\" exceed the max" );
 			return false;
 			return false;
 		}
 		}
-		bone.childs_num = token->value.int_;
-		for( int j=0; j<bone.childs_num; j++ )
+		bone.childsNum = token->value.int_;
+		for( int j=0; j<bone.childsNum; j++ )
 		{
 		{
 			token = &scanner.getNextToken();
 			token = &scanner.getNextToken();
 			if( token->code != Scanner::TC_NUMBER || token->type != Scanner::DT_INT )
 			if( token->code != Scanner::TC_NUMBER || token->type != Scanner::DT_INT )

+ 48 - 0
src/resources/Skeleton.h

@@ -0,0 +1,48 @@
+#ifndef _SKELETON_H_
+#define _SKELETON_H_
+
+#include "common.h"
+#include "gmath.h"
+#include "Resource.h"
+#include "engine_class.h"
+
+
+/// Skeleton
+class Skeleton: public Resource
+{
+	public:
+		/// Bone
+		class Bone: public nc_t
+		{
+			public:
+				static const uint MAX_CHILDS_PER_BONE = 4; ///< Please dont change this
+				ushort  id; ///< pos inside the Skeleton::bones vector
+				Bone* parent;
+				Bone* childs[ MAX_CHILDS_PER_BONE ];
+				ushort  childsNum;
+				vec3_t  head;
+				vec3_t  tail;
+
+				/* The rotation and translation that transform the bone from bone space to armature space. Meaning that if
+				MA = TRS(rotSkelSpace, tslSkelSpace) then head = MA * vec3_t(0.0, length, 0.0) and tail = MA * vec3_t( 0.0, 0.0, 0.0 )
+				We also keep the inverted ones for fast calculations. rotSkelSpaceInv = MA.Inverted().GetRotationPart() and NOT
+				rotSkelSpaceInv = rotSkelSpace.GetInverted() */
+				mat3_t rotSkelSpace;
+				vec3_t tslSkelSpace;
+				mat3_t rotSkelSpaceInv;
+				vec3_t tslSkelSpaceInv;
+
+				 Bone() {}
+				~Bone() {}
+		};	
+	
+		Vec<Bone> bones;
+
+		 Skeleton() {}
+		~Skeleton() {}
+		bool load( const char* filename );
+		void unload() { bones.clear(); }
+};
+
+
+#endif

+ 51 - 51
src/resources/texture.cpp → src/resources/Texture.cpp

@@ -1,17 +1,17 @@
 #include <fstream>
 #include <fstream>
 #include <SDL/SDL_image.h>
 #include <SDL/SDL_image.h>
-#include "texture.h"
+#include "Texture.h"
 #include "renderer.h"
 #include "renderer.h"
 
 
 
 
-unsigned char image_t::tga_header_uncompressed[12] = {0,0,2,0,0,0,0,0,0,0,0,0};
-unsigned char image_t::tga_header_compressed[12]   = {0,0,10,0,0,0,0,0,0,0,0,0};
+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};
 
 
 
 
 //=====================================================================================================================================
 //=====================================================================================================================================
-// LoadUncompressedTGA                                                                                                                =
+// loadUncompressedTGA                                                                                                                =
 //=====================================================================================================================================
 //=====================================================================================================================================
-bool image_t::LoadUncompressedTGA( const char* filename, fstream& fs )
+bool Image::loadUncompressedTGA( const char* filename, fstream& fs )
 {
 {
 	// read the info from header
 	// read the info from header
 	unsigned char header6[6];
 	unsigned char header6[6];
@@ -57,9 +57,9 @@ bool image_t::LoadUncompressedTGA( const char* filename, fstream& fs )
 
 
 
 
 //=====================================================================================================================================
 //=====================================================================================================================================
-// LoadCompressedTGA                                                                                                                  =
+// loadCompressedTGA                                                                                                                  =
 //=====================================================================================================================================
 //=====================================================================================================================================
-bool image_t::LoadCompressedTGA( const char* filename, fstream& fs )
+bool Image::loadCompressedTGA( const char* filename, fstream& fs )
 {
 {
 	unsigned char header6[6];
 	unsigned char header6[6];
 	fs.read( (char*)&header6[0], sizeof(header6) );
 	fs.read( (char*)&header6[0], sizeof(header6) );
@@ -169,10 +169,10 @@ bool image_t::LoadCompressedTGA( const char* filename, fstream& fs )
 
 
 
 
 //=====================================================================================================================================
 //=====================================================================================================================================
-// LoadTGA                                                                                                                            =
+// loadTGA                                                                                                                            =
 //=====================================================================================================================================
 //=====================================================================================================================================
-/// Load a tga using the help of the above
-bool image_t::LoadTGA( const char* filename )
+/// load a tga using the help of the above
+bool Image::loadTGA( const char* filename )
 {
 {
 	fstream fs;
 	fstream fs;
 	char my_tga_header[12];
 	char my_tga_header[12];
@@ -193,13 +193,13 @@ bool image_t::LoadTGA( const char* filename )
 	}
 	}
 
 
 	bool funcs_return;
 	bool funcs_return;
-	if( memcmp(tga_header_uncompressed, &my_tga_header[0], sizeof(my_tga_header)) == 0 )
+	if( memcmp(tgaHeaderUncompressed, &my_tga_header[0], sizeof(my_tga_header)) == 0 )
 	{
 	{
-		funcs_return = LoadUncompressedTGA( filename, fs );
+		funcs_return = loadUncompressedTGA( filename, fs );
 	}
 	}
-	else if( memcmp(tga_header_compressed, &my_tga_header[0], sizeof(my_tga_header)) == 0 )
+	else if( memcmp(tgaHeaderCompressed, &my_tga_header[0], sizeof(my_tga_header)) == 0 )
 	{
 	{
-		funcs_return = LoadCompressedTGA( filename, fs );
+		funcs_return = loadCompressedTGA( filename, fs );
 	}
 	}
 	else
 	else
 	{
 	{
@@ -213,9 +213,9 @@ bool image_t::LoadTGA( const char* filename )
 
 
 
 
 //=====================================================================================================================================
 //=====================================================================================================================================
-// LoadPNG                                                                                                                            =
+// loadPNG                                                                                                                            =
 //=====================================================================================================================================
 //=====================================================================================================================================
-bool image_t::LoadPNG( const char* filename )
+bool Image::loadPNG( const char* filename )
 {
 {
 	SDL_Surface *sdli;
 	SDL_Surface *sdli;
 	sdli = IMG_Load( filename );
 	sdli = IMG_Load( filename );
@@ -258,9 +258,9 @@ bool image_t::LoadPNG( const char* filename )
 
 
 
 
 //=====================================================================================================================================
 //=====================================================================================================================================
-// Load                                                                                                                               =
+// load                                                                                                                               =
 //=====================================================================================================================================
 //=====================================================================================================================================
-bool image_t::Load( const char* filename )
+bool Image::load( const char* filename )
 {
 {
 	// get the extension
 	// get the extension
 	char* ext = util::GetFileExtension( filename );
 	char* ext = util::GetFileExtension( filename );
@@ -268,17 +268,17 @@ bool image_t::Load( const char* filename )
 	// load from this extension
 	// load from this extension
 	if( strcmp( ext, "tga" ) == 0 )
 	if( strcmp( ext, "tga" ) == 0 )
 	{
 	{
-		if( !LoadTGA( filename ) )
+		if( !loadTGA( filename ) )
 		{
 		{
-			Unload();
+			unload();
 			return false;
 			return false;
 		}
 		}
 	}
 	}
 	else if( strcmp( ext, "png" ) == 0 )
 	else if( strcmp( ext, "png" ) == 0 )
 	{
 	{
-		if( !LoadPNG( filename ) )
+		if( !loadPNG( filename ) )
 		{
 		{
-			Unload();
+			unload();
 			return false;
 			return false;
 		}
 		}
 	}
 	}
@@ -295,29 +295,29 @@ bool image_t::Load( const char* filename )
 
 
 /*
 /*
 =======================================================================================================================================
 =======================================================================================================================================
-texture_t                                                                                                                             =
+Texture                                                                                                                             =
 =======================================================================================================================================
 =======================================================================================================================================
 */
 */
 
 
 //=====================================================================================================================================
 //=====================================================================================================================================
-// Load                                                                                                                               =
+// load                                                                                                                               =
 //=====================================================================================================================================
 //=====================================================================================================================================
-bool texture_t::Load( const char* filename )
+bool Texture::load( const char* filename )
 {
 {
 	type = GL_TEXTURE_2D;
 	type = GL_TEXTURE_2D;
-	if( gl_id != numeric_limits<uint>::max() )
+	if( glId != numeric_limits<uint>::max() )
 	{
 	{
 		ERROR( "Texture allready loaded" );
 		ERROR( "Texture allready loaded" );
 		return false;
 		return false;
 	}
 	}
 
 
-	image_t img;
-	if( !img.Load( filename ) ) return false;
+	Image img;
+	if( !img.load( filename ) ) return false;
 
 
 
 
 	// bind the texture
 	// bind the texture
-	glGenTextures( 1, &gl_id );
-	Bind(0);
+	glGenTextures( 1, &glId );
+	bind(0);
 	if( r::mipmaping )  glTexParameteri( type, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR );
 	if( r::mipmaping )  glTexParameteri( type, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR );
 	else                glTexParameteri( type, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
 	else                glTexParameteri( type, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
 
 
@@ -341,27 +341,27 @@ bool texture_t::Load( const char* filename )
 	glTexImage2D( type, 0, int_format, img.width, img.height, 0, format, GL_UNSIGNED_BYTE, img.data );
 	glTexImage2D( type, 0, int_format, img.width, img.height, 0, format, GL_UNSIGNED_BYTE, img.data );
 	if( r::mipmaping ) glGenerateMipmap(type);
 	if( r::mipmaping ) glGenerateMipmap(type);
 
 
-	img.Unload();
+	img.unload();
 	return true;
 	return true;
 }
 }
 
 
 
 
 //=====================================================================================================================================
 //=====================================================================================================================================
-// CreateEmpty2D                                                                                                                      =
+// createEmpty2D                                                                                                                      =
 //=====================================================================================================================================
 //=====================================================================================================================================
-bool texture_t::CreateEmpty2D( float width_, float height_, int internal_format, int format_, GLenum type_ )
+bool Texture::createEmpty2D( float width_, float height_, int internal_format, int format_, GLenum type_ )
 {
 {
 	type = GL_TEXTURE_2D;
 	type = GL_TEXTURE_2D;
 	DEBUG_ERR( internal_format>0 && internal_format<=4 ); // deprecated internal format
 	DEBUG_ERR( internal_format>0 && internal_format<=4 ); // deprecated internal format
-	DEBUG_ERR( gl_id != numeric_limits<uint>::max() ) // Texture already loaded
+	DEBUG_ERR( glId != numeric_limits<uint>::max() ) // Texture already loaded
 
 
 	// GL stuff
 	// GL stuff
-	glGenTextures( 1, &gl_id );
-	Bind();
-	TexParameter( GL_TEXTURE_MIN_FILTER, GL_NEAREST );
-	TexParameter( GL_TEXTURE_MAG_FILTER, GL_NEAREST );
-	TexParameter( GL_TEXTURE_WRAP_S, GL_CLAMP );
-	TexParameter( GL_TEXTURE_WRAP_T, GL_CLAMP );
+	glGenTextures( 1, &glId );
+	bind();
+	texParameter( GL_TEXTURE_MIN_FILTER, GL_NEAREST );
+	texParameter( GL_TEXTURE_MAG_FILTER, GL_NEAREST );
+	texParameter( GL_TEXTURE_WRAP_S, GL_CLAMP );
+	texParameter( GL_TEXTURE_WRAP_T, GL_CLAMP );
 
 
 	// allocate to vram
 	// allocate to vram
 	glTexImage2D( type, 0, internal_format, width_, height_, 0, format_, type_, NULL );
 	glTexImage2D( type, 0, internal_format, width_, height_, 0, format_, type_, NULL );
@@ -379,16 +379,16 @@ bool texture_t::CreateEmpty2D( float width_, float height_, int internal_format,
 
 
 
 
 //=====================================================================================================================================
 //=====================================================================================================================================
-// CreateEmpty2DMSAA                                                                                                                  =
+// createEmpty2DMSAA                                                                                                                  =
 //=====================================================================================================================================
 //=====================================================================================================================================
-bool texture_t::CreateEmpty2DMSAA( float width, float height, int samples_num, int internal_format )
+bool Texture::createEmpty2DMSAA( float width, float height, int samples_num, int internal_format )
 {
 {
 	/*type = GL_TEXTURE_2D_MULTISAMPLE;
 	/*type = GL_TEXTURE_2D_MULTISAMPLE;
 	DEBUG_ERR( internal_format>0 && internal_format<=4 ); // deprecated internal format
 	DEBUG_ERR( internal_format>0 && internal_format<=4 ); // deprecated internal format
-	DEBUG_ERR( gl_id != numeric_limits<uint>::max() ) // Texture already loaded
+	DEBUG_ERR( glId != numeric_limits<uint>::max() ) // Texture already loaded
 
 
-	glGenTextures( 1, &gl_id );
-	Bind();
+	glGenTextures( 1, &glId );
+	bind();
 	
 	
 	// allocate
 	// allocate
 	glTexImage2DMultisample( type, samples_num, internal_format, width, height, false );*/
 	glTexImage2DMultisample( type, samples_num, internal_format, width, height, false );*/
@@ -397,22 +397,22 @@ bool texture_t::CreateEmpty2DMSAA( float width, float height, int samples_num, i
 
 
 
 
 //=====================================================================================================================================
 //=====================================================================================================================================
-// Unload                                                                                                                             =
+// unload                                                                                                                             =
 //=====================================================================================================================================
 //=====================================================================================================================================
-void texture_t::Unload()
+void Texture::unload()
 {
 {
-	glDeleteTextures( 1, &gl_id );
+	glDeleteTextures( 1, &glId );
 }
 }
 
 
 
 
 //=====================================================================================================================================
 //=====================================================================================================================================
-// Bind                                                                                                                               =
+// bind                                                                                                                               =
 //=====================================================================================================================================
 //=====================================================================================================================================
-void texture_t::Bind( uint unit ) const
+void Texture::bind( uint unit ) const
 {
 {
 	if( unit>=(uint)r::max_texture_units )
 	if( unit>=(uint)r::max_texture_units )
 		WARNING("Max tex units passed");
 		WARNING("Max tex units passed");
 
 
 	glActiveTexture( GL_TEXTURE0+unit );
 	glActiveTexture( GL_TEXTURE0+unit );
-	glBindTexture( type, gl_id );
+	glBindTexture( type, glId );
 }
 }

+ 67 - 0
src/resources/Texture.h

@@ -0,0 +1,67 @@
+#ifndef _TEXTURE_H_
+#define _TEXTURE_H_
+
+#include <GL/glew.h>
+#include <GL/gl.h>
+#include <limits>
+#include "common.h"
+#include "Resource.h"
+
+
+/// Image class. Used in Texture::load
+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(); }
+
+		bool load( const char* filename );
+		void unload() { if( data ) delete [] data; data=NULL; }
+};
+
+
+/**
+ * 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)
+ */
+class Texture: public Resource
+{
+	protected:
+		uint   glId; ///< Idendification for OGL. The only class variable
+		GLenum type;
+
+	public:
+		 Texture(): glId(numeric_limits<uint>::max()), type(GL_TEXTURE_2D) {}
+		~Texture() {}
+
+		inline uint getGlId() const { DEBUG_ERR(glId==numeric_limits<uint>::max()); return glId; }
+		inline int  getWidth() const { bind(); int i; glGetTexLevelParameteriv( type, 0, GL_TEXTURE_WIDTH, &i ); return i; }
+		inline int  getHeight() const { bind(); int i; glGetTexLevelParameteriv( type, 0, GL_TEXTURE_HEIGHT, &i ); return i; }
+
+		bool load( const char* filename );
+		void unload();
+		bool createEmpty2D( float width, float height, int internal_format, int format, GLenum type_ = GL_FLOAT );
+		bool createEmpty2DMSAA( float width, float height, int samples_num, int internal_format );
+
+		void bind( uint unit=0 ) const;
+
+		inline void texParameter( GLenum param_name, GLint value ) const { bind(); glTexParameteri( GL_TEXTURE_2D, param_name, value ); }
+};
+
+
+
+#endif

+ 0 - 33
src/resources/extension.cpp

@@ -1,33 +0,0 @@
-#include <dlfcn.h>
-#include "extension.h"
-
-
-bool extension_t::Load( const char* filename )
-{
-	// load libary
-	lib_handle = dlopen( filename, RTLD_LAZY );
-	if( lib_handle == NULL ) 
-	{
-		ERROR( "File \"" << filename << "\": " << dlerror() );
-		return false;
-	}
-	
-	// get FooBar
-	foobar_ptr = (int(*)(void*))( dlsym(lib_handle, "FooBar") );
-	if( foobar_ptr == NULL )  
-	{
-		ERROR( "File \"" << filename << "\": \"FooBar\" entry symbol not found: " << dlerror() );
-		return false;
-	}
-	
-	return true;
-}
-
-
-void extension_t::Unload()
-{
-	DEBUG_ERR( lib_handle==NULL || foobar_ptr==NULL );
-	dlclose( lib_handle );
-	lib_handle = NULL;
-	foobar_ptr = NULL;
-}

+ 0 - 24
src/resources/extension.h

@@ -1,24 +0,0 @@
-#ifndef _EXTENSION_H_
-#define _EXTENSION_H_
-
-#include "common.h"
-#include "resource.h"
-
-
-/// Extension resource
-class extension_t: public resource_t
-{
-	private:
-		void* lib_handle;
-		int(*foobar_ptr)(void*);
-	
-	public:
-		extension_t(): lib_handle(NULL), foobar_ptr(NULL) {}
-		~extension_t() {}
-		bool Load( const char* filename );
-		void Unload();
-		template<typename type_t> int FooBar( type_t* ptr ) { DEBUG_ERR(foobar_ptr==NULL); return (*foobar_ptr)( reinterpret_cast<type_t*>(ptr) ); }
-};
-
-
-#endif

+ 0 - 46
src/resources/light_props.h

@@ -1,46 +0,0 @@
-#ifndef _LIGHT_PROPS_H_
-#define _LIGHT_PROPS_H_
-
-#include "common.h"
-#include "resource.h"
-#include "gmath.h"
-
-
-class texture_t;
-
-
-/// Light properties resource
-class light_props_t: public resource_t
-{
-	// data
-	PROPERTY_R( vec3_t, diffuse_col, GetDiffuseColor )
-	PROPERTY_R( vec3_t, specular_col, GetSpecularColor )
-	PROPERTY_R( float, radius, GetRadius ) ///< For point lights
-	PROPERTY_R( bool, casts_shadow, CastsShadow ) ///< For spot lights
-	PROPERTY_R( float, distance, GetDistance ) ///< For spot lights. A.K.A.: camera's zfar
-	PROPERTY_R( float, fov_x, GetFovX ) ///< For spot lights
-	PROPERTY_R( float, fov_y, GetFovY ) ///< For spot lights
-		
-	private:
-		texture_t* texture; ///< For spot lights
-	public:
-		const texture_t* GetTexture() const { DEBUG_ERR(texture==NULL); return texture; }
-	
-	// funcs	
-	public:
-		light_props_t():
-			diffuse_col(0.5),
-			specular_col(0.5),
-			radius(1.0),
-			casts_shadow(false),
-			distance(3.0),
-			fov_x(m::PI/4.0),
-			fov_y(m::PI/4.0),
-			texture(NULL) 
-		{}
-		virtual ~light_props_t() { /* ToDo */ }
-		bool Load( const char* filename );
-		void Unload();
-};
-
-#endif

+ 0 - 75
src/resources/mesh.h

@@ -1,75 +0,0 @@
-#ifndef _MESH_H_
-#define _MESH_H_
-
-#include "common.h"
-#include "gmath.h"
-#include "vbo.h"
-#include "resource.h"
-#include "collision.h"
-
-
-/// Mesh resource
-class mesh_t: public resource_t
-{
-	// data
-	public:
-		class vertex_weight_t
-		{
-			public:
-				static const uint MAX_BONES_PER_VERT = 4; ///< Dont change or change the skinning code in shader
-
-				// ToDo: change the vals to uint when change drivers
-				float bones_num;
-				float bone_ids[MAX_BONES_PER_VERT];
-				float weights[MAX_BONES_PER_VERT];
-		};
-
-		class triangle_t
-		{
-			public:
-				uint   vert_ids[3]; // an array with the vertex indexes in the mesh class
-				vec3_t normal;
-		};
-
-		vec_t<vec3_t>          vert_coords;
-		vec_t<vec3_t>          vert_normals;
-		vec_t<vec4_t>          vert_tangents;
-		vec_t<vec2_t>          tex_coords;    ///< One for every vert so we can use vertex arrays
-		vec_t<vertex_weight_t> vert_weights;
-		vec_t<triangle_t>      tris;
-		vec_t<ushort>          vert_indeces; ///< Used for vertex arrays
-
-		struct
-		{
-			vbo_t vert_coords;
-			vbo_t vert_normals;
-			vbo_t vert_tangents;
-			vbo_t tex_coords;
-			vbo_t vert_indeces;
-			vbo_t vert_weights;
-		} vbos;
-
-		string material_name;
-
-		bsphere_t bsphere;
-
-	// funcs
-	protected:
-		void CreateFaceNormals();
-		void CreateVertNormals();
-		void CreateAllNormals() { CreateFaceNormals(); CreateVertNormals(); }
-		void CreateVertTangents();
-		void CreateVertIndeces();
-		void CreateVBOs();
-		void CalcBSphere();
-
-	public:
-		mesh_t() {}
-		virtual ~mesh_t() { /*ToDo*/ }
-		bool Load( const char* filename );
-		void Unload();
-
-};
-
-
-#endif

+ 0 - 25
src/resources/path.h

@@ -1,25 +0,0 @@
-#ifndef _PATH_H_
-#define _PATH_H_
-
-#include "common.h"
-#include "resource.h"
-#include "gmath.h"
-
-
-/// Path
-class path_t: public resource_t
-{
-	public:
-		vec_t<vec3_t> positions; ///< AKA translations
-		vec_t<mat3_t> rotations;
-		vec_t<float>  scales;
-		float         step;
-
-		path_t() {}
-		~path_t() {}
-		bool Load( const char* filename );
-		void Unload() { points.clear(); }
-};
-
-
-#endif

+ 0 - 198
src/resources/resource.h

@@ -1,198 +0,0 @@
-#ifndef _RESOURCE_H_
-#define _RESOURCE_H_
-
-#include "common.h"
-#include "engine_class.h"
-#include "util.h"
-
-
-// forward decls
-class texture_t;
-class material_t;
-class shader_prog_t;
-class mesh_t;
-class skeleton_t;
-class skel_anim_t;
-class light_props_t;
-
-namespace rsrc {
-template< typename type_t > class container_t;
-}
-
-
-// resource_t
-/**
- * Every class that it is considered resource should be derivative of this one. This step is not
- * necessary because of the container_t template but ensures that loading will be made by the
- * resource manager and not the class itself
- */
-class resource_t
-{
-	PROPERTY_R( string, path, GetPath );
-	PROPERTY_R( string, name, GetName );
-	PROPERTY_R( uint, users_num, GetUsersNum );
-
-	// friends
-	friend class rsrc::container_t<texture_t>;
-	friend class rsrc::container_t<material_t>;
-	friend class rsrc::container_t<shader_prog_t>;
-	friend class rsrc::container_t<skeleton_t>;
-	friend class rsrc::container_t<mesh_t>;
-	friend class rsrc::container_t<skel_anim_t>;
-	friend class rsrc::container_t<light_props_t>;
-	friend class shader_prog_t;
-
-	public:
-		virtual bool Load( const char* ) = 0;
-		virtual void Unload() = 0;
-
-		resource_t(): users_num(0) {}
-		virtual ~resource_t() {};
-};
-
-
-/// resource namespace
-namespace rsrc {
-
-
-extern container_t<texture_t>     textures;
-extern container_t<shader_prog_t> shaders;
-extern container_t<material_t>    materials;
-extern container_t<mesh_t>        meshes;
-extern container_t<skeleton_t>    skeletons;
-extern container_t<skel_anim_t>   skel_anims;
-extern container_t<light_props_t> light_props;
-
-
-/// resource container template class
-template<typename type_t> class container_t: public vec_t<type_t*>
-{
-	private:
-		typedef typename container_t<type_t>::iterator iterator_t; ///< Just to save me time from typing
-		typedef vec_t<type_t*> base_class_t;
-
-		/**
-		 * Search inside the container by name
-		 * @param name The name of the resource
-		 * @return The iterator of the content end of vector if not found
-		 */
-		iterator_t FindByName( const char* name )
-		{
-			iterator_t it = base_class_t::begin();
-			while( it != base_class_t::end() )
-			{
-				if( (*it).name == name )
-					return it;
-				++it;
-			}
-
-			return it;
-		}
-
-
-		/**
-		 * Search inside the container by name and path
-		 * @param name The name of the resource
-		 * @param path The path of the resource
-		 * @return The iterator of the content end of vector if not found
-		 */
-		iterator_t FindByNameAndPath( const char* name, const char* path )
-		{
-			iterator_t it = base_class_t::begin();
-			while( it != base_class_t::end() )
-			{
-				if( (*it)->name == name && (*it)->path == path )
-					return it;
-				++it;
-			}
-
-			return it;
-		}
-
-
-		/**
-	   * Search inside the container by pointer
-		 * @param name The name of the resource object
-		 * @return The iterator of the content end of vector if not found
-		 */
-		iterator_t FindByPtr( type_t* ptr )
-		{
-			iterator_t it = base_class_t::begin();
-			while( it != base_class_t::end() )
-			{
-				if( ptr == (*it) )
-					return it;
-				++it;
-			}
-
-			return it;
-		}
-
-		public:
-		/**
-		 * Load an object and register it. If its allready loaded return its pointer
-		 * @param fname The filename that initializes the object
-		 * @return A pointer of a new resource or NULL on fail
-		 */
-		type_t* Load( const char* fname )
-		{
-			char* name = util::CutPath( fname );
-			string path = util::GetPath( fname );
-			iterator_t it = FindByNameAndPath( name, path.c_str() );
-
-			// if allready loaded then inc the users and return the pointer
-			if( it != base_class_t::end() )
-			{
-				++ (*it)->users_num;
-				return (*it);
-			}
-
-			// else create new, loaded and update the container
-			type_t* new_instance = new type_t();
-			new_instance->name = name;
-			new_instance->path = path;
-			new_instance->users_num = 1;
-
-			if( !new_instance->Load( fname ) )
-			{
-				ERROR( "Cannot load \"" << fname << '\"' );
-				delete new_instance;
-				return NULL;
-			}
-			base_class_t::push_back( new_instance );
-
-			return new_instance;
-		}
-
-
-		/**
-		 * Unload item. If nobody else uses it then delete it completely
-		 * @param x Pointer to the instance we want to unload
-		 */
-		void Unload( type_t* x )
-		{
-			iterator_t it = FindByPtr( x );
-			if( it == base_class_t::end() )
-			{
-				ERROR( "Cannot find resource with pointer 0x" << x );
-				return;
-			}
-
-			type_t* del_ = (*it);
-			DEBUG_ERR( del_->users_num < 1 ); // WTF?
-
-			--del_->users_num;
-
-			// if no other users then call Unload and update the container
-			if( del_->users_num == 0 )
-			{
-				del_->Unload();
-				delete del_;
-				base_class_t::erase( it );
-			}
-		}
-}; // end class container_t
-
-
-} // end namespace
-#endif

+ 0 - 55
src/resources/shader_prog.h

@@ -1,55 +0,0 @@
-#ifndef _SHADER_PROG_H_
-#define _SHADER_PROG_H_
-
-#include <GL/glew.h>
-#include <map>
-#include "common.h"
-#include "resource.h"
-
-class ShaderParser;
-class texture_t;
-
-/// Shader program. Combines a fragment and a vertex shader
-class shader_prog_t: public resource_t
-{
-	PROPERTY_R( uint, gl_id, GetGLID )
-	
-	private:
-		typedef map<string,int>::const_iterator ntlit_t; ///< name to location iterator
-	
-		vec_t<int> custom_uni_loc_to_real_loc;
-		vec_t<int> custom_attrib_loc_to_real_loc;
-		map<string,int> uni_name_to_loc;
-		map<string,int> attrib_name_to_loc;
-		
-		void GetUniAndAttribLocs();
-		bool FillTheCustomLocationsVectors( const ShaderParser& pars );
-		uint CreateAndCompileShader( const char* source_code, const char* preproc, int type ) const; ///< @return Returns zero on falure
-		bool Link();
-		
-	public:
-		shader_prog_t(): gl_id(0) {}
-		virtual ~shader_prog_t() {}
-		
-		inline void Bind() const { DEBUG_ERR( gl_id==0 ); glUseProgram(gl_id); }
-		static void Unbind() { glUseProgram(0); }
-		static uint GetCurrentProgram() { int i; glGetIntegerv( GL_CURRENT_PROGRAM, &i ); return i; }
-
-		bool Load( const char* filename );
-		bool CustomLoad( const char* filename, const char* extra_source );
-		void Unload() { /* ToDo: add code */ }
-
-		int GetUniformLocation( const char* name ) const; ///< Returns -1 if fail and throws error
-		int GetAttributeLocation( const char* name ) const; ///< Returns -1 if fail and throws error
-		int GetUniformLocationSilently( const char* name ) const;
-		int GetAttributeLocationSilently( const char* name ) const;
-
-		int GetUniformLocation( int id ) const;
-		int GetAttributeLocation( int id ) const;
-
-		// The function's code is being used way to often so a function has to be made
-		void LocTexUnit( int location, const texture_t& tex, uint tex_unit ) const;
-		void LocTexUnit( const char* name, const texture_t& tex, uint tex_unit ) const;
-}; 
-
-#endif

+ 0 - 45
src/resources/skel_anim.h

@@ -1,45 +0,0 @@
-#ifndef _SKEL_ANIM_H_
-#define _SKEL_ANIM_H_
-
-#include "common.h"
-#include "resource.h"
-#include "gmath.h"
-
-
-/// Skeleton animation
-class skel_anim_t: public resource_t
-{
-	public:
-		/// bone_pose_t
-		class bone_pose_t
-		{
-			public:
-				quat_t rotation;
-				vec3_t translation;
-		};
-
-
-		/// bone_anim_t
-		class bone_anim_t
-		{
-			public:
-				vec_t<bone_pose_t> keyframes; ///< The poses for every keyframe. Its empty if the bone doesnt have any animation
-
-				bone_anim_t() {}
-				~bone_anim_t() { if(keyframes.size()) keyframes.clear();}
-		};
-		
-		vec_t<uint> keyframes;
-		uint frames_num;
-
-		vec_t<bone_anim_t> bones;
-
-		skel_anim_t() {}
-		~skel_anim_t() {}
-		bool Load( const char* filename );
-		void Unload() { keyframes.clear(); bones.clear(); frames_num=0; }
-};
-
-
-
-#endif

+ 0 - 48
src/resources/skeleton.h

@@ -1,48 +0,0 @@
-#ifndef _SKELETON_H_
-#define _SKELETON_H_
-
-#include "common.h"
-#include "gmath.h"
-#include "resource.h"
-#include "engine_class.h"
-
-
-/// skeleton_t
-class skeleton_t: public resource_t
-{
-	public:
-		/// bone_t
-		class bone_t: public nc_t
-		{
-			public:
-				static const uint MAX_CHILDS_PER_BONE = 4; ///< Please dont change this
-				ushort  id; ///< pos inside the skeleton_t::bones vector
-				bone_t* parent;
-				bone_t* childs[ MAX_CHILDS_PER_BONE ];
-				ushort  childs_num;
-				vec3_t  head;
-				vec3_t  tail;
-
-				/* The rotation and translation that transform the bone from bone space to armature space. Meaning that if
-				MA = TRS(rot_skel_space, tsl_skel_space) then head = MA * vec3_t(0.0, length, 0.0) and tail = MA * vec3_t( 0.0, 0.0, 0.0 )
-				We also keep the inverted ones for fast calculations. rot_skel_space_inv = MA.Inverted().GetRotationPart() and NOT
-				rot_skel_space_inv = rot_skel_space.GetInverted() */
-				mat3_t rot_skel_space;
-				vec3_t tsl_skel_space;
-				mat3_t rot_skel_space_inv;
-				vec3_t tsl_skel_space_inv;
-
-				 bone_t() {}
-				~bone_t() {}
-		};	
-	
-		vec_t<bone_t> bones;
-
-		 skeleton_t() {}
-		~skeleton_t() {}
-		bool Load( const char* filename );
-		void Unload() { bones.clear(); }
-};
-
-
-#endif

+ 0 - 69
src/resources/texture.h

@@ -1,69 +0,0 @@
-#ifndef _TEXTURE_H_
-#define _TEXTURE_H_
-
-#include <GL/glew.h>
-#include <GL/gl.h>
-#include <limits>
-#include "common.h"
-#include "resource.h"
-
-
-// image_t
-/// Image class. Used in texture_t::Load
-class image_t
-{
-	protected:
-		static unsigned char tga_header_uncompressed[12];
-		static unsigned char tga_header_compressed[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_t(): data(NULL) {}
-		~image_t() { Unload(); }
-
-		bool Load( const char* filename );
-		void Unload() { if( data ) delete [] data; data=NULL; }
-};
-
-
-// texture_t
-/**
- * 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)
- */
-class texture_t: public resource_t
-{
-	protected:
-		uint   gl_id; ///< Idendification for OGL. The only class variable
-		GLenum type;
-
-	public:
-		 texture_t(): gl_id(numeric_limits<uint>::max()), type(GL_TEXTURE_2D) {}
-		~texture_t() {}
-
-		inline uint GetGLID() const { DEBUG_ERR(gl_id==numeric_limits<uint>::max()); return gl_id; }
-		inline int  GetWidth() const { Bind(); int i; glGetTexLevelParameteriv( type, 0, GL_TEXTURE_WIDTH, &i ); return i; }
-		inline int  GetHeight() const { Bind(); int i; glGetTexLevelParameteriv( type, 0, GL_TEXTURE_HEIGHT, &i ); return i; }
-
-		bool Load( const char* filename );
-		void Unload();
-		bool CreateEmpty2D( float width, float height, int internal_format, int format, GLenum type_ = GL_FLOAT );
-		bool CreateEmpty2DMSAA( float width, float height, int samples_num, int internal_format );
-
-		void Bind( uint unit=0 ) const;
-
-		inline void TexParameter( GLenum param_name, GLint value ) const { Bind(); glTexParameteri( GL_TEXTURE_2D, param_name, value ); }
-};
-
-
-
-#endif

+ 11 - 11
src/scene/light.cpp

@@ -1,7 +1,7 @@
 #include "light.h"
 #include "light.h"
 #include "collision.h"
 #include "collision.h"
 #include "renderer.h"
 #include "renderer.h"
-#include "light_props.h"
+#include "LightProps.h"
 
 
 
 
 //=====================================================================================================================================
 //=====================================================================================================================================
@@ -9,8 +9,8 @@
 //=====================================================================================================================================
 //=====================================================================================================================================
 void point_light_t::Init( const char* filename )
 void point_light_t::Init( const char* filename )
 {
 {
-	light_props = rsrc::light_props.Load( filename );
-	radius = light_props->GetRadius();
+	light_props = rsrc::light_props.load( filename );
+	radius = light_props->getRadius();
 }
 }
 
 
 
 
@@ -19,12 +19,12 @@ void point_light_t::Init( const char* filename )
 //=====================================================================================================================================
 //=====================================================================================================================================
 void spot_light_t::Init( const char* filename )
 void spot_light_t::Init( const char* filename )
 {
 {
-	light_props = rsrc::light_props.Load( filename );
-	camera.SetAll( light_props->GetFovX(), light_props->GetFovY(), 0.2, light_props->GetDistance() );
-	casts_shadow = light_props->CastsShadow();
-	if( light_props->GetTexture() == NULL )
+	light_props = rsrc::light_props.load( filename );
+	camera.SetAll( light_props->getFovX(), light_props->getFovY(), 0.2, light_props->getDistance() );
+	castsShadow = light_props->castsShadow();
+	if( light_props->getTexture() == NULL )
 	{
 	{
-		ERROR( "Light properties \"" << light_props->GetName() << "\" do not have a texture" );
+		ERROR( "Light properties \"" << light_props->getName() << "\" do not have a texture" );
 		return;
 		return;
 	}
 	}
 }
 }
@@ -35,7 +35,7 @@ void spot_light_t::Init( const char* filename )
 //=====================================================================================================================================
 //=====================================================================================================================================
 void light_t::Deinit()
 void light_t::Deinit()
 {
 {
-	rsrc::light_props.Unload( light_props );
+	rsrc::light_props.unload( light_props );
 }
 }
 
 
 
 
@@ -59,7 +59,7 @@ static void RenderSphere( const mat4_t& tsl, const vec3_t& col )
 //=====================================================================================================================================
 //=====================================================================================================================================
 void point_light_t::Render()
 void point_light_t::Render()
 {
 {
-	RenderSphere( transformation_wspace, light_props->GetDiffuseColor() );
+	RenderSphere( transformation_wspace, light_props->getDiffuseColor() );
 }
 }
 
 
 
 
@@ -68,5 +68,5 @@ void point_light_t::Render()
 //=====================================================================================================================================
 //=====================================================================================================================================
 void spot_light_t::Render()
 void spot_light_t::Render()
 {
 {
-	RenderSphere( transformation_wspace, light_props->GetDiffuseColor() );
+	RenderSphere( transformation_wspace, light_props->getDiffuseColor() );
 }
 }

+ 5 - 5
src/scene/light.h

@@ -18,11 +18,11 @@ Specular intensity of material: Sm
 #define _LIGHT_H_
 #define _LIGHT_H_
 
 
 #include "common.h"
 #include "common.h"
-#include "texture.h"
+#include "Texture.h"
 #include "node.h"
 #include "node.h"
 #include "camera.h"
 #include "camera.h"
 
 
-class light_props_t;
+class LightProps;
 
 
 
 
 /// light_t (A)
 /// light_t (A)
@@ -32,7 +32,7 @@ class light_t: public node_t
 		enum type_e { LT_POINT, LT_SPOT };
 		enum type_e { LT_POINT, LT_SPOT };
 
 
 		type_e type;
 		type_e type;
-		light_props_t* light_props; ///< Later we will add a controller
+		LightProps* light_props; ///< Later we will add a controller
 	
 	
 		light_t( type_e type_ ): node_t(NT_LIGHT), type(type_) {}
 		light_t( type_e type_ ): node_t(NT_LIGHT), type(type_) {}
 		//void Init( const char* );
 		//void Init( const char* );
@@ -57,9 +57,9 @@ class spot_light_t: public light_t
 {
 {
 	public:
 	public:
 		camera_t camera;
 		camera_t camera;
-		bool casts_shadow;
+		bool castsShadow;
 
 
-		spot_light_t(): light_t(LT_SPOT), casts_shadow(false) { AddChild( &camera ); }
+		spot_light_t(): light_t(LT_SPOT), castsShadow(false) { AddChild( &camera ); }
 		float GetDistance() const { return camera.GetZFar(); }
 		float GetDistance() const { return camera.GetZFar(); }
 		void  SetDistance( float d ) { camera.SetZFar(d); }
 		void  SetDistance( float d ) { camera.SetZFar(d); }
 		void  Init( const char* );
 		void  Init( const char* );

+ 47 - 47
src/scene/mesh_node.cpp

@@ -1,10 +1,10 @@
 #include "mesh_node.h"
 #include "mesh_node.h"
-#include "resource.h"
-#include "mesh.h"
+#include "Resource.h"
+#include "Mesh.h"
 #include "renderer.h"
 #include "renderer.h"
-#include "material.h"
+#include "Material.h"
 #include "skel_node.h"
 #include "skel_node.h"
-#include "skeleton.h"
+#include "Skeleton.h"
 #include "mesh_skel_ctrl.h"
 #include "mesh_skel_ctrl.h"
 #include "skel_anim_ctrl.h"
 #include "skel_anim_ctrl.h"
 
 
@@ -14,11 +14,11 @@
 //=====================================================================================================================================
 //=====================================================================================================================================
 void mesh_node_t::Init( const char* filename )
 void mesh_node_t::Init( const char* filename )
 {
 {
-	mesh = rsrc::meshes.Load( filename );
-	material = rsrc::materials.Load( mesh->material_name.c_str() );
+	mesh = rsrc::meshes.load( filename );
+	material = rsrc::materials.load( mesh->materialName.c_str() );
 
 
 	// sanity checks
 	// sanity checks
-	if( material->attrib_locs.tex_coords != -1 && mesh->vbos.tex_coords.GetGLID() == 0 )
+	if( material->attribLocs.texCoords != -1 && mesh->vbos.texCoords.getGlId() == 0 )
 	{
 	{
 		ERROR( "The shader program needs information that the mesh do not have" );
 		ERROR( "The shader program needs information that the mesh do not have" );
 	}
 	}
@@ -30,8 +30,8 @@ void mesh_node_t::Init( const char* filename )
 //=====================================================================================================================================
 //=====================================================================================================================================
 void mesh_node_t::Deinit()
 void mesh_node_t::Deinit()
 {
 {
-	rsrc::meshes.Unload( mesh );
-	rsrc::materials.Unload( material );
+	rsrc::meshes.unload( mesh );
+	rsrc::materials.unload( material );
 }
 }
 
 
 
 
@@ -39,7 +39,7 @@ void mesh_node_t::Deinit()
 // Render                                                                                                                             =
 // Render                                                                                                                             =
 //=====================================================================================================================================
 //=====================================================================================================================================
 /// Called in material or blending stages
 /// Called in material or blending stages
-void mesh_node_t::Render( material_t* mtl ) const
+void mesh_node_t::Render( Material* mtl ) const
 {
 {
 	glPushMatrix();
 	glPushMatrix();
 	r::MultMatrix( transformation_wspace );
 	r::MultMatrix( transformation_wspace );
@@ -48,66 +48,66 @@ void mesh_node_t::Render( material_t* mtl ) const
 	if( mesh_skel_ctrl )
 	if( mesh_skel_ctrl )
 	{
 	{
 		// first the uniforms
 		// first the uniforms
-		glUniformMatrix3fv( mtl->uni_locs.skinning_rotations, mesh_skel_ctrl->skel_node->skeleton->bones.size(), 1,
+		glUniformMatrix3fv( mtl->uniLocs.skinningRotations, mesh_skel_ctrl->skel_node->skeleton->bones.size(), 1,
 		                    &(mesh_skel_ctrl->skel_node->skel_anim_ctrl->bone_rotations[0])[0] );
 		                    &(mesh_skel_ctrl->skel_node->skel_anim_ctrl->bone_rotations[0])[0] );
-		glUniform3fv( mtl->uni_locs.skinning_translations, mesh_skel_ctrl->skel_node->skeleton->bones.size(),
-		              &(mesh_skel_ctrl->skel_node->skel_anim_ctrl->bone_translations[0])[0] );
+		glUniform3fv( mtl->uniLocs.skinningTranslations, mesh_skel_ctrl->skel_node->skeleton->bones.size(),
+		              &(mesh_skel_ctrl->skel_node->skel_anim_ctrl->Boneranslations[0])[0] );
 
 
 		// then the attributes
 		// then the attributes
-		DEBUG_ERR( !mtl->HasHWSkinning() );
-
-		mesh->vbos.vert_weights.Bind();
-		glEnableVertexAttribArray( mtl->attrib_locs.vert_weight_bones_num );
-		glVertexAttribPointer( mtl->attrib_locs.vert_weight_bones_num, 1, GL_FLOAT, GL_FALSE, sizeof(mesh_t::vertex_weight_t), BUFFER_OFFSET(0) );
-		glEnableVertexAttribArray( mtl->attrib_locs.vert_weight_bone_ids );
-		glVertexAttribPointer( mtl->attrib_locs.vert_weight_bone_ids, 4, GL_FLOAT, GL_FALSE, sizeof(mesh_t::vertex_weight_t), BUFFER_OFFSET(4) );
-		glEnableVertexAttribArray( mtl->attrib_locs.vert_weight_weights );
-		glVertexAttribPointer( mtl->attrib_locs.vert_weight_weights, 4, GL_FLOAT, GL_FALSE, sizeof(mesh_t::vertex_weight_t), BUFFER_OFFSET(20) );
+		DEBUG_ERR( !mtl->hasHWSkinning() );
+
+		mesh->vbos.vertWeights.Bind();
+		glEnableVertexAttribArray( mtl->attribLocs.vertWeightBonesNum );
+		glVertexAttribPointer( mtl->attribLocs.vertWeightBonesNum, 1, GL_FLOAT, GL_FALSE, sizeof(Mesh::VertexWeight), BUFFER_OFFSET(0) );
+		glEnableVertexAttribArray( mtl->attribLocs.vertWeightBoneIds );
+		glVertexAttribPointer( mtl->attribLocs.vertWeightBoneIds, 4, GL_FLOAT, GL_FALSE, sizeof(Mesh::VertexWeight), BUFFER_OFFSET(4) );
+		glEnableVertexAttribArray( mtl->attribLocs.vertWeightWeights );
+		glVertexAttribPointer( mtl->attribLocs.vertWeightWeights, 4, GL_FLOAT, GL_FALSE, sizeof(Mesh::VertexWeight), BUFFER_OFFSET(20) );
 	}
 	}
 
 
-	if( mtl->attrib_locs.position != -1 )
+	if( mtl->attribLocs.position != -1 )
 	{
 	{
-		mesh->vbos.vert_coords.Bind();
-		glVertexAttribPointer( mtl->attrib_locs.position, 3, GL_FLOAT, false, 0, NULL );
-		glEnableVertexAttribArray( mtl->attrib_locs.position );
+		mesh->vbos.vertCoords.Bind();
+		glVertexAttribPointer( mtl->attribLocs.position, 3, GL_FLOAT, false, 0, NULL );
+		glEnableVertexAttribArray( mtl->attribLocs.position );
 	}
 	}
 
 
-	if( mtl->attrib_locs.normal != -1 )
+	if( mtl->attribLocs.normal != -1 )
 	{
 	{
-		mesh->vbos.vert_normals.Bind();
-		glVertexAttribPointer( mtl->attrib_locs.normal, 3, GL_FLOAT, false, 0, NULL );
-		glEnableVertexAttribArray( mtl->attrib_locs.normal );
+		mesh->vbos.vertNormals.Bind();
+		glVertexAttribPointer( mtl->attribLocs.normal, 3, GL_FLOAT, false, 0, NULL );
+		glEnableVertexAttribArray( mtl->attribLocs.normal );
 	}
 	}
 
 
-	if( mtl->attrib_locs.tex_coords != -1 )
+	if( mtl->attribLocs.texCoords != -1 )
 	{
 	{
-		mesh->vbos.tex_coords.Bind();
-		glVertexAttribPointer( mtl->attrib_locs.tex_coords, 2, GL_FLOAT, false, 0, NULL );
-		glEnableVertexAttribArray( mtl->attrib_locs.tex_coords );
+		mesh->vbos.texCoords.Bind();
+		glVertexAttribPointer( mtl->attribLocs.texCoords, 2, GL_FLOAT, false, 0, NULL );
+		glEnableVertexAttribArray( mtl->attribLocs.texCoords );
 	}
 	}
 
 
-	if( mtl->attrib_locs.tanget != -1 )
+	if( mtl->attribLocs.tanget != -1 )
 	{
 	{
-		mesh->vbos.vert_tangents.Bind();
-		glVertexAttribPointer( mtl->attrib_locs.tanget, 4, GL_FLOAT, false, 0, NULL );
-		glEnableVertexAttribArray( mtl->attrib_locs.tanget );
+		mesh->vbos.vertTangents.Bind();
+		glVertexAttribPointer( mtl->attribLocs.tanget, 4, GL_FLOAT, false, 0, NULL );
+		glEnableVertexAttribArray( mtl->attribLocs.tanget );
 	}
 	}
 
 
-	mesh->vbos.vert_indeces.Bind();
+	mesh->vbos.vertIndeces.Bind();
 
 
-	glDrawElements( GL_TRIANGLES, mesh->vert_indeces.size(), GL_UNSIGNED_SHORT, 0 );
+	glDrawElements( GL_TRIANGLES, mesh->vertIndeces.size(), GL_UNSIGNED_SHORT, 0 );
 
 
 	// disable
 	// disable
-	if( mtl->attrib_locs.position != -1 ) glDisableVertexAttribArray( mtl->attrib_locs.position );
-	if( mtl->attrib_locs.normal != -1 ) glDisableVertexAttribArray( mtl->attrib_locs.normal );
-	if( mtl->attrib_locs.tex_coords != -1 ) glDisableVertexAttribArray( mtl->attrib_locs.tex_coords );
-	if( mtl->attrib_locs.tanget != -1 ) glDisableVertexAttribArray( mtl->attrib_locs.tanget );
+	if( mtl->attribLocs.position != -1 ) glDisableVertexAttribArray( mtl->attribLocs.position );
+	if( mtl->attribLocs.normal != -1 ) glDisableVertexAttribArray( mtl->attribLocs.normal );
+	if( mtl->attribLocs.texCoords != -1 ) glDisableVertexAttribArray( mtl->attribLocs.texCoords );
+	if( mtl->attribLocs.tanget != -1 ) glDisableVertexAttribArray( mtl->attribLocs.tanget );
 
 
 	if( mesh_skel_ctrl )
 	if( mesh_skel_ctrl )
 	{
 	{
-		glDisableVertexAttribArray( mtl->attrib_locs.vert_weight_bones_num );
-		glDisableVertexAttribArray( mtl->attrib_locs.vert_weight_bone_ids );
-		glDisableVertexAttribArray( mtl->attrib_locs.vert_weight_weights );
+		glDisableVertexAttribArray( mtl->attribLocs.vertWeightBonesNum );
+		glDisableVertexAttribArray( mtl->attribLocs.vertWeightBoneIds );
+		glDisableVertexAttribArray( mtl->attribLocs.vertWeightWeights );
 	}
 	}
 
 
 	vbo_t::UnbindAllTargets();
 	vbo_t::UnbindAllTargets();

+ 6 - 6
src/scene/mesh_node.h

@@ -3,23 +3,23 @@
 
 
 #include "common.h"
 #include "common.h"
 #include "node.h"
 #include "node.h"
-#include "material.h"
+#include "Material.h"
 
 
 class mesh_skel_ctrl_t;
 class mesh_skel_ctrl_t;
-class mesh_t;
+class Mesh;
 
 
 
 
 /// Mesh node
 /// Mesh node
 class mesh_node_t: public node_t
 class mesh_node_t: public node_t
 {
 {
 	private:
 	private:
-		void Render( material_t* mtl ) const; ///< Common code for Render() and RenderDepth()
+		void Render( Material* mtl ) const; ///< Common code for Render() and RenderDepth()
 
 
 	public:
 	public:
 		// resources
 		// resources
-		mesh_t* mesh;
-		material_t* material;
-		material_t* dp_material; ///< Depth pass material
+		Mesh* mesh;
+		Material* material;
+		Material* dp_material; ///< Depth pass material
 		// controllers
 		// controllers
 		mesh_skel_ctrl_t* mesh_skel_ctrl;
 		mesh_skel_ctrl_t* mesh_skel_ctrl;
 		// funcs
 		// funcs

+ 1 - 1
src/scene/node.cpp

@@ -142,7 +142,7 @@ void node_t::AddChild( node_t* node )
 //=====================================================================================================================================
 //=====================================================================================================================================
 void node_t::RemoveChild( node_t* node )
 void node_t::RemoveChild( node_t* node )
 {
 {
-	vec_t<node_t*>::iterator it = find( childs.begin(), childs.end(), node );
+	Vec<node_t*>::iterator it = find( childs.begin(), childs.end(), node );
 	if( it == childs.end() )
 	if( it == childs.end() )
 	{
 	{
 		ERROR( "Child not found" );
 		ERROR( "Child not found" );

+ 2 - 2
src/scene/node.h

@@ -7,7 +7,7 @@
 
 
 
 
 class bvolume_t;
 class bvolume_t;
-class material_t;
+class Material;
 class controller_t;
 class controller_t;
 
 
 
 
@@ -36,7 +36,7 @@ class node_t
 		mat4_t transformation_wspace;
 		mat4_t transformation_wspace;
 
 
 		node_t* parent;
 		node_t* parent;
-		vec_t<node_t*> childs;
+		Vec<node_t*> childs;
 
 
 		type_e type;
 		type_e type;
 
 

+ 8 - 8
src/scene/scene.cpp

@@ -5,7 +5,7 @@
 #include "mesh_node.h"
 #include "mesh_node.h"
 #include "light.h"
 #include "light.h"
 #include "controller.h"
 #include "controller.h"
-#include "material.h"
+#include "Material.h"
 
 
 namespace scene {
 namespace scene {
 
 
@@ -22,21 +22,21 @@ container_camera_t     cameras;
 container_mesh_node_t  mesh_nodes;
 container_mesh_node_t  mesh_nodes;
 container_skel_node_t  skel_nodes;
 container_skel_node_t  skel_nodes;
 
 
-vec_t<controller_t*>   controllers;
+Vec<controller_t*>   controllers;
 
 
 
 
 //=====================================================================================================================================
 //=====================================================================================================================================
 // Static template funcs                                                                                                              =
 // Static template funcs                                                                                                              =
 //=====================================================================================================================================
 //=====================================================================================================================================
-template<typename container_type_t, typename type_t> static void PutBackNode( container_type_t& container, type_t* x )
+template<typename container_Type, typename Type> static void PutBackNode( container_Type& container, Type* x )
 {
 {
 	DEBUG_ERR( std::find( container.begin(), container.end(), x ) != container.end() );
 	DEBUG_ERR( std::find( container.begin(), container.end(), x ) != container.end() );
 	container.push_back( x );
 	container.push_back( x );
 }
 }
 
 
-template<typename container_type_t, typename type_t> static void EraseNode( container_type_t& container, type_t* x )
+template<typename container_Type, typename Type> static void EraseNode( container_Type& container, Type* x )
 {
 {
-	typename container_type_t::iterator it = std::find( container.begin(), container.end(), x );
+	typename container_Type::iterator it = std::find( container.begin(), container.end(), x );
 	DEBUG_ERR( it == container.end() );
 	DEBUG_ERR( it == container.end() );
 	container.erase( it );
 	container.erase( it );
 }
 }
@@ -109,7 +109,7 @@ void RegisterController( controller_t* controller )
 
 
 void UnregisterController( controller_t* controller )
 void UnregisterController( controller_t* controller )
 {
 {
-	vec_t<controller_t*>::iterator it = std::find( controllers.begin(), controllers.end(), controller );
+	Vec<controller_t*>::iterator it = std::find( controllers.begin(), controllers.end(), controller );
 	DEBUG_ERR( it == controllers.end() );
 	DEBUG_ERR( it == controllers.end() );
 	controllers.erase( it );
 	controllers.erase( it );
 }
 }
@@ -155,11 +155,11 @@ void UpdateAllControllers()
 	/*for( container_node_t::iterator it=nodes.begin(); it!=nodes.end(); it++ )
 	/*for( container_node_t::iterator it=nodes.begin(); it!=nodes.end(); it++ )
 	{
 	{
 		node_t* node = (*it);
 		node_t* node = (*it);
-		for( vec_t<controller_t*>::iterator it1=node->controllers.begin(); it1!=node->controllers.end(); it1++ )
+		for( Vec<controller_t*>::iterator it1=node->controllers.begin(); it1!=node->controllers.end(); it1++ )
 			(*it1)->Update( 0.0 );
 			(*it1)->Update( 0.0 );
 	}*/
 	}*/
 
 
-	for( vec_t<controller_t*>::iterator it=controllers.begin(); it!=controllers.end(); it++ )
+	for( Vec<controller_t*>::iterator it=controllers.begin(); it!=controllers.end(); it++ )
 	{
 	{
 		(*it)->Update( 0.0 );
 		(*it)->Update( 0.0 );
 	}
 	}

+ 4 - 4
src/scene/scene.h

@@ -30,11 +30,11 @@ extern void UpdateAllWorldStuff();
 extern void UpdateAllControllers();
 extern void UpdateAllControllers();
 
 
 
 
-// container_t
+// Container
 /// entities container class
 /// entities container class
-template<typename type_t> class container_t: public vec_t<type_t*>
+template<typename Type> class container_t: public Vec<Type*>
 {
 {
-}; // end class container_t
+}; // end class Container
 
 
 
 
 
 
@@ -52,7 +52,7 @@ extern container_camera_t     cameras;
 extern container_mesh_node_t  mesh_nodes;
 extern container_mesh_node_t  mesh_nodes;
 extern container_skel_node_t  skel_nodes;
 extern container_skel_node_t  skel_nodes;
 
 
-extern vec_t<controller_t*>   controllers;
+extern Vec<controller_t*>   controllers;
 
 
 
 
 } // end namespace
 } // end namespace

+ 1 - 1
src/scene/skel_model_node.h

@@ -16,7 +16,7 @@ class skel_node_t;
 class skel_model_node_t: public node_t
 class skel_model_node_t: public node_t
 {
 {
 	public:
 	public:
-		vec_t<mesh_node_t*> mesh_nodes;
+		Vec<mesh_node_t*> mesh_nodes;
 		skel_node_t* skel_node;
 		skel_node_t* skel_node;
 		
 		
 		skel_model_node_t(): node_t(NT_SKEL_MODEL), skel_node(NULL) { is_group_node = true; }
 		skel_model_node_t(): node_t(NT_SKEL_MODEL), skel_node(NULL) { is_group_node = true; }

+ 4 - 4
src/scene/skel_node.cpp

@@ -1,7 +1,7 @@
 #include "skel_node.h"
 #include "skel_node.h"
 #include "renderer.h"
 #include "renderer.h"
-#include "skel_anim.h"
-#include "skeleton.h"
+#include "SkelAnim.h"
+#include "Skeleton.h"
 #include "skel_anim_ctrl.h"
 #include "skel_anim_ctrl.h"
 
 
 
 
@@ -20,7 +20,7 @@ skel_node_t::skel_node_t():
 //=====================================================================================================================================
 //=====================================================================================================================================
 void skel_node_t::Init( const char* filename )
 void skel_node_t::Init( const char* filename )
 {
 {
-	skeleton = rsrc::skeletons.Load( filename );
+	skeleton = rsrc::skeletons.load( filename );
 	skel_anim_ctrl = new skel_anim_ctrl_t( this );
 	skel_anim_ctrl = new skel_anim_ctrl_t( this );
 }
 }
 
 
@@ -30,7 +30,7 @@ void skel_node_t::Init( const char* filename )
 //=====================================================================================================================================
 //=====================================================================================================================================
 void skel_node_t::Deinit()
 void skel_node_t::Deinit()
 {
 {
-	rsrc::skeletons.Unload( skeleton );
+	rsrc::skeletons.unload( skeleton );
 }
 }
 
 
 
 

+ 2 - 2
src/scene/skel_node.h

@@ -6,7 +6,7 @@
 #include "controller.h"
 #include "controller.h"
 #include "gmath.h"
 #include "gmath.h"
 
 
-class skeleton_t;
+class Skeleton;
 class skel_anim_ctrl_t;
 class skel_anim_ctrl_t;
 
 
 
 
@@ -14,7 +14,7 @@ class skel_anim_ctrl_t;
 class skel_node_t: public node_t
 class skel_node_t: public node_t
 {
 {
 	public:
 	public:
-		skeleton_t* skeleton; ///< The skeleton resource
+		Skeleton* skeleton; ///< The skeleton resource
 		skel_anim_ctrl_t* skel_anim_ctrl; ///< Hold the controller here as well
 		skel_anim_ctrl_t* skel_anim_ctrl; ///< Hold the controller here as well
 
 
 		skel_node_t();
 		skel_node_t();

+ 2 - 2
src/tokenizer/Scanner.h

@@ -160,8 +160,8 @@ class Scanner
 		Scanner( bool newlinesAsWhitespace = true );
 		Scanner( bool newlinesAsWhitespace = true );
 		~Scanner() { /* The destructor does NOTHING. The class does not make any mem allocations */ }
 		~Scanner() { /* The destructor does NOTHING. The class does not make any mem allocations */ }
 
 
-		bool loadFile( const char* filename ); ///< Load a file to extract tokens
-		bool loadIoStream( iostream* iostream_, const char* scriptName_ = "unamed-iostream" ); ///< Load a STL iostream to extract tokens
+		bool loadFile( const char* filename ); ///< load a file to extract tokens
+		bool loadIoStream( iostream* iostream_, const char* scriptName_ = "unamed-iostream" ); ///< load a STL iostream to extract tokens
 		void unload();
 		void unload();
 
 
 		static void   printTokenInfo( const Token& token ); ///< Print info of the given token
 		static void   printTokenInfo( const Token& token ); ///< Print info of the given token

+ 4 - 4
src/tokenizer/parser.h

@@ -29,7 +29,7 @@ It parses expressions like this one: { 10 -0.2 123.e-10 -0x0FF } and stores the
 @param arr The array that the func returns the numbers
 @param arr The array that the func returns the numbers
 @return True if the parsing was success or false otherwise
 @return True if the parsing was success or false otherwise
 */
 */
-template <typename type_t> bool ParseArrOfNumbers( Scanner& scanner, bool paren, bool signs, uint size, type_t* arr )
+template <typename Type> bool ParseArrOfNumbers( Scanner& scanner, bool paren, bool signs, uint size, Type* arr )
 {
 {
 	const Scanner::Token* token;
 	const Scanner::Token* token;
 
 
@@ -74,12 +74,12 @@ template <typename type_t> bool ParseArrOfNumbers( Scanner& scanner, bool paren,
 		} // end if signs
 		} // end if signs
 
 
 		// put the number in the arr and do typecasting from int to float
 		// put the number in the arr and do typecasting from int to float
-		type_t nmbr;
+		Type nmbr;
 
 
 		if( token->type == Scanner::DT_FLOAT )
 		if( token->type == Scanner::DT_FLOAT )
-			nmbr = static_cast<type_t>( token->value.float_ );
+			nmbr = static_cast<Type>( token->value.float_ );
 		else
 		else
-			nmbr = static_cast<type_t>( token->value.int_ );
+			nmbr = static_cast<Type>( token->value.int_ );
 
 
 		arr[i] = (sign==0) ? nmbr : -nmbr;
 		arr[i] = (sign==0) ? nmbr : -nmbr;
 	}
 	}

+ 11 - 11
src/ui/ui.cpp

@@ -2,8 +2,8 @@
 #include <stdarg.h>
 #include <stdarg.h>
 #include "ui.h"
 #include "ui.h"
 #include "renderer.h"
 #include "renderer.h"
-#include "texture.h"
-#include "resource.h"
+#include "Texture.h"
+#include "Resource.h"
 
 
 namespace ui {
 namespace ui {
 
 
@@ -13,9 +13,9 @@ namespace ui {
 data members                                                                                                                          =
 data members                                                                                                                          =
 =======================================================================================================================================
 =======================================================================================================================================
 */
 */
-static texture_t* font_map;
+static Texture* font_map;
 
 
-static shader_prog_t* shader;
+static ShaderProg* shader;
 
 
 static float  initial_x;
 static float  initial_x;
 static float  font_w;
 static float  font_w;
@@ -37,8 +37,8 @@ static funcs
 // SetGL
 // SetGL
 static void SetGL()
 static void SetGL()
 {
 {
-	shader->Bind();
-	shader->LocTexUnit( shader->GetUniformLocation(0), *font_map, 0 );
+	shader->bind();
+	shader->locTexUnit( shader->GetUniLoc(0), *font_map, 0 );
 
 
 	glEnable( GL_BLEND );
 	glEnable( GL_BLEND );
 	glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
 	glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
@@ -53,7 +53,7 @@ static void SetGL()
 
 
 	glMatrixMode( GL_PROJECTION );
 	glMatrixMode( GL_PROJECTION );
 	glPushMatrix();
 	glPushMatrix();
-	r::LoadMatrix( r::Ortho( -1.0, 1.0, -1.0, 1.0, -1.0, 1.0 ) );
+	r::loadMatrix( r::Ortho( -1.0, 1.0, -1.0, 1.0, -1.0, 1.0 ) );
 
 
 	glMatrixMode( GL_MODELVIEW );
 	glMatrixMode( GL_MODELVIEW );
 	glPushMatrix();
 	glPushMatrix();
@@ -159,10 +159,10 @@ non static funcs
 // exec after init SDL
 // exec after init SDL
 void Init()
 void Init()
 {
 {
-	font_map = rsrc::textures.Load( "gfx/fontmapa.tga" );
-	font_map->TexParameter( GL_TEXTURE_MIN_FILTER, GL_LINEAR );
-	//font_map->TexParameter( GL_TEXTURE_MAG_FILTER, GL_NEAREST );
-	shader = rsrc::shaders.Load( "shaders/txt.glsl" );
+	font_map = rsrc::textures.load( "gfx/fontmapa.tga" );
+	font_map->texParameter( GL_TEXTURE_MIN_FILTER, GL_LINEAR );
+	//font_map->texParameter( GL_TEXTURE_MAG_FILTER, GL_NEAREST );
+	shader = rsrc::shaders.load( "shaders/txt.glsl" );
 	SetPos( 0.0f, 0.0f );
 	SetPos( 0.0f, 0.0f );
 	SetFontWidth( 0.05f );
 	SetFontWidth( 0.05f );
 	SetColor( vec4_t(1.0f, 1.0f, 1.0f, 1.0f) );
 	SetColor( vec4_t(1.0f, 1.0f, 1.0f, 1.0f) );

+ 5 - 5
src/uncategorized/collision.h

@@ -314,19 +314,19 @@ class obb_t: public bvolume_t
 collision triangle                                                                                                                    =
 collision triangle                                                                                                                    =
 =======================================================================================================================================
 =======================================================================================================================================
 */
 */
-/*class ctriangle_t: public bvolume_t
+/*class cTriangle: public bvolume_t
 {
 {
 	public:
 	public:
 		// data members
 		// data members
 		vec3_t a, b, c;
 		vec3_t a, b, c;
 
 
 		// constructors & destractor
 		// constructors & destractor
-		ctriangle_t() {}
-		ctriangle_t( const vec3_t& a_, const vec3_t& b_, const vec3_t& c_ ): a(a_), b(b_), c(c_) {}
-		ctriangle_t( const  )
+		cTriangle() {}
+		cTriangle( const vec3_t& a_, const vec3_t& b_, const vec3_t& c_ ): a(a_), b(b_), c(c_) {}
+		cTriangle( const  )
 
 
 		// operators
 		// operators
-		ctriangle_t& operator =( const ctriangle_t& other ) { a=other.a; b=other.b; c=other.c; return (*this); }
+		cTriangle& operator =( const cTriangle& other ) { a=other.a; b=other.b; c=other.c; return (*this); }
 
 
 		// std funcs
 		// std funcs
 };*/
 };*/

+ 17 - 17
src/uncategorized/map.cpp

@@ -1,9 +1,9 @@
 #include <limits>
 #include <limits>
 #include "map.h"
 #include "map.h"
-#include "mesh.h"
+#include "Mesh.h"
 #include "Scanner.h"
 #include "Scanner.h"
 #include "parser.h"
 #include "parser.h"
-#include "resource.h"
+#include "Resource.h"
 #include "camera.h"
 #include "camera.h"
 
 
 
 
@@ -12,7 +12,7 @@
 CreateRoot                                                                                                                            =
 CreateRoot                                                                                                                            =
 =======================================================================================================================================
 =======================================================================================================================================
 */
 */
-void octree_t::CreateRoot( const vec_t<mesh_t*>& meshes )
+void octree_t::CreateRoot( const Vec<Mesh*>& meshes )
 {
 {
 	DEBUG_ERR( root ); // root should be NULL
 	DEBUG_ERR( root ); // root should be NULL
 
 
@@ -21,16 +21,16 @@ void octree_t::CreateRoot( const vec_t<mesh_t*>& meshes )
 
 
 	for( uint m=0; m<meshes.size(); m++ )
 	for( uint m=0; m<meshes.size(); m++ )
 	{
 	{
-		mesh_t* cmesh = meshes[m];
-		for( uint v=0; v<cmesh->vert_coords.size(); v++ )
+		Mesh* cmesh = meshes[m];
+		for( uint v=0; v<cmesh->vertCoords.size(); v++ )
 		{
 		{
-			const vec3_t& vert_coords = cmesh->vert_coords[v];
+			const vec3_t& vertCoords = cmesh->vertCoords[v];
 			for( int i=0; i<3; i++ )
 			for( int i=0; i<3; i++ )
 			{
 			{
-				if( vert_coords[i] > max[i] )
-					max[i] = vert_coords[i];
-				else if( vert_coords[i] < min[i] )
-					min[i] = vert_coords[i];
+				if( vertCoords[i] > max[i] )
+					max[i] = vertCoords[i];
+				else if( vertCoords[i] < min[i] )
+					min[i] = vertCoords[i];
 			} // end for 3 times
 			} // end for 3 times
 		} // end for all mesh verts
 		} // end for all mesh verts
 	} // end for all meshes
 	} // end for all meshes
@@ -43,15 +43,15 @@ void octree_t::CreateRoot( const vec_t<mesh_t*>& meshes )
 
 
 
 
 	/// create the face and vert ids
 	/// create the face and vert ids
-	DEBUG_ERR( node->face_ids.size() != 0 || node->vert_ids.size() != 0 || node->meshes.size() != 0 ); // vectors not empty. wrong node init
+	DEBUG_ERR( node->face_ids.size() != 0 || node->vertIds.size() != 0 || node->meshes.size() != 0 ); // vectors not empty. wrong node init
 
 
 	node->face_ids.resize( meshes.size() );
 	node->face_ids.resize( meshes.size() );
-	node->vert_ids.resize( meshes.size() );
+	node->vertIds.resize( meshes.size() );
 	node->meshes.resize( meshes.size() );
 	node->meshes.resize( meshes.size() );
 
 
 	for( uint m=0; m<meshes.size(); m++ )
 	for( uint m=0; m<meshes.size(); m++ )
 	{
 	{
-		mesh_t* cmesh = meshes[m];
+		Mesh* cmesh = meshes[m];
 
 
 		// first set the mesh
 		// first set the mesh
 		node->meshes[m] = cmesh;
 		node->meshes[m] = cmesh;
@@ -127,7 +127,7 @@ void octree_t::SubdivideNode( node_t* node )
 CreateTree                                                                                                                            =
 CreateTree                                                                                                                            =
 =======================================================================================================================================
 =======================================================================================================================================
 */
 */
-void octree_t::CreateTree( const vec_t<mesh_t*>& meshes )
+void octree_t::CreateTree( const Vec<Mesh*>& meshes )
 {
 {
 	CreateRoot( meshes );
 	CreateRoot( meshes );
 	SubdivideNode( root );
 	SubdivideNode( root );
@@ -178,10 +178,10 @@ map
 
 
 /*
 /*
 =======================================================================================================================================
 =======================================================================================================================================
-Load                                                                                                                                  =
+load                                                                                                                                  =
 =======================================================================================================================================
 =======================================================================================================================================
 */
 */
-bool map_t::Load( const char* filename )
+bool map_t::load( const char* filename )
 {
 {
 	DEBUG_ERR( meshes.size() != 0 ); // meshes vector should be empty
 	DEBUG_ERR( meshes.size() != 0 ); // meshes vector should be empty
 
 
@@ -196,7 +196,7 @@ bool map_t::Load( const char* filename )
 		// strings is what we want in this case... please let it be G-Strings
 		// strings is what we want in this case... please let it be G-Strings
 		if( token->code == Scanner::TC_STRING )
 		if( token->code == Scanner::TC_STRING )
 		{
 		{
-			mesh_t* mesh = rsrc::meshes.Load( token->value.string );
+			Mesh* mesh = rsrc::meshes.load( token->value.string );
 			if( !mesh ) return false;
 			if( !mesh ) return false;
 
 
 			meshes.push_back( mesh );
 			meshes.push_back( mesh );

+ 8 - 8
src/uncategorized/map.h

@@ -4,7 +4,7 @@
 #include "common.h"
 #include "common.h"
 #include "collision.h"
 #include "collision.h"
 
 
-class mesh_t;
+class Mesh;
 class camera_t;
 class camera_t;
 
 
 
 
@@ -24,9 +24,9 @@ class octree_t
 				node_t* childs[8];
 				node_t* childs[8];
 				aabb_t  bounding_box;
 				aabb_t  bounding_box;
 
 
-				vec_t<mesh_t*>   meshes;
-				vec_t< vec_t<uint> > vert_ids;
-				vec_t< vec_t<uint> > face_ids;
+				Vec<Mesh*>   meshes;
+				Vec< Vec<uint> > vertIds;
+				Vec< Vec<uint> > face_ids;
 
 
 				node_t() {}
 				node_t() {}
 				~node_t() { /*ToDo: when class is finalized add code*/ }
 				~node_t() { /*ToDo: when class is finalized add code*/ }
@@ -40,7 +40,7 @@ class octree_t
 		// funcs for the tree creation
 		// funcs for the tree creation
 		bool IsSubdivHeuristicMet( node_t* node ) const;
 		bool IsSubdivHeuristicMet( node_t* node ) const;
 		void SubdivideNode( node_t* node );
 		void SubdivideNode( node_t* node );
-		void CreateRoot( const vec_t<mesh_t*>& meshes );
+		void CreateRoot( const Vec<Mesh*>& meshes );
 
 
 		// frustum funcs
 		// frustum funcs
 		uint CheckNodeAgainstFrustum( node_t* node, const camera_t& cam ) const;
 		uint CheckNodeAgainstFrustum( node_t* node, const camera_t& cam ) const;
@@ -48,7 +48,7 @@ class octree_t
 	public:
 	public:
 		node_t* root;
 		node_t* root;
 
 
-		void CreateTree( const vec_t<mesh_t*>& meshes );
+		void CreateTree( const Vec<Mesh*>& meshes );
 };
 };
 
 
 
 
@@ -60,10 +60,10 @@ map_t
 class map_t
 class map_t
 {
 {
 	public:
 	public:
-		vec_t<mesh_t*> meshes;
+		Vec<Mesh*> meshes;
 		octree_t             octree;
 		octree_t             octree;
 
 
-		bool Load( const char* filename );
+		bool load( const char* filename );
 		void CreateOctree() { DEBUG_ERR( meshes.size() < 1 ); octree.CreateTree(meshes); };
 		void CreateOctree() { DEBUG_ERR( meshes.size() < 1 ); octree.CreateTree(meshes); };
 };
 };
 
 

+ 1 - 1
src/uncategorized/particles.h

@@ -46,7 +46,7 @@ class particle_emitter_t: public object_t
 		};
 		};
 
 
 	public:
 	public:
-		vec_t<particle_t> particles;
+		Vec<particle_t> particles;
 
 
 		int start_frame;
 		int start_frame;
 		int stop_frame;
 		int stop_frame;

+ 15 - 15
src/uncategorized/skybox.cpp

@@ -1,5 +1,5 @@
 #include "skybox.h"
 #include "skybox.h"
-#include "resource.h"
+#include "Resource.h"
 #include "renderer.h"
 #include "renderer.h"
 #include "gmath.h"
 #include "gmath.h"
 #include "camera.h"
 #include "camera.h"
@@ -26,21 +26,21 @@ static float coords [][4][3] =
 
 
 /*
 /*
 =======================================================================================================================================
 =======================================================================================================================================
-Load                                                                                                                                  =
+load                                                                                                                                  =
 =======================================================================================================================================
 =======================================================================================================================================
 */
 */
-bool skybox_t::Load( const char* filenames[6] )
+bool skybox_t::load( const char* filenames[6] )
 {
 {
 	for( int i=0; i<6; i++ )
 	for( int i=0; i<6; i++ )
 	{
 	{
-		textures[i] = rsrc::textures.Load( filenames[i] );
+		textures[i] = rsrc::textures.load( filenames[i] );
 	}
 	}
 
 
-	noise = rsrc::textures.Load( "gfx/noise2.tga" );
-	noise->TexParameter( GL_TEXTURE_WRAP_S, GL_REPEAT );
-	noise->TexParameter( GL_TEXTURE_WRAP_T, GL_REPEAT );
+	noise = rsrc::textures.load( "gfx/noise2.tga" );
+	noise->texParameter( GL_TEXTURE_WRAP_S, GL_REPEAT );
+	noise->texParameter( GL_TEXTURE_WRAP_T, GL_REPEAT );
 
 
-	shader = rsrc::shaders.Load( "shaders/ms_mp_skybox.glsl" );
+	shader = rsrc::shaders.load( "shaders/ms_mp_skybox.glsl" );
 
 
 	return true;
 	return true;
 }
 }
@@ -58,16 +58,16 @@ void skybox_t::Render( const mat3_t& rotation )
 
 
 	glPushMatrix();
 	glPushMatrix();
 
 
-	shader->Bind();
-	glUniform1i( shader->GetUniformLocation("colormap"), 0 );
-	shader->LocTexUnit( shader->GetUniformLocation("noisemap"), *noise, 1 );
-	glUniform1f( shader->GetUniformLocation("timer"), (rotation_ang/(2*PI))*100 );
-	glUniform3fv( shader->GetUniformLocation("scene_ambient_color"), 1, &(vec3_t( 1.0, 1.0, 1.0 ) / scene::GetAmbientColor())[0] );
+	shader->bind();
+	glUniform1i( shader->getUniLoc("colormap"), 0 );
+	shader->locTexUnit( shader->getUniLoc("noisemap"), *noise, 1 );
+	glUniform1f( shader->getUniLoc("timer"), (rotation_ang/(2*PI))*100 );
+	glUniform3fv( shader->getUniLoc("scene_ambient_color"), 1, &(vec3_t( 1.0, 1.0, 1.0 ) / scene::GetAmbientColor())[0] );
 
 
 	// set the rotation matrix
 	// set the rotation matrix
 	mat3_t tmp( rotation );
 	mat3_t tmp( rotation );
 	tmp.RotateYAxis(rotation_ang);
 	tmp.RotateYAxis(rotation_ang);
-	r::LoadMatrix( mat4_t( tmp ) );
+	r::loadMatrix( mat4_t( tmp ) );
 	rotation_ang += 0.0001;
 	rotation_ang += 0.0001;
 	if( rotation_ang >= 2*PI ) rotation_ang = 0.0;
 	if( rotation_ang >= 2*PI ) rotation_ang = 0.0;
 
 
@@ -78,7 +78,7 @@ void skybox_t::Render( const mat3_t& rotation )
 
 
 	for( int i=0; i<6; i++ )
 	for( int i=0; i<6; i++ )
 	{
 	{
-		textures[i]->Bind(0);
+		textures[i]->bind(0);
 		glBegin( GL_QUADS );
 		glBegin( GL_QUADS );
 			glTexCoord2fv( uvs[0] );
 			glTexCoord2fv( uvs[0] );
 			glVertex3fv( coords[i][0] );
 			glVertex3fv( coords[i][0] );

+ 6 - 6
src/uncategorized/skybox.h

@@ -2,10 +2,10 @@
 #define _SKYBOX_H_
 #define _SKYBOX_H_
 
 
 #include "common.h"
 #include "common.h"
-#include "texture.h"
+#include "Texture.h"
 #include "gmath.h"
 #include "gmath.h"
 
 
-class shader_prog_t;
+class ShaderProg;
 
 
 class skybox_t
 class skybox_t
 {
 {
@@ -20,16 +20,16 @@ class skybox_t
 			DOWN
 			DOWN
 		};
 		};
 
 
-		texture_t* textures[6];
-		texture_t* noise;
-		shader_prog_t* shader;
+		Texture* textures[6];
+		Texture* noise;
+		ShaderProg* shader;
 
 
 		float rotation_ang;
 		float rotation_ang;
 
 
 	public:
 	public:
 		skybox_t() { rotation_ang=0.0; }
 		skybox_t() { rotation_ang=0.0; }
 
 
-		bool Load( const char* filenames[6] );
+		bool load( const char* filenames[6] );
 		void Render( const mat3_t& rotation );
 		void Render( const mat3_t& rotation );
 };
 };
 
 

+ 22 - 22
src/utility/common.h

@@ -37,7 +37,7 @@ typedef unsigned long int ulong;
 //=====================================================================================================================================
 //=====================================================================================================================================
 // misc funcs                                                                                                                         =
 // misc funcs                                                                                                                         =
 //=====================================================================================================================================
 //=====================================================================================================================================
-template<typename type_t> class vec_t;
+template<typename Type> class Vec;
 
 
 extern string        IntToStr( int );
 extern string        IntToStr( int );
 extern string        FloatToStr( float );
 extern string        FloatToStr( float );
@@ -112,22 +112,22 @@ extern string GetFunctionFromPrettyFunction( const char* pretty_function );
 
 
 
 
 /// useful property macros
 /// useful property macros
-#define PROPERTY_RW( __type_t__, __var_name__, __set_func__, __get_func__ ) \
+#define PROPERTY_RW( __Type__, __var_name__, __set_func__, __get_func__ ) \
 	private: \
 	private: \
-		__type_t__ __var_name__; \
+		__Type__ __var_name__; \
 	public: \
 	public: \
-		void __set_func__( const __type_t__& __x__ ) { \
+		void __set_func__( const __Type__& __x__ ) { \
 			__var_name__ = __x__; \
 			__var_name__ = __x__; \
 		} \
 		} \
-		const __type_t__& __get_func__() const { \
+		const __Type__& __get_func__() const { \
 			return __var_name__; \
 			return __var_name__; \
 		}
 		}
 
 
-#define PROPERTY_R( __type_t__, __var_name__, __get_func__ ) \
+#define PROPERTY_R( __Type__, __var_name__, __get_func__ ) \
 	private: \
 	private: \
-		__type_t__ __var_name__; \
+		__Type__ __var_name__; \
 	public: \
 	public: \
-		const __type_t__& __get_func__() const { \
+		const __Type__& __get_func__() const { \
 			return __var_name__; \
 			return __var_name__; \
 		}
 		}
 
 
@@ -144,38 +144,38 @@ extern string GetFunctionFromPrettyFunction( const char* pretty_function );
 // MemZero                                                                                                                            =
 // MemZero                                                                                                                            =
 //=====================================================================================================================================
 //=====================================================================================================================================
 /// sets memory to zero
 /// sets memory to zero
-template <typename type_t> inline void MemZero( type_t& t )
+template <typename Type> inline void MemZero( Type& t )
 {
 {
-	memset( &t, 0, sizeof(type_t) );
+	memset( &t, 0, sizeof(Type) );
 }
 }
 
 
 
 
 //=====================================================================================================================================
 //=====================================================================================================================================
-// vec_t                                                                                                                              =
+// Vec                                                                                                                              =
 //=====================================================================================================================================
 //=====================================================================================================================================
 /// New vector class
 /// New vector class
-template<typename type_t> class vec_t: public vector<type_t>
+template<typename Type> class Vec: public vector<Type>
 {
 {
 	public:
 	public:
-		vec_t(): vector<type_t>() {}
-		vec_t( size_t size ): vector<type_t>(size) {}
-		vec_t( size_t size, type_t val ): vector<type_t>(val,size) {}
+		Vec(): vector<Type>() {}
+		Vec( size_t size ): vector<Type>(size) {}
+		Vec( size_t size, Type val ): vector<Type>(val,size) {}
 
 
-		type_t& operator[]( size_t n )
+		Type& operator[]( size_t n )
 		{
 		{
-			DEBUG_ERR( n >= vector<type_t>::size() );
-			return vector<type_t>::operator []( n );
+			DEBUG_ERR( n >= vector<Type>::size() );
+			return vector<Type>::operator []( n );
 		}
 		}
 
 
-		const type_t& operator[]( size_t n ) const
+		const Type& operator[]( size_t n ) const
 		{
 		{
-			DEBUG_ERR( n >= vector<type_t>::size() );
-			return vector<type_t>::operator []( n );
+			DEBUG_ERR( n >= vector<Type>::size() );
+			return vector<Type>::operator []( n );
 		}
 		}
 
 
 		size_t GetSizeInBytes() const
 		size_t GetSizeInBytes() const
 		{
 		{
-			return vector<type_t>::size() * sizeof(type_t);
+			return vector<Type>::size() * sizeof(Type);
 		}
 		}
 };
 };
 
 

+ 1 - 1
src/utility/u_string.h

@@ -31,7 +31,7 @@ class string_t
 		uint length;
 		uint length;
 		
 		
 		// private funcs
 		// private funcs
-		template<typename type_t> string_t ConvertT( type_t t, const char* format )
+		template<typename Type> string_t ConvertT( Type t, const char* format )
 		{
 		{
 			string_t out;
 			string_t out;
 			char tmps [1024];
 			char tmps [1024];

+ 2 - 2
src/utility/util.cpp

@@ -50,9 +50,9 @@ string ReadFile( const char* filename )
 //=====================================================================================================================================
 //=====================================================================================================================================
 // GetFileLines                                                                                                                       =
 // GetFileLines                                                                                                                       =
 //=====================================================================================================================================
 //=====================================================================================================================================
-vec_t<string> GetFileLines( const char* filename )
+Vec<string> GetFileLines( const char* filename )
 {
 {
-	vec_t<string> lines;
+	Vec<string> lines;
 	ifstream ifs( filename );
 	ifstream ifs( filename );
 	if( !ifs.is_open() )
 	if( !ifs.is_open() )
 	{
 	{

+ 1 - 1
src/utility/util.h

@@ -9,7 +9,7 @@ extern int   RandRange( int min, int max );
 extern float RandRange( float min, float max );
 extern float RandRange( float min, float max );
 
 
 extern string        ReadFile( const char* filename );
 extern string        ReadFile( const char* filename );
-extern vec_t<string> GetFileLines( const char* filename );
+extern Vec<string> GetFileLines( const char* filename );
 extern char*         GetFileExtension( const char* path );
 extern char*         GetFileExtension( const char* path );
 extern char*         CutPath( const char* path );
 extern char*         CutPath( const char* path );
 extern string        GetPath( const char* path );
 extern string        GetPath( const char* path );

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