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

Removed the FFP matrix manipulation from MeshNode::render

Panagiotis Christopoulos Charitos 15 лет назад
Родитель
Сommit
c98e514329
6 измененных файлов с 108 добавлено и 87 удалено
  1. 27 3
      README
  2. 50 50
      build/README
  3. 8 8
      src/Renderer/BufferObjects/BufferObject.h
  4. 17 17
      src/Resources/Texture.cpp
  5. 6 5
      src/Resources/Texture.h
  6. 0 4
      src/Scene/MeshNode.cpp

+ 27 - 3
README

@@ -1,4 +1,28 @@
-For build info see build/README
+AnKi 3D engine
+Copyright (C) 2009, 2010 Christopoulos-Charitos Panagiotis
+
+www.ancient-ritual.com
[email protected]
+
+
+1) Building
+
+  For build info see build/README
+
+
+2) Assets
+  
+  Currently there are no assets (models, textures, materials etc) so even if
+  you build it, the application will fail to run
+  
+  
+3) Submitting patches
+
+  If you want to update/patch the file README (this file), for example, do:
+
+  make changes to README
+	
+  $ svn diff README > /tmp/foo
+
+  E-mail the "foo" file with subject "[PATCH] README updates"
 
-Currently there are no assets (models, textures, materials etc) so even if you
-compile it, the application will fail to run

+ 50 - 50
build/README

@@ -6,74 +6,74 @@ build system that generates GNU makefiles.
 
 1) Required libraries
 
-	AnKi requires a few up to date versions of some libraries. The libraries are:
-	- Bullet Physics
-	- SDL ver 1.3
-	- GLEW
+  AnKi requires a few up to date versions of some libraries. The libraries are:
+  - Bullet Physics
+  - SDL ver 1.3
+  - GLEW
 
-	So before generating makefiles or building AnKi you have to download from
-	their repositories and build the above libraries. Instructions follow. You can
-	alternately use the script download-and-build-externals.sh
-	
+  So before generating makefiles or building AnKi you have to download from
+  their repositories and build the above libraries. Instructions follow. You can
+  alternately use the script download-and-build-externals.sh
+  
 
 1.1) Bullet Physics Library
 
-	From now on the AnKi requires the Bullet physics library. You need CMake and
-	SVN installed.
+  From now on the AnKi requires the Bullet physics library. You need CMake and
+  SVN installed.
 
-	1) Go to the root AnKi path (where src, shaders and blenderscripts are)
-	2) cd ..
-	3) svn checkout http://bullet.googlecode.com/svn/trunk/ bullet_svn
-	4) cd bullet_svn
-	5) cmake -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=Release
-	6) make
+  1) Go to the root AnKi path (where src, shaders and blenderscripts are)
+  2) cd ..
+  3) svn checkout http://bullet.googlecode.com/svn/trunk/ bullet_svn
+  4) cd bullet_svn
+  5) cmake -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=Release
+  6) make
 
 
 1.2) SDL ver 1.3
 
-	We need SDL ver 1.3 for creating OpenGL 3.x context. You need to have the
-	Mercurial and autoconf installed.
+  We need SDL ver 1.3 for creating OpenGL 3.x context. You need to have the
+  Mercurial and autoconf installed.
 
-	1) Go to the root AnKi path (where src, shaders and blenderscripts are)
-	2) cd ..
-	3) hg clone http://hg.libsdl.org/SDL SDL-hg
-	4) cd SDL-hg
-	5) ./autogen.sh
-	6) ./configure
-	7) make
-	
+  1) Go to the root AnKi path (where src, shaders and blenderscripts are)
+  2) cd ..
+  3) hg clone http://hg.libsdl.org/SDL SDL-hg
+  4) cd SDL-hg
+  5) ./autogen.sh
+  6) ./configure
+  7) make
+  
 
 1.3) GLEW
 
-	The latest GLEW provides us with OpenGL 3 and 4 extensions. Needs SVN and a 
-	Unix environment (for step 5).
-	
-	1) Go to the root AnKi path (where src, shaders and blenderscripts are)
-	2) cd ..
-	3) svn co https://glew.svn.sourceforge.net/svnroot/glew/trunk/glew glew
-	4) cd glew
-	5) make extensions
-	6) make
+  The latest GLEW provides us with OpenGL 3 and 4 extensions. Needs SVN and a 
+  Unix environment (for step 5).
+  
+  1) Go to the root AnKi path (where src, shaders and blenderscripts are)
+  2) cd ..
+  3) svn co https://glew.svn.sourceforge.net/svnroot/glew/trunk/glew glew
+  4) cd glew
+  5) make extensions
+  6) make
 
 
 2) Generating makefiles and building AnKi
 
-	There are 4 build targets in this folder. There is also a build system that
-	generates GNU makefiles (it requires Python 3 installed). If you want to 
-	generate the makefile for the debug target (for example) do the following:
+  There are 4 build targets in this folder. There is also a build system that
+  generates GNU makefiles (it requires Python 3 installed). If you want to 
+  generate the makefile for the debug target (for example) do the following:
 
-	1) cd <path to anki>/build/debug
-	2) ../genmakefile.py
-	
-	Now there is an updated "Makefile". To build just type:
-	
-	3) make
+  1) cd <path to anki>/build/debug
+  2) ../genmakefile.py
+  
+  Now there is an updated "Makefile". To build just type:
+  
+  3) make
 
-	And the build process will begin. 
+  And the build process will begin. 
 
-	The gen.cfg.py files contain the build options of every target. Their format
-	is pretty straightforward and minimal.
+  The gen.cfg.py files contain the build options of every target. Their format
+  is pretty straightforward and minimal.
 
-	WARNING: Sometimes I forget to update all the targets. The debug is always
-	updated though.
-	
+  WARNING: Sometimes I forget to update all the targets. The debug is always
+  updated though.
+  

+ 8 - 8
src/Renderer/BufferObjects/BufferObject.h

@@ -6,7 +6,7 @@
 
 
 /**
- * @brief 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
 {
@@ -20,7 +20,7 @@ class BufferObject
 		virtual ~BufferObject() { if(glId!=0) deleteBuff(); }
 
 		/**
-		 * @brief Accessor. Throws an assertion error in BO is not created
+		 * Accessor. Throws an assertion error in BO is not created
 		 * @return The OpenGL ID of the buffer
 		 */
 		uint getGlId() const
@@ -30,7 +30,7 @@ class BufferObject
 		}
 
 		/**
-		 * @brief Accessor. Throws an assertion error in BO is not created
+		 * Accessor. Throws an assertion error in BO is not created
 		 * @return
 		 */
 		GLenum getBufferTarget() const
@@ -40,7 +40,7 @@ class BufferObject
 		}
 
 		/**
-		 * @brief Accessor. Throws an assertion error in BO is not created
+		 * Accessor. Throws an assertion error in BO is not created
 		 * @return GL_STREAM_DRAW or GL_STATIC_DRAW or GL_DYNAMIC_DRAW
 		 */
 		GLenum getBufferUsage() const
@@ -59,7 +59,7 @@ class BufferObject
 		}
 
 		/**
-		 * @brief Creates a new BO with the given params and checks if everything went OK
+		 * 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
@@ -94,7 +94,7 @@ class BufferObject
 		}
 
 		/**
-		 * @brief Throws an assertion error in BO is not created
+		 * Throws an assertion error in BO is not created
 		 */
 		void bind() const
 		{
@@ -103,7 +103,7 @@ class BufferObject
 		}
 
 		/**
-		 * @brief Throws an assertion error in BO is not created
+		 * Throws an assertion error in BO is not created
 		 */
 		void unbind() const
 		{
@@ -112,7 +112,7 @@ class BufferObject
 		}
 
 		/**
-		 * @brief Self explanatory. Throws an assertion error in BO is not created
+		 * Self explanatory. Throws an assertion error in BO is not created
 		 */
 		void deleteBuff()
 		{

+ 17 - 17
src/Resources/Texture.cpp

@@ -16,8 +16,8 @@ int Texture::anisotropyLevel = 8;
 // Constructor                                                                                                         =
 //======================================================================================================================
 Texture::Texture():
-	glId(numeric_limits<uint>::max()),
-	type(GL_TEXTURE_2D)
+	glId( numeric_limits<uint>::max() ),
+	target( GL_TEXTURE_2D )
 {
 }
 
@@ -26,7 +26,7 @@ Texture::Texture():
 //======================================================================================================================
 bool Texture::load( const char* filename )
 {
-	type = GL_TEXTURE_2D;
+	target = GL_TEXTURE_2D;
 	if( glId != numeric_limits<uint>::max() )
 	{
 		ERROR( "Texture already loaded" );
@@ -42,20 +42,20 @@ bool Texture::load( const char* filename )
 	bind(0);
 	if( mipmappingEnabled )
 	{
-		glTexParameteri( type, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR );
+		texParameter( GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR );
 	}
 	else
 	{
-		glTexParameteri( type, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
+		texParameter( GL_TEXTURE_MIN_FILTER, GL_LINEAR );
 	}
 
-	glTexParameteri( type, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
+	texParameter( GL_TEXTURE_MAG_FILTER, GL_LINEAR );
 
-	glTexParameterf( type, GL_TEXTURE_MAX_ANISOTROPY_EXT, anisotropyLevel );
+	texParameter( GL_TEXTURE_MAX_ANISOTROPY_EXT, float(anisotropyLevel) );
 
 	// leave to GL_REPEAT. There is not real performance impact
-	glTexParameteri( type, GL_TEXTURE_WRAP_S, GL_REPEAT );
-	glTexParameteri( type, GL_TEXTURE_WRAP_T, GL_REPEAT );
+	texParameter( GL_TEXTURE_WRAP_S, GL_REPEAT );
+	texParameter( GL_TEXTURE_WRAP_T, GL_REPEAT );
 
 	int format = (img.bpp==32) ? GL_RGBA : GL_RGB;
 
@@ -70,10 +70,10 @@ bool Texture::load( const char* filename )
 		intFormat = (img.bpp==32) ? GL_RGBA : GL_RGB;
 	}
 
-	glTexImage2D( type, 0, intFormat, img.width, img.height, 0, format, GL_UNSIGNED_BYTE, img.data );
+	glTexImage2D( target, 0, intFormat, img.width, img.height, 0, format, GL_UNSIGNED_BYTE, img.data );
 	if( mipmappingEnabled )
 	{
-		glGenerateMipmap(type);
+		glGenerateMipmap(target);
 	}
 
 	img.unload();
@@ -89,7 +89,7 @@ bool Texture::createEmpty2D( float width_, float height_, int internalFormat, in
 {
 	DEBUG_ERR( glGetError() != GL_NO_ERROR ); // dont enter the func with prev error
 
-	type = GL_TEXTURE_2D;
+	target = GL_TEXTURE_2D;
 	DEBUG_ERR( internalFormat>0 && internalFormat<=4 ); // deprecated internal format
 	DEBUG_ERR( glId != numeric_limits<uint>::max() ) // Texture already loaded
 
@@ -98,19 +98,19 @@ bool Texture::createEmpty2D( float width_, float height_, int internalFormat, in
 	bind();
 
 	if( mimapping )
-		glTexParameteri( type, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR );
+		texParameter( GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR );
 	else
-		glTexParameteri( type, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
+		texParameter( GL_TEXTURE_MIN_FILTER, GL_LINEAR );
 
 	texParameter( GL_TEXTURE_MAG_FILTER, GL_LINEAR );
 	texParameter( GL_TEXTURE_WRAP_S, GL_REPEAT );
 	texParameter( GL_TEXTURE_WRAP_T, GL_REPEAT );
 
 	// allocate to vram
-	glTexImage2D( type, 0, internalFormat, width_, height_, 0, format_, type_, NULL );
+	glTexImage2D( target, 0, internalFormat, width_, height_, 0, format_, type_, NULL );
 
 	if( mimapping )
-		glGenerateMipmap( type );
+		glGenerateMipmap( target );
 
 	GLenum errid = glGetError();
 	if( errid != GL_NO_ERROR )
@@ -158,5 +158,5 @@ void Texture::bind( uint unit ) const
 		WARNING("Max tex units passed");
 
 	glActiveTexture( GL_TEXTURE0+unit );
-	glBindTexture( type, glId );
+	glBindTexture( target, glId );
 }

+ 6 - 5
src/Resources/Texture.h

@@ -20,7 +20,7 @@ class Texture: public Resource
 
 	protected:
 		uint   glId; ///< Identification for OGL
-		GLenum type; ///< GL_TEXTURE_2D, GL_TEXTURE_3D... etc
+		GLenum target; ///< GL_TEXTURE_2D, GL_TEXTURE_3D... etc
 		static int  textureUnitsNum; ///< This needs to be filled after the main renderer initialization
 		static bool mipmappingEnabled;
 		static bool compressionEnabled;
@@ -30,9 +30,9 @@ class Texture: public Resource
 		 Texture();
 		~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; }
+		uint getGlId() const { DEBUG_ERR(glId==numeric_limits<uint>::max()); return glId; }
+		int  getWidth() const { bind(); int i; glGetTexLevelParameteriv( target, 0, GL_TEXTURE_WIDTH, &i ); return i; }
+		int  getHeight() const { bind(); int i; glGetTexLevelParameteriv( target, 0, GL_TEXTURE_HEIGHT, &i ); return i; }
 
 		bool load( const char* filename );
 		void unload();
@@ -41,7 +41,8 @@ class Texture: public Resource
 
 		void bind( uint unit=0 ) const;
 
-		inline void texParameter( GLenum paramName, GLint value ) const { bind(); glTexParameteri( GL_TEXTURE_2D, paramName, value ); }
+		inline void texParameter( GLenum paramName, GLint value ) const { bind(); glTexParameteri( target, paramName, value ); }
+		inline void texParameter( GLenum paramName, GLfloat value ) const { bind(); glTexParameterf( target, paramName, value ); }
 };
 
 

+ 0 - 4
src/Scene/MeshNode.cpp

@@ -47,9 +47,6 @@ void MeshNode::render( Material* mtl ) const
 	GLint locs[ 64 ];
 	int locsNum = 0;
 
-	glPushMatrix();
-	app->getMainRenderer()->multMatrix( Mat4(getWorldTransform()) );
-
 	// if we have skeleton controller
 	if( meshSkelCtrl )
 	{
@@ -128,5 +125,4 @@ void MeshNode::render( Material* mtl ) const
 	}
 
 	Vbo::unbindAllTargets();
-	glPopMatrix();
 }