Browse Source

Refactoring

Panagiotis Christopoulos Charitos 14 years ago
parent
commit
76e577cb69

+ 3 - 7
src/Collision/Plane.h

@@ -3,6 +3,7 @@
 
 #include "CollisionShape.h"
 #include "Math/Math.h"
+#include "Util/Accessors.h"
 
 
 namespace Col {
@@ -29,13 +30,8 @@ class Plane: public CollisionShape
 
 		/// @name Accessors
 		/// @{
-		const Vec3& getNormal() const {return normal;}
-		Vec3& getNormal() {return normal;}
-		void setNormal(const Vec3& n) {normal = n;}
-
-		float getOffset() const {return offset;}
-		float& getOffset() {return offset;}
-		void setOffset(float o) {offset = o;}
+		GETTER_SETTER(Vec3, normal, getNormal, setNormal)
+		GETTER_SETTER_BY_VAL(float, offset, getOffset, setOffset)
 		/// @}
 
 		/// Return the transformed

+ 3 - 0
src/GfxApi/GlStateMachine.cpp

@@ -10,6 +10,9 @@ GLenum GlStateMachine::flagEnums[] =
 	GL_DEPTH_TEST,
 	GL_BLEND,
 	GL_STENCIL_TEST,
+	GL_CULL_FACE,
+	GL_RASTERIZER_DISCARD,
+	GL_POLYGON_OFFSET_FILL,
 	0
 };
 

+ 2 - 2
src/Renderer/MainRenderer.cpp

@@ -70,13 +70,13 @@ void MainRenderer::initGl()
 	glDepthFunc(GL_LEQUAL);
 	// CullFace is always on
 	glCullFace(GL_BACK);
-	glEnable(GL_CULL_FACE);
+	GlStateMachineSingleton.getInstance().enable(GL_CULL_FACE);
 
 	// defaults
 	//glDisable(GL_LIGHTING);
 	//glDisable(GL_TEXTURE_2D);
 	GlStateMachineSingleton::getInstance().enable(GL_BLEND, false);
-	glDisable(GL_STENCIL_TEST);
+	GlStateMachineSingleton::getInstance().disable(GL_STENCIL_TEST);
 	glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
 	glDepthMask(true);
 	glDepthFunc(GL_LESS);

+ 6 - 6
src/Renderer/SkinsDeformer.cpp

@@ -25,15 +25,15 @@ void SkinsDeformer::init()
 //==============================================================================
 void SkinsDeformer::deform(SkinPatchNode& node)
 {
-	ASSERT(node.getParent() != NULL); // The SkinPatchNode are always have
-	                                  // parent
+	ASSERT(node.getParent() != NULL); // The SkinPatchNodes always have parent
 	ASSERT(static_cast<SceneNode*>(node.getParent())->getSceneNodeType() ==
-		SceneNode::SNT_SKIN);
+		SceneNode::SNT_SKIN); // And their parent must be
 
 	SkinNode* skinNode = static_cast<SkinNode*>(node.getParent());
 
-	glEnable(GL_RASTERIZER_DISCARD);
+	GlStateMachineSingleton::getInstance().enable(GL_RASTERIZER_DISCARD);
 
+	// Chose sProg
 	const ShaderProg* sProg;
 
 	if(node.getModelPatchRsrc().supportsNormals() &&
@@ -73,11 +73,11 @@ void SkinsDeformer::deform(SkinPatchNode& node)
 	//glBeginQuery(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN, this->Query);
 	glBeginTransformFeedback(GL_POINTS);
 		glDrawArrays(GL_POINTS, 0,
-		node.getModelPatchRsrc().getMesh().getVertsNum());
+			node.getModelPatchRsrc().getMesh().getVertsNum());
 	glEndTransformFeedback();
 	//glEndQuery(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN);
 
-	glDisable(GL_RASTERIZER_DISCARD);
+	GlStateMachineSingleton::getInstance().disable(GL_RASTERIZER_DISCARD);
 }
 
 

+ 9 - 12
src/Renderer/Sm.cpp

@@ -71,15 +71,13 @@ void Sm::initLevel(uint resolution, float distance, bool bilinear, Level& level)
 		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE,
 			GL_COMPARE_R_TO_TEXTURE);
 		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL);
-		/*
-		 * If you dont want to use the FFP for comparing the shadowmap
-		 * (the above two lines) then you can make the comparison
-		 * inside the glsl shader. The GL_LEQUAL means that:
-		 * shadow = (R <= Dt) ? 1.0 : 0.0; . The R is given by:
-		 * 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.
-		 */
+		/*If you dont want to use the FFP for comparing the shadowmap
+		(the above two lines) then you can make the comparison
+		inside the glsl shader. The GL_LEQUAL means that:
+		shadow = (R <= Dt) ? 1.0 : 0.0; . The R is given by:
+		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.*/
 
 		// inform the we wont write to color buffers
 		level.fbo.setNumOfColorAttachements(0);
@@ -142,7 +140,7 @@ void Sm::run(const Light& light, float distance)
 
 	// for artifacts
 	glPolygonOffset(2.0, 2.0); // keep the values as low as possible!!!!
-	glEnable(GL_POLYGON_OFFSET_FILL);
+	GlStateMachineSingleton::getInstance().enable(GL_POLYGON_OFFSET_FILL);
 
 	// render all
 	BOOST_FOREACH(const RenderableNode* node,
@@ -164,10 +162,9 @@ void Sm::run(const Light& light, float distance)
 	}
 
 	// restore GL
-	glDisable(GL_POLYGON_OFFSET_FILL);
+	GlStateMachineSingleton::getInstance().disable(GL_POLYGON_OFFSET_FILL);
 	glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
 
-
 	// FBO
 	crntLevel->fbo.unbind();
 }

+ 0 - 1
src/Scene/MaterialRuntime.h

@@ -8,7 +8,6 @@
 #include "Resources/Material.h"
 
 
-
 /// One layer above material resource
 class MaterialRuntime: private MaterialProps
 {