Forráskód Böngészése

It compiles but it fails to run

- Working on the new renderer
- Moving from SDL 1.2 to 1.3
Panagiotis Christopoulos Charitos 15 éve
szülő
commit
ae28ff3f30

A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 416 - 326
build/debug/Makefile


+ 4 - 3
build/debug/gen.cfg.py

@@ -1,12 +1,13 @@
 sourcePaths = [ "../../src/Math/", "../../src/Util/Tokenizer/", "../../src/Misc/", "../../src/", "../../src/Renderer/", "../../src/Scene/", "../../src/Ui/", "../../src/Resources/", "../../src/Util/", "../../src/Scene/Controllers/", "../../src/Physics/", "../../src/Renderer/BufferObjects/", "../../src/Renderer2/" ]
 
 includePaths = list(sourcePaths)
-includePaths.extend( [ "../../../bullet_svn/src/", "../../../SDL-hg/include" ] ) # the extra libs paths
+#includePaths.extend( [ "../../../bullet_svn/src/", "/usr/include/SDL" ] )
+includePaths.extend( [ "../../../bullet_svn/src/", "../../../SDL-hg/include", "../../glew/include" ] )
 
 precompiledHeaders = []
 executableName = "AnKi.bin"
 compiler = "g++"
 commonFlags = ""
-compilerFlags = "-c -pedantic-errors -pedantic -ansi -Wall -Wextra -W -pipe -O0 -g3 -pg -fsingle-precision-constant -D_DEBUG_ -D_TERMINAL_COLORING__ -D_PLATFORM_LINUX_ -DPLATFORM=LINUX -DREVISION=\\\"`svnversion -c ../..`\\\" "
+compilerFlags = "-c -pedantic-errors -pedantic -ansi -Wall -Wextra -W -pipe -O0 -g3 -pg -fsingle-precision-constant -D_DEBUG_ -D_TERMINAL_COLORING__ -DPLATFORM=LINUX -DREVISION=\\\"`svnversion -c ../..`\\\" "
 precompiledHeadersFlags = "-x c++-header"
-linkerFlags = "-rdynamic -L../../../SDL-hg/build/.libs -L../../../bullet_svn/src/BulletSoftBody -L../../../bullet_svn/src/BulletDynamics -L../../../bullet_svn/src/BulletCollision -L../../../bullet_svn/src/LinearMath -Wl,-Bstatic -lBulletSoftBody -lBulletDynamics -lBulletCollision -lLinearMath -lGLEW -lSDL_image -lGLU -lSDL -Wl,-Bdynamic -lGL -ljpeg -lpng -ltiff" # a few libs are now static
+linkerFlags = "-rdynamic -L../../../SDL-hg/build/.libs -L../../../glew/lib -L../../../bullet_svn/src/BulletSoftBody -L../../../bullet_svn/src/BulletDynamics -L../../../bullet_svn/src/BulletCollision -L../../../bullet_svn/src/LinearMath -Wl,-Bstatic -lBulletSoftBody -lBulletDynamics -lBulletCollision -lLinearMath -lGLEW -lSDL_image -lGLU -lSDL -Wl,-Bdynamic -lGL -ljpeg -lpng -ltiff" # a few libs are now static

+ 1 - 1
src/Main.cpp

@@ -382,7 +382,7 @@ int main( int argc, char* argv[] )
 		R::takeScreenshot(str);*/
 
 		// std stuff follow
-		SDL_GL_SwapBuffers();
+		app->swapBuffers();
 		R::printLastError();
 		if( 1 )
 		{

+ 2 - 2
src/Math/MathFuncs.inl.h

@@ -20,14 +20,14 @@ inline float invSqrt( float f )
 {
 #if defined( _DEBUG_ )
 	return 1.0/sqrtf(f);
-#elif defined( _PLATFORM_WIN_ )
+#elif PLATFORM==WIN
 	float fhalf = 0.5*f;
 	int i = *(int*)&f;
 	i = 0x5F3759DF - (i>>1);
 	f = *(float*)&i;
 	f *= 1.5 - fhalf*f*f;
 	return f;
-#elif defined( _PLATFORM_LINUX_ )
+#elif PLATFORM==LINUX
 	float fhalf = 0.5*f;
 	asm
 	(

+ 1 - 1
src/Misc/memory.cpp

@@ -1,5 +1,5 @@
 #include "memory.h"
-#include <SDL/SDL.h>
+#include <SDL.h>
 
 #ifdef _USE_MEM_MANAGER_
 

+ 8 - 6
src/Renderer/Renderer.cpp

@@ -54,10 +54,10 @@ void DrawQuad( int vertCoordsUniLoc )
 	glVertexPointer( 2, GL_FLOAT, 0, quadVertCoords );
 	glDrawArrays( GL_QUADS, 0, 4 );
 	glDisableClientState( GL_VERTEX_ARRAY );*/
-	glVertexAttribPointer( vertCoords_uni_loc, 2, GL_FLOAT, false, 0, quadVertCoords );
-	glEnableVertexAttribArray( vertCoords_uni_loc );
+	glVertexAttribPointer( vertCoordsUniLoc, 2, GL_FLOAT, false, 0, quadVertCoords );
+	glEnableVertexAttribArray( vertCoordsUniLoc );
 	glDrawArrays( GL_QUADS, 0, 4 );
-	glDisableVertexAttribArray( vertCoords_uni_loc );
+	glDisableVertexAttribArray( vertCoordsUniLoc );
 }
 
 
@@ -110,13 +110,15 @@ void init()
 {
 	INFO( "Renderer initializing..." );
 
-	glewInit();
+	GLenum err = glewInit();
+	if( err != GLEW_OK )
+		FATAL( "GLEW initialization failed" );
 
 	// print GL info
 	INFO( "OpenGL info: OGL " << glGetString(GL_VERSION) << ", GLSL " << glGetString(GL_SHADING_LANGUAGE_VERSION) );
 
-	if( !glewIsSupported("GL_VERSION_2_1") )
-		WARNING( "OpenGL ver 2.1 not supported. The application may crash (and burn)" );
+	if( !glewIsSupported("GL_VERSION_3_1") )
+		WARNING( "OpenGL ver 3.1 not supported. The application may crash (and burn)" );
 
 	if( !glewIsSupported("GL_EXT_framebuffer_object") )
 		WARNING( "Framebuffer objects not supported. The application may crash (and burn)" );

+ 9 - 6
src/Renderer2/Hdr.cpp

@@ -6,6 +6,9 @@
 //=====================================================================================================================================
 void Renderer::Pps::Hdr::initFbos( Fbo& fbo, Texture& fai, int internalFormat )
 {
+	int width = renderingQuality * r.width;
+	int height = renderingQuality * r.height;
+
 	// create FBO
 	fbo.create();
 	fbo.bind();
@@ -14,7 +17,7 @@ void Renderer::Pps::Hdr::initFbos( Fbo& fbo, Texture& fai, int internalFormat )
 	fbo.setNumOfColorAttachements(1);
 
 	// create the texes
-	fai.createEmpty2D( w, h, internalFormat, GL_RGB );
+	fai.createEmpty2D( width, height, internalFormat, GL_RGB );
 	fai.texParameter( GL_TEXTURE_MAG_FILTER, GL_NEAREST );
 	//fai.texParameter( GL_TEXTURE_MAG_FILTER, GL_LINEAR );
 	fai.texParameter( GL_TEXTURE_MIN_FILTER, GL_NEAREST );
@@ -36,8 +39,8 @@ void Renderer::Pps::Hdr::initFbos( Fbo& fbo, Texture& fai, int internalFormat )
 //=====================================================================================================================================
 void Renderer::Pps::Hdr::init()
 {
-	w = R::Pps::Hdr::renderingQuality * R::w;
-	h = R::Pps::Hdr::renderingQuality * R::h;
+	int width = renderingQuality * r.width;
+	int height = renderingQuality * r.height;
 
 	initFbos( pass0Fbo, pass0Fai, GL_RGB );
 	initFbos( pass1Fbo, pass1Fai, GL_RGB );
@@ -49,11 +52,11 @@ void Renderer::Pps::Hdr::init()
 	//
 	const char* shaderFname = "shaders/PpsHdr.glsl";
 
-	if( !pass0SProg.customLoad( shaderFname, ("#define _PPS_HDR_PASS_0_\n#define IS_FAI_WIDTH " + Util::floatToStr(R::w) + "\n").c_str() ) )
+	if( !pass0SProg.customLoad( shaderFname, ("#define _PPS_HDR_PASS_0_\n#define IS_FAI_WIDTH " + Util::floatToStr(r.width) + "\n").c_str() ) )
 		FATAL( "See prev error" );
 	uniLocs.pass0SProg.fai = pass0SProg.getUniVar("fai")->getLoc();
 
-	if( !pass1SProg.customLoad( shaderFname, ("#define _PPS_HDR_PASS_1_\n#define PASS0_HEIGHT " + Util::floatToStr(h) + "\n").c_str() ) )
+	if( !pass1SProg.customLoad( shaderFname, ("#define _PPS_HDR_PASS_1_\n#define PASS0_HEIGHT " + Util::floatToStr(height) + "\n").c_str() ) )
 		FATAL( "See prev error" );
 	uniLocs.pass1SProg.fai = pass1SProg.getUniVar("fai")->getLoc();
 
@@ -86,7 +89,7 @@ void Renderer::Pps::Hdr::run()
 	// pass 1
 	pass1Fbo.bind();
 	pass1SProg.bind();
-	pass1SProg.locTexUnit( uniLocs.pass1SProg.uniLocs.fai, pass0Fai, 0 );
+	pass1SProg.locTexUnit( uniLocs.pass1SProg.fai, pass0Fai, 0 );
 	r.drawQuad( 0 );
 
 

+ 10 - 0
src/Renderer2/Renderer.cpp

@@ -0,0 +1,10 @@
+#include "Renderer.hpp"
+
+//=====================================================================================================================================
+// Vars                                                                                                                               =
+//=====================================================================================================================================
+int Renderer::screenshotJpegQuality = 90;
+bool Renderer::textureCompression = false;
+int  Renderer::maxTextureUnits = -1;
+bool Renderer::mipmapping = true;
+int  Renderer::maxAnisotropy = 8;

+ 36 - 97
src/Renderer2/Renderer.hpp

@@ -31,17 +31,17 @@ class SpotLight;
 class Renderer
 {
 	//===================================================================================================================================
-	// Rendering Stages                                                                                                                 =
+	// The rendering stages                                                                                                             =
 	//===================================================================================================================================
 	public:
-
 		/**
-		 * Rendering stage base class
+		 * Rendering stage
 		 */
 		class RenderingStage
 		{
 			protected:
 				Renderer& r;
+
 			public:
 				RenderingStage( Renderer& r_ ): r(r_) {}
 		};
@@ -50,7 +50,7 @@ class Renderer
 		/**
 		 * Material stage
 		 */
-		class Ms: public RenderingStage
+		class Ms: private RenderingStage
 		{
 			private:
 				Fbo fbo;
@@ -64,20 +64,19 @@ class Renderer
 				Texture specularFai;
 				Texture depthFai;
 
-				Ms( Renderer& r_ ): RenderingStage(r_) {}
-		}; // end Ms
-
+				Ms( Renderer& r_ ): RenderingStage( r_ ) {}
+		};
 
 		/**
 		 * Illumination stage
 		 */
-		class Is: public RenderingStage
+		class Is: private RenderingStage
 		{
 			public:
 				/**
 				 * Shadowmapping sub-stage
 				 */
-				class Sm: public RenderingStage
+				class Sm: private RenderingStage
 				{
 					private:
 						Fbo fbo; ///< Illumination stage shadowmapping FBO
@@ -89,9 +88,9 @@ class Renderer
 					public:
 						bool pcfEnabled;
 						bool bilinearEnabled;
-						int  mapRez;
+						int  resolution;
 
-						Sm( Renderer& r_ ): RenderingStage(r_) {}
+						Sm( Renderer& r_ ): RenderingStage( r_ ) {}
 				};
 
 			private:
@@ -121,26 +120,26 @@ class Renderer
 
 			public:
 				Texture fai;
+
 				Sm sm;
 
-				Is( Renderer& r_ ): RenderingStage(r_), sm(r) {}
-		}; // end Is
+				Is( Renderer& r_ ): RenderingStage( r_ ), sm(r) {}
+		};
 
 
 		/**
 		 * Post-processing stage
 		 */
-		class Pps: public RenderingStage
+		class Pps: private RenderingStage
 		{
 			public:
 				/**
-				 * High dynamic range lighting
+				 * High dynamic range lighting stage
 				 */
-				class Hdr: public RenderingStage
+				class Hdr: private RenderingStage
 				{
 					private:
 						Fbo pass0Fbo, pass1Fbo, pass2Fbo;
-						float renderingQuality;
 						ShaderProg pass0SProg, pass1SProg, pass2SProg;
 						struct
 						{
@@ -163,24 +162,23 @@ class Renderer
 						void run();
 
 					public:
+						bool enabled;
+						float renderingQuality;
 						Texture pass0Fai; ///< Vertical blur pass
-						Texture pass1Fai; ///< @ref pass0Fai with the horizontal blur
+						Texture pass1Fai; ///< pass0Fai with the horizontal blur
 						Texture fai; ///< The final FAI
-						bool enabled;
 
 						Hdr( Renderer& r_ ): RenderingStage(r_) {}
-				}; // end Hdr
+				};
 
 				/**
-				 * Screen space ambient occlusion
+				 * Screen space ambien occlusion stage
 				 */
-				class Ssao: public RenderingStage
+				class Saao: private RenderingStage
 				{
 					private:
 						Fbo pass0Fbo, pass1Fbo, pass2Fbo;
-						uint width, height;
-						uint bwidth, bheight;
-						ShaderProg ssaoSProg, blurSProg, blurSProg2;
+						uint width, height, bwidth, bheight;
 						Texture* noiseMap;
 
 						void initBlurFbos();
@@ -188,78 +186,20 @@ class Renderer
 						void run();
 
 					public:
-						bool enabled;
 						float renderingQuality;
 						float bluringQuality;
 						Texture pass0Fai, pass1Fai, fai;
+						ShaderProg ssaoSProg, blurSProg, blurSProg2;
 
-						Ssao( Renderer& r_ ): RenderingStage(r_) {}
-				}; // end Ssao
-
-				/**
-				 * Light scattering
-				 */
-				class Lscatt: public RenderingStage
-				{
-					private:
-						Fbo fbo;
-						ShaderProg sProg;
-						int msDepthFaiUniLoc;
-						int isFaiUniLoc;
-
-						void init();
-						void run();
-
-					public:
-						float renderingQuality;
-						bool enabled;
-						Texture fai;
-
-						Lscatt( Renderer& r_ ): RenderingStage(r_) {}
-				}; // end Lscatt
-
-			private:
-				Fbo fbo;
-				ShaderProg sProg;
-				struct
-				{
-					int isFai;
-					int ppsSsaoFai;
-					int msNormalFai;
-					int hdrFai;
-					int lscattFai;
-				} uniLocs;
-
-				void init();
-				void run();
-
-			public:
-				Texture fai;
-
-				Hdr hdr;
-				Ssao ssao;
-				Lscatt lscatt;
-
-				Pps( Renderer& r_ ): RenderingStage(r_), hdr(r), ssao(r), lscatt(r) {}
-		}; // end Pps
-
-
-		/**
-		 * Blending stage
-		 */
-		class Bs: public RenderingStage
-		{
-			private:
-			public:
-				Bs( Renderer& r_ ): RenderingStage(r_) {}
-		}; // end Bs
+						Saao( Renderer& r_ ): RenderingStage(r_) {}
+				};
 
+		};
 
-		// define the stages
-		Ms  ms;
-		Is  is;
+		// the data members
+		Ms ms;
+		Is is;
 		Pps pps;
-		Bs  bs;
 
 	//===================================================================================================================================
 	//                                                                                                                                  =
@@ -269,14 +209,14 @@ class Renderer
 		uint  width; ///< width of the rendering. Dont confuse with the window width
 		uint  height; ///< height of the rendering. Dont confuse with the window width
 		float renderingQuality; ///< The global rendering quality of the raster image. From 0.0(low) to 1.0(high)
-		int   screenshotJpegQuality; ///< The quality of the JPEG screenshots. From 0 to 100
+		static int screenshotJpegQuality; ///< The quality of the JPEG screenshots. From 0 to 100
 		// texture stuff
-		bool textureCompression; ///< Used in Texture::load to enable texture compression. Decreases video memory usage
-		int  maxTextureUnits; ///< Used in Texture::bind so we wont bind in a nonexistent texture unit. Readonly
-		bool mipmaping; ///< Used in Texture::load. Enables mipmapping increases video memory usage
-		int  maxAnisotropy; ///< Max texture anisotropy. Used in Texture::load
+		static bool textureCompression; ///< Used in Texture::load to enable texture compression. Decreases video memory usage
+		static int  maxTextureUnits; ///< Used in Texture::bind so we wont bind in a nonexistent texture unit. Readonly
+		static bool mipmapping; ///< Used in Texture::load. Enables mipmapping increases video memory usage
+		static int  maxAnisotropy; ///< Max texture anisotropy. Used in Texture::load
 		// other
-		int   maxColorAtachments; ///< Max color attachments a FBO can accept
+		static int   maxColorAtachments; ///< Max color attachments a FBO can accept
 		uint  framesNum;
 		float aspectRatio;
 		// matrices & viewing
@@ -286,7 +226,6 @@ class Renderer
 		Mat4 modelViewProjectionMat; ///< This changes just like @ref modelViewMat
 		Mat3 normalMat; ///< The rotation part of modelViewMat
 
-
 		void setProjectionMatrix( const Camera& cam ) {}
 		void setViewMatrix( const Camera& cam ) {}
 		void setProjectionViewMatrices( const Camera& cam ) {}

+ 157 - 0
src/Renderer2/Ssao.cpp

@@ -0,0 +1,157 @@
+#include "Renderer.hpp"
+#include "Camera.h"
+
+
+//=====================================================================================================================================
+// initBlurFbos                                                                                                                       =
+//=====================================================================================================================================
+void Renderer::Pps::Saao::initBlurFbos()
+{
+	// create FBO
+	pass1Fbo.create();
+	pass1Fbo.bind();
+
+	// inform in what buffers we draw
+	pass1Fbo.setNumOfColorAttachements(1);
+
+	// create the texes
+	pass1Fai.createEmpty2D( bwidth, bheight, GL_ALPHA8, GL_ALPHA );
+	pass1Fai.texParameter( GL_TEXTURE_MAG_FILTER, GL_NEAREST );
+	pass1Fai.texParameter( GL_TEXTURE_MIN_FILTER, GL_NEAREST );
+
+	// attach
+	glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, pass1Fai.getGlId(), 0 );
+
+	// test if success
+	if( !pass1Fbo.isGood() )
+		FATAL( "Cannot create deferred shading post-processing stage SSAO blur FBO" );
+
+	// unbind
+	pass1Fbo.unbind();
+
+
+
+	// create FBO
+	pass2Fbo.create();
+	pass2Fbo.bind();
+
+	// inform in what buffers we draw
+	pass2Fbo.setNumOfColorAttachements(1);
+
+	// create the texes
+	fai.createEmpty2D( bwidth, bheight, GL_ALPHA8, GL_ALPHA );
+	fai.texParameter( GL_TEXTURE_MAG_FILTER, GL_LINEAR );
+	fai.texParameter( GL_TEXTURE_MIN_FILTER, GL_NEAREST );
+
+	// attach
+	glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, fai.getGlId(), 0 );
+
+	// test if success
+	if( !pass2Fbo.isGood() )
+		FATAL( "Cannot create deferred shading post-processing stage SSAO blur FBO" );
+
+	// unbind
+	pass2Fbo.unbind();
+}
+
+
+//=====================================================================================================================================
+// init                                                                                                                               =
+//=====================================================================================================================================
+void Renderer::Pps::Saao::init()
+{
+	width = renderingQuality * r.width;
+	height = renderingQuality * r.height;
+	bwidth = height * bluringQuality;
+	bheight = height * bluringQuality;
+
+	// create FBO
+	pass0Fbo.create();
+	pass0Fbo.bind();
+
+	// inform in what buffers we draw
+	pass0Fbo.setNumOfColorAttachements(1);
+
+	// create the texes
+	pass0Fai.createEmpty2D( width, height, GL_ALPHA8, GL_ALPHA );
+	pass0Fai.texParameter( GL_TEXTURE_MAG_FILTER, GL_NEAREST );
+	pass0Fai.texParameter( GL_TEXTURE_MIN_FILTER, GL_NEAREST );
+
+	// attach
+	glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, pass0Fai.getGlId(), 0 );
+
+	// test if success
+	if( !pass0Fbo.isGood() )
+		FATAL( "Cannot create deferred shading post-processing stage SSAO pass FBO" );
+
+	// unbind
+	pass0Fbo.unbind();
+
+
+	// init shaders
+	ssaoSProg.customLoad( "shaders/PpsSsao.glsl" );
+
+	// load noise map and disable temporaly the texture compression and enable mipmapping
+	bool texCompr = Renderer::textureCompression;
+	bool mipmaping = Renderer::mipmapping;
+	Renderer::textureCompression = false;
+	Renderer::mipmapping = true;
+	noiseMap = Rsrc::textures.load( "gfx/noise3.tga" );
+	noiseMap->texParameter( GL_TEXTURE_WRAP_S, GL_REPEAT );
+	noiseMap->texParameter( GL_TEXTURE_WRAP_T, GL_REPEAT );
+	//noise_map->texParameter( GL_TEXTURE_MAG_FILTER, GL_NEAREST );
+	//noise_map->texParameter( GL_TEXTURE_MIN_FILTER, GL_NEAREST );
+	Renderer::textureCompression = texCompr;
+	Renderer::mipmapping = mipmaping;
+
+	// blur FBO
+	initBlurFbos();
+	blurSProg.customLoad( "shaders/PpsSsaoBlur.glsl", ("#define _PPS_SSAO_PASS_0_\n#define PASS0_FAI_WIDTH " + Util::floatToStr(width) + "\n").c_str() );
+	blurSProg2.customLoad( "shaders/PpsSsaoBlur.glsl", ("#define _PPS_SSAO_PASS_1_\n#define PASS1_FAI_HEIGHT " + Util::floatToStr(bheight) + "\n").c_str() );
+}
+
+
+//=====================================================================================================================================
+// run                                                                                                                                =
+//=====================================================================================================================================
+void Renderer::Pps::Saao::run()
+{
+	Camera& cam = *r.cam;
+	pass0Fbo.bind();
+
+	r.setViewport( 0, 0, width, height );
+
+	glDisable( GL_BLEND );
+	glDisable( GL_DEPTH_TEST );
+
+	// fill SSAO FAI
+	ssaoSProg.bind();
+	glUniform2fv( ssaoSProg.getUniVar("camerarange")->getLoc(), 1, &(Vec2(cam.getZNear(), cam.getZFar()))[0] );
+	ssaoSProg.locTexUnit( ssaoSProg.getUniVar("msDepthFai")->getLoc(), r.ms.depthFai, 0 );
+	ssaoSProg.locTexUnit( ssaoSProg.getUniVar("noiseMap")->getLoc(), *noiseMap, 1 );
+	ssaoSProg.locTexUnit( ssaoSProg.getUniVar("msNormalFai")->getLoc(), r.ms.normalFai, 2 );
+	r.drawQuad( 0 ); // Draw quad
+
+	/*glBindFramebuffer( GL_READ_FRAMEBUFFER, pass0Fbo.getGlId() );
+	glBindFramebuffer( GL_DRAW_FRAMEBUFFER, pass1Fbo.getGlId() );
+	glBlitFramebuffer( 0, 0, w, h, 0, 0, bw, bh, GL_COLOR_BUFFER_BIT, GL_NEAREST);*/
+
+	r.setViewport( 0, 0, bwidth, bheight );
+
+	// second pass. blur
+	pass1Fbo.bind();
+	blurSProg.bind();
+	blurSProg.locTexUnit( blurSProg.getUniVar("tex")->getLoc(), pass0Fai, 0 );
+	r.drawQuad( 0 ); // Draw quad
+
+	// third pass. blur
+	pass2Fbo.bind();
+	blurSProg2.bind();
+	blurSProg2.locTexUnit( blurSProg2.getUniVar("tex")->getLoc(), pass1Fai, 0 );
+	r.drawQuad( 0 ); // Draw quad
+
+
+	// end
+	Fbo::unbind();
+}
+

+ 2 - 11
src/Scene/ParticleEmitter.cpp

@@ -168,17 +168,6 @@ void ParticleEmitter::update()
 //=====================================================================================================================================
 void ParticleEmitter::render()
 {
-	float vertPositions[] = { maxStartingPos.x, maxStartingPos.y, maxStartingPos.z,   // right top front
-	                          minStartingPos.x, maxStartingPos.y, maxStartingPos.z,   // left top front
-	                          minStartingPos.x, minStartingPos.y, maxStartingPos.z,   // left bottom front
-	                          maxStartingPos.x, minStartingPos.y, maxStartingPos.z,   // right bottom front
-	                          maxStartingPos.x, maxStartingPos.y, minStartingPos.z,   // right top back
-	                          minStartingPos.x, maxStartingPos.y, minStartingPos.z,   // left top back
-	                          minStartingPos.x, minStartingPos.y, minStartingPos.z,   // left bottom back
-	                          maxStartingPos.x, minStartingPos.y, minStartingPos.z }; // right bottom back
-
-	uint vertIndices [] = { 0, 1, 1, 2, 2, 3, 3, 0, 4, 5, 5, 6, 6, 7, 7, 4, 0, 4, 1, 5, 3, 7, 2, 6 };
-
 	glPushMatrix();
 	R::multMatrix( getWorldTransform() );
 
@@ -188,7 +177,9 @@ void ParticleEmitter::render()
 	glVertexPointer( 3, GL_FLOAT, 0, vertPositions );
 	glDrawElements( GL_LINES, sizeof(vertIndices)/sizeof(uint), GL_UNSIGNED_INT, vertIndices );
 	glDisableClientState( GL_VERTEX_ARRAY );*/
+	glPolygonMode( GL_FRONT, GL_LINE );
 	R::Dbg::renderCube();
+	glPolygonMode( GL_FRONT, GL_FILL );
 
 	glPopMatrix();
 }

+ 13 - 2
src/Util/App.cpp

@@ -1,6 +1,6 @@
 #include <GL/glew.h>
 #include <sstream>
-#include <SDL/SDL.h>
+#include <SDL.h>
 #include "App.h"
 #include "Scene.h"
 
@@ -36,7 +36,8 @@ App::App( int /*argc*/, char* /*argv*/[] )
 void App::initWindow()
 {
 	INFO( "SDL window initializing..." );
-	SDL_Init( SDL_INIT_VIDEO );
+	if( SDL_Init(SDL_INIT_VIDEO) < 0 )
+		FATAL( "Failed to init SDL_VIDEO" );
 
 	// print driver name
 	char charBuff [256];
@@ -103,6 +104,16 @@ void App::togleFullScreen()
 }
 
 
+//=====================================================================================================================================
+// swapBuffers                                                                                                                        =
+//=====================================================================================================================================
+void App::swapBuffers()
+{
+	SDL_GL_SwapBuffers();
+	//SDL_GL_SwapWindow(mainwindow);
+}
+
+
 //=====================================================================================================================================
 // quitApp                                                                                                                            =
 //=====================================================================================================================================

+ 2 - 0
src/Util/App.h

@@ -24,6 +24,7 @@ class App
 		class SDL_Surface* mainSurf; ///< SDL stuff
 		class SDL_Surface* iconImage; ///< SDL stuff
 
+
 	public:
 		uint timerTick;
 
@@ -33,6 +34,7 @@ class App
 		void quitApp( int code );
 		void waitForNextFrame();
 		void togleFullScreen();
+		void swapBuffers();
 		static void printAppInfo();
 
 		/**

+ 2 - 2
src/Util/Common.h

@@ -159,10 +159,10 @@ extern string getFunctionFromPrettyFunction( const char* pretty_function );
 
 
 //=====================================================================================================================================
-// MemZero                                                                                                                            =
+// memZero                                                                                                                            =
 //=====================================================================================================================================
 /// sets memory to zero
-template <typename Type> inline void MemZero( Type& t )
+template <typename Type> inline void memZero( Type& t )
 {
 	memset( &t, 0, sizeof(Type) );
 }

+ 7 - 6
src/Util/Input.cpp

@@ -11,7 +11,7 @@ namespace I {
 data vars                                                                                                                             =
 =======================================================================================================================================
 */
-short keys [SDLK_LAST];  // shows the current key state. 0: unpressed, 1: pressed once, n is >1: kept pressed 'n' times continucely
+Vec<short> keys( 1024 );  // shows the current key state. 0: unpressed, 1: pressed once, n is >1: kept pressed 'n' times continucely
 short mouseBtns [8];    // mouse btns. Supporting 3 btns & wheel. Works the same as above
 Vec2 mousePosNdc;    // the coords are in the ndc space
 Vec2 mousePos;        // the coords are in the window space
@@ -26,9 +26,10 @@ bool hideCursor = true;
 reset                                                                                                                                 =
 =======================================================================================================================================
 */
-void Reset( void )
+void reset( void )
 {
-	memset( keys, 0, sizeof(keys) );
+	DEBUG_ERR( keys.size() < 1 );
+	memset( &keys[0], 0, keys.size()*sizeof(short) );
 	memset(mouseBtns, 0, sizeof(mouseBtns) );
 	mousePosNdc.setZero();
 	mouseVelocity.setZero();
@@ -46,7 +47,7 @@ void handleEvents()
 	else             SDL_ShowCursor( SDL_ENABLE );
 
 	// add the times a key is bying pressed
-	for( int x=0; x<SDLK_LAST; x++ )
+	for( uint x=0; x<keys.size(); x++ )
 	{
 		if( keys[x] ) ++keys[x];
 	}
@@ -86,8 +87,8 @@ void handleEvents()
 				mousePos.x = event_.button.x;
 				mousePos.y = event_.button.y;
 
-				mousePosNdc.x = (2.0f * mousePos.x) / (float)app->getWindowWidth() - 1.0f;
-				mousePosNdc.y = 1.0f - (2.0f * mousePos.y) / (float)app->getWindowHeight();
+				mousePosNdc.x = (2.0 * mousePos.x) / (float)app->getWindowWidth() - 1.0;
+				mousePosNdc.y = 1.0 - (2.0 * mousePos.y) / (float)app->getWindowHeight();
 
 				if( warpMouse )
 				{

+ 2 - 2
src/Util/Input.h

@@ -1,7 +1,7 @@
 #ifndef _INPUT_H_
 #define _INPUT_H_
 
-#include <SDL/SDL.h>
+#include <SDL.h>
 #include "Common.h"
 #include "App.h"
 #include "Math.h"
@@ -13,7 +13,7 @@ extern void reset();
 extern void handleEvents();
 
 // keys and btns
-extern short keys [];  ///< Shows the current key state. 0: unpressed, 1: pressed once, n is >1: kept pressed 'n' times continucely
+extern Vec<short> keys;  ///< Shows the current key state. 0: unpressed, 1: pressed once, n is >1: kept pressed 'n' times continucely
 extern short mouseBtns [];    ///< Mouse btns. Supporting 3 btns & wheel. Works the same as above
 
 // mouse stuff

Nem az összes módosított fájl került megjelenítésre, mert túl sok fájl változott