Panagiotis Christopoulos Charitos 15 tahun lalu
induk
melakukan
a01426f40b

File diff ditekan karena terlalu besar
+ 360 - 356
build/debug/Makefile


+ 3 - 0
src/Core/App.cpp

@@ -52,6 +52,7 @@ App::App(int argc, char* argv[], Object* parent):
 	parseCommandLineArgs(argc, argv);
 
 	messageHandler = new MessageHandler(this);
+	messageHandler->getSignal().connect(boost::bind(&App::handleMessageHanlderMsgs, this, _1, _2, _3, _4));
 
 	printAppInfo();
 
@@ -281,7 +282,9 @@ void App::execStdinScpripts()
 		string cmd = app->getStdinLintener().getLine();
 
 		if(cmd.length() < 1)
+		{
 			break;
+		}
 
 		app->getScriptingEngine().execScript(cmd.c_str(), "command line input");
 	}

+ 9 - 1
src/Core/App.h

@@ -5,6 +5,7 @@
 #include <boost/filesystem.hpp>
 #include "Common.h"
 #include "Object.h"
+#include "MessageHandler.h"
 
 
 class ScriptingEngine;
@@ -12,7 +13,6 @@ class StdinListener;
 class Scene;
 class MainRenderer;
 class Camera;
-class MessageHandler;
 
 
 /**
@@ -59,6 +59,7 @@ class App: public Object
 		MainRenderer& getMainRenderer();
 		Camera* getActiveCam() {return activeCam;}
 		void setActiveCam(Camera* cam) {activeCam = cam;}
+		MessageHandler& getMessageHandler();
 		/**@}*/
 
 		/**
@@ -128,6 +129,13 @@ inline MainRenderer& App::getMainRenderer()
 }
 
 
+inline MessageHandler& App::getMessageHandler()
+{
+	/// @todo Check
+	return *messageHandler;
+}
+
+
 inline void App::handleMessageHanlderMsgs(const char* file, int line, const char* func, const std::string& msg)
 {
 	std::cout << file << ":" << line << " " << func << ": " << msg << std::endl;

+ 2 - 4
src/Renderer/Bs.h

@@ -1,7 +1,6 @@
 #ifndef BS_H
 #define BS_H
 
-#include "Common.h"
 #include "RenderingStage.h"
 #include "Fbo.h"
 #include "RsrcPtr.h"
@@ -11,9 +10,8 @@
 class ShaderProg;
 
 
-/**
- * Blending stage
- */
+/// Blending stage.
+/// The objects that blend must be handled differently
 class Bs: public RenderingStage
 {
 	public:

+ 31 - 0
src/Renderer/BufferObjects/BufferObject.cpp

@@ -0,0 +1,31 @@
+#include "BufferObject.h"
+
+
+//======================================================================================================================
+// create                                                                                                              =
+//======================================================================================================================
+void BufferObject::create(GLenum target_, uint sizeInBytes, const void* dataPtr, GLenum usage_)
+{
+	RASSERT_THROW_EXCEPTION(isCreated()); // BO already initialized
+	// unacceptable usage_
+	RASSERT_THROW_EXCEPTION(usage_ != GL_STREAM_DRAW && usage_ != GL_STATIC_DRAW && usage_ != GL_DYNAMIC_DRAW);
+	RASSERT_THROW_EXCEPTION(sizeInBytes < 1); // unacceptable sizeInBytes
+
+	usage = usage_;
+	target = target_;
+
+	glGenBuffers(1, &glId);
+	bind();
+	glBufferData(target, sizeInBytes, dataPtr, usage);
+
+	// make a check
+	int bufferSize = 0;
+	glGetBufferParameteriv(target, GL_BUFFER_SIZE, &bufferSize);
+	if(sizeInBytes != (uint)bufferSize)
+	{
+		deleteBuff();
+		throw EXCEPTION("Data size mismatch");
+	}
+
+	unbind();
+}

+ 45 - 90
src/Renderer/BufferObjects/BufferObject.h

@@ -1,13 +1,12 @@
-#ifndef _BUFFEROBJECT_H_
-#define _BUFFEROBJECT_H_
+#ifndef BUFFER_OBJECT_H
+#define BUFFER_OBJECT_H
 
-#include "Common.h"
 #include <GL/glew.h>
+#include "Exception.h"
+#include "StdTypes.h"
 
 
-/**
- * A wrapper for OpenGL buffer objects (vertex arrays, texture buffers etc) to prevent us from making idiotic errors
- */
+/// A wrapper for OpenGL buffer objects (vertex arrays, texture buffers etc) to prevent us from making idiotic errors
 class BufferObject
 {
 	protected:
@@ -16,56 +15,47 @@ class BufferObject
 		GLenum usage; ///< GL_STREAM_DRAW or GL_STATIC_DRAW or GL_DYNAMIC_DRAW
 
 	public:
-		BufferObject();
+		BufferObject(): glId(0) {}
 		virtual ~BufferObject();
 
-		/**
-		 * Accessor. Throws an assertion error in BO is not created
-		 * @return The OpenGL ID of the buffer
-		 */
+		/// Safe accessor. Throws exception if BO is not created
+		/// @return The OpenGL ID of the buffer
+		/// @exception Exception
 		uint getGlId() const;
 
-		/**
-		 * Accessor. Throws an assertion error in BO is not created
-		 * @return
-		 */
+		/// Safe accessor. Throws exception if BO is not created
+		/// @return OpenGL target
+		/// @exception Exception
 		GLenum getBufferTarget() const;
 
-		/**
-		 * Accessor. Throws an assertion error in BO is not created
-		 * @return GL_STREAM_DRAW or GL_STATIC_DRAW or GL_DYNAMIC_DRAW
-		 */
+		/// Safe accessor. Throws exception if BO is not created
+		/// @return GL_STREAM_DRAW or GL_STATIC_DRAW or GL_DYNAMIC_DRAW
+		/// @exception Exception
 		GLenum getBufferUsage() const;
 
-		/**
-		 * @brief Checks if BO is created
-		 * @return True if BO is already created
-		 */
-		bool isCreated() const;
-
-		/**
-		 * Creates a new BO with the given params and checks if everything went OK
-		 * @param target_ Depends on the BO
-		 * @param sizeInBytes The size of the buffer that we will allocate in bytes
-		 * @param dataPtr Points to the data buffer to copy to the VGA memory. Put NULL if you want just to allocate memory
-		 * @param usage_ It should be: GL_STREAM_DRAW or GL_STATIC_DRAW or GL_DYNAMIC_DRAW only!!!!!!!!!
-		 * @return True on success
-		 */
-		bool create(GLenum target_, uint sizeInBytes, const void* dataPtr, GLenum usage_);
-
-		/**
-		 * Throws an assertion error in BO is not created
-		 */
+		/// Checks if BO is created
+		/// @return True if BO is already created
+		bool isCreated() const throw() {return glId != 0;}
+
+		/// Creates a new BO with the given parameters and checks if everything went OK. Throws exception if fails
+		/// @param target Depends on the BO
+		/// @param sizeInBytes The size of the buffer that we will allocate in bytes
+		/// @param dataPtr Points to the data buffer to copy to the VGA memory. Put NULL if you want just to allocate memory
+		/// @param usage It should be: GL_STREAM_DRAW or GL_STATIC_DRAW or GL_DYNAMIC_DRAW only!!!!!!!!!
+		/// @exception Exception
+		void create(GLenum target, uint sizeInBytes, const void* dataPtr, GLenum usage);
+
+		/// Bind BO. Throws exception if BO is not created
+		/// @exception Exception
 		void bind() const;
 
-		/**
-		 * Throws an assertion error in BO is not created
-		 */
+		/// Unbind BO. Throws exception if BO is not created
+		/// @exception Exception
 		void unbind() const;
 
-		/**
-		 * Self explanatory. Throws an assertion error in BO is not created
-		 */
+	private:
+		/// Delete the BO
+		/// @exception Exception
 		void deleteBuff();
 };
 
@@ -74,91 +64,56 @@ class BufferObject
 // Inlines                                                                                                             =
 //======================================================================================================================
 
-inline BufferObject::BufferObject():
-	glId(0)
-{}
-
-
 inline BufferObject::~BufferObject()
 {
-	if(glId!=0)
+	if(isCreated())
+	{
 		deleteBuff();
+	}
 }
 
+
 inline uint BufferObject::getGlId() const
 {
-	DEBUG_ERR(!isCreated());
+	RASSERT_THROW_EXCEPTION(!isCreated());
 	return glId;
 }
 
 
 inline GLenum BufferObject::getBufferTarget() const
 {
-	DEBUG_ERR(!isCreated());
+	RASSERT_THROW_EXCEPTION(!isCreated());
 	return target;
 }
 
 
 inline GLenum BufferObject::getBufferUsage() const
 {
-	DEBUG_ERR(!isCreated());
+	RASSERT_THROW_EXCEPTION(!isCreated());
 	return usage;
 }
 
 
-inline bool BufferObject::isCreated() const
-{
-	return glId != 0;
-}
-
-
-inline bool BufferObject::create(GLenum target_, uint sizeInBytes, const void* dataPtr, GLenum usage_)
-{
-	DEBUG_ERR(isCreated()); // BO already initialized
-	DEBUG_ERR(usage_!=GL_STREAM_DRAW && usage_!=GL_STATIC_DRAW && usage_!=GL_DYNAMIC_DRAW); // unacceptable usage_
-	DEBUG_ERR(sizeInBytes < 1); // unacceptable sizeInBytes
-
-	usage = usage_;
-	target = target_;
-
-	glGenBuffers(1, &glId);
-	bind();
-	glBufferData(target, sizeInBytes, dataPtr, usage);
-
-	// make a check
-	int bufferSize = 0;
-	glGetBufferParameteriv(target, GL_BUFFER_SIZE, &bufferSize);
-	if(sizeInBytes != (uint)bufferSize)
-	{
-		deleteBuff();
-		ERROR("Data size mismatch");
-		return false;
-	}
-
-	unbind();
-	return true;
-}
-
-
 inline void BufferObject::bind() const
 {
-	DEBUG_ERR(!isCreated());
+	RASSERT_THROW_EXCEPTION(!isCreated());
 	glBindBuffer(target, glId);
 }
 
 
 inline void BufferObject::unbind() const
 {
-	DEBUG_ERR(!isCreated());
+	RASSERT_THROW_EXCEPTION(!isCreated());
 	glBindBuffer(target, 0);
 }
 
 
 inline void BufferObject::deleteBuff()
 {
-	DEBUG_ERR(!isCreated());
+	RASSERT_THROW_EXCEPTION(!isCreated());
 	glDeleteBuffers(1, &glId);
 	glId = 0;
 }
 
+
 #endif

+ 5 - 5
src/Renderer/Renderer.cpp

@@ -75,13 +75,13 @@ void Renderer::render(Camera& cam_)
 //======================================================================================================================
 // drawQuad                                                                                                            =
 //======================================================================================================================
-void Renderer::drawQuad(int vertCoordsUniLoc)
+void Renderer::drawQuad(int vertCoordsAttribLoc)
 {
-	DEBUG_ERR(vertCoordsUniLoc == -1);
-	glEnableVertexAttribArray(vertCoordsUniLoc);
-	glVertexAttribPointer(vertCoordsUniLoc, 2, GL_FLOAT, false, 0, quadVertCoords);
+	DEBUG_ERR(vertCoordsAttribLoc == -1);
+	glEnableVertexAttribArray(vertCoordsAttribLoc);
+	glVertexAttribPointer(vertCoordsAttribLoc, 2, GL_FLOAT, false, 0, quadVertCoords);
 	glDrawArrays(GL_QUADS, 0, 4);
-	glDisableVertexAttribArray(vertCoordsUniLoc);
+	glDisableVertexAttribArray(vertCoordsAttribLoc);
 }
 
 

+ 40 - 63
src/Renderer/Renderer.h

@@ -1,5 +1,5 @@
-#ifndef _RENDERER_H_
-#define _RENDERER_H_
+#ifndef RENDERER_H
+#define RENDERER_H
 
 #include "Common.h"
 #include "Math.h"
@@ -21,11 +21,8 @@ class RendererInitializer;
 class SceneNode;
 
 
-/**
- * Offscreen renderer
- *
- * It is a class and not a namespace because we may need external renderers for security cameras for example
- */
+/// Offscreen renderer
+/// It is a class and not a namespace because we may need external renderers for security cameras for example
 class Renderer: public Object
 {
 	//====================================================================================================================
@@ -39,15 +36,13 @@ class Renderer: public Object
 	// Public                                                                                                            =
 	//====================================================================================================================
 	public:
-		/**
-		 * @name Rendering stages
-		 */
-		/**@{*/
+		/// @name Rendering stages
+		/// @{
 		Ms ms; ///< Material rendering stage
 		Is is; ///< Illumination rendering stage
 		Pps pps; ///< Postprocessing rendering stage
 		Bs bs; ///< Blending stage
-		/**@}*/
+		/// @}
 
 		static float quadVertCoords [][2];
 
@@ -55,74 +50,56 @@ class Renderer: public Object
 
 		~Renderer() throw() {}
 
-		/**
-		 * @name Setters & getters
-		 */
-		/**@{*/
+		/// @name Setters & getters
+		/// @{
 		const Camera& getCamera() const {return *cam;}
-		/**@}*/
+		/// @}
 
-		/**
-		 * Init the renderer given an initialization class
-		 * @param initializer The initializer class
-		 */
+		/// Init the renderer given an initialization class
+		/// @param initializer The initializer class
 		void init(const RendererInitializer& initializer);
 
-		/**
-		 * This function does all the rendering stages and produces a final FAI
-		 * @param cam The camera from where the rendering will be done
-		 */
+		/// This function does all the rendering stages and produces a final FAI
+		/// @param cam The camera from where the rendering will be done
 		void render(Camera& cam);
 
-		/**
-		 * @name Setters & getters
-		 */
-		/**@{*/
+		/// @name Setters & getters
+		/// @{
 		uint getFramesNum() const {return framesNum;}
-		/**@}*/
-
-		/**
-		 * My version of gluUnproject
-		 * @param windowCoords Window screen coords
-		 * @param modelViewMat The modelview matrix
-		 * @param projectionMat The projection matrix
-		 * @param view The view vector
-		 * @return The unprojected coords
-		 */
+		/// @}
+
+		/// My version of gluUnproject
+		/// @param windowCoords Window screen coords
+		/// @param modelViewMat The modelview matrix
+		/// @param projectionMat The projection matrix
+		/// @param view The view vector
+		/// @return The unprojected coords
 		static Vec3 unproject(const Vec3& windowCoords, const Mat4& modelViewMat, const Mat4& projectionMat,
 		                      const int view[4]);
 
-		/**
-		 * It returns an orthographic projection matrix
-		 * @param left left vertical clipping plane
-		 * @param right right vertical clipping plane
-		 * @param bottom bottom horizontal clipping plane
-		 * @param top top horizontal clipping plane
-		 * @param near nearer distance of depth clipping plane
-		 * @param far farther distance of depth clipping plane
-		 * @return A 4x4 projection matrix
-		 */
+		/// It returns an orthographic projection matrix
+		/// @param left left vertical clipping plane
+		/// @param right right vertical clipping plane
+		/// @param bottom bottom horizontal clipping plane
+		/// @param top top horizontal clipping plane
+		/// @param near nearer distance of depth clipping plane
+		/// @param far farther distance of depth clipping plane
+		/// @return A 4x4 projection matrix
 		static Mat4 ortho(float left, float right, float bottom, float top, float near, float far);
 
-		/**
-		 * OpenGL wrapper
-		 */
+		/// OpenGL wrapper
 		static void setViewport(uint x, uint y, uint w, uint h) {glViewport(x, y, w, h);}
 
-		/**
-		 * @todo write cmnts
-		 * @param mtl
-		 * @param sceneNode
-		 * @param cam
-		 */
+		/// @todo write cmnts
+		/// @param mtl
+		/// @param sceneNode
+		/// @param cam
 		void setupMaterial(const class Material& mtl, const SceneNode& sceneNode, const Camera& cam);
 
 
-		/**
-		 * @todo write cmnts
-		 * @param vertCoordsUniLoc
-		 */
-		static void drawQuad(int vertCoordsUniLoc);
+		/// Draws a quad
+		/// @param vertCoordsAttribLoc The attribute location of the vertex positions
+		static void drawQuad(int vertCoordsAttribLoc);
 
 
 	//====================================================================================================================

+ 2 - 2
src/Util/Exception.cpp

@@ -9,7 +9,7 @@
 void Exception::init(const char* err_, const char* file, int line, const char* func)
 {
 	char tmpStr[1024];
-	//sprintf(tmpStr, "%s:%d %s: exception: %s", file, line, func, err_);
-	sprintf(tmpStr, "%s", err_);
+	sprintf(tmpStr, "%s:%d %s: exception: %s", file, line, func, err_);
+	//sprintf(tmpStr, "%s", err_);
 	err = tmpStr;
 }

Beberapa file tidak ditampilkan karena terlalu banyak file yang berubah dalam diff ini