From: <cn...@us...> - 2009-11-13 07:38:29
|
Revision: 613 http://hgengine.svn.sourceforge.net/hgengine/?rev=613&view=rev Author: cnlohr Date: 2009-11-13 07:38:19 +0000 (Fri, 13 Nov 2009) Log Message: ----------- permit other texture modes Modified Paths: -------------- Mercury2/src/Texture.cpp Mercury2/src/Texture.h Modified: Mercury2/src/Texture.cpp =================================================================== --- Mercury2/src/Texture.cpp 2009-11-13 07:35:37 UTC (rev 612) +++ Mercury2/src/Texture.cpp 2009-11-13 07:38:19 UTC (rev 613) @@ -13,7 +13,7 @@ #define BUFFER_OFFSET(i) ((char*)NULL + (i)) Texture::Texture( const MString & key, bool bInstanced ) - :MercuryAsset( key, bInstanced ), m_raw(NULL),m_textureID(0),m_bDeleteRaw(true),m_dynamic(false), m_bClamp(true) + :MercuryAsset( key, bInstanced ), m_raw(NULL),m_textureID(0),m_bDeleteRaw(true),m_dynamic(false), m_bClamp(true), m_tFilterMode(TF_LINEAR_MIPS) { if (!m_initTextureSuccess) { @@ -65,10 +65,24 @@ GL_UNSIGNED_BYTE, m_raw->m_data); */ - GLCALL( gluBuild2DMipmaps( GL_TEXTURE_2D, byteType, m_raw->m_width, m_raw->m_height, byteType, GL_UNSIGNED_BYTE, m_raw->m_data ) ); - - GLCALL( glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST) ); - GLCALL( glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR) ); + if( m_tFilterMode == TF_NONE ) + { + GLCALL( glTexImage2D(GL_TEXTURE_2D, 0, byteType, m_raw->m_width, m_raw->m_height, 0, byteType, GL_UNSIGNED_BYTE, m_raw->m_data) ); + GLCALL( glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST) ); + GLCALL( glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST) ); + } + else if( m_tFilterMode == TF_LINEAR ) + { + GLCALL( glTexImage2D(GL_TEXTURE_2D, 0, byteType, m_raw->m_width, m_raw->m_height, 0, byteType, GL_UNSIGNED_BYTE, m_raw->m_data) ); + GLCALL( glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR) ); + GLCALL( glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR) ); + } + else + { + GLCALL( gluBuild2DMipmaps( GL_TEXTURE_2D, byteType, m_raw->m_width, m_raw->m_height, byteType, GL_UNSIGNED_BYTE, m_raw->m_data ) ); + GLCALL( glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_LINEAR) ); + GLCALL( glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR) ); + } // GLCALL( glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE ) ); @@ -104,11 +118,23 @@ void Texture::LoadFromXML(const XMLNode& node) { - if ( !node.Attribute("dynamic").empty() ) - m_dynamic = StrToBool( node.Attribute("dynamic") ); - if( !node.Attribute( "clamp" ).empty() ) - m_bClamp = StrToBool( node.Attribute("clamp" ) ); + LOAD_FROM_XML( "dynamic", m_dynamic, StrToBool ); + LOAD_FROM_XML( "clamp", m_bClamp, StrToBool ); + + MString filter = node.Attribute( "filter" ); + if( !filter.empty() ) + { + if( filter == "none" ) + { + m_tFilterMode = TF_NONE; + } + else if( filter == "linear" ) + { + m_tFilterMode = TF_LINEAR; + } + } + MString file = node.Attribute("file"); ChangeKey( file ); Modified: Mercury2/src/Texture.h =================================================================== --- Mercury2/src/Texture.h 2009-11-13 07:35:37 UTC (rev 612) +++ Mercury2/src/Texture.h 2009-11-13 07:38:19 UTC (rev 613) @@ -4,6 +4,13 @@ #include <MercuryAsset.h> #include <RawImageData.h> +enum TextureFilterMode +{ + TF_NONE, + TF_LINEAR, + TF_LINEAR_MIPS, +}; + class Texture : public MercuryAsset { public: @@ -39,6 +46,8 @@ static void ApplyActiveTextures(uint16_t stride); static void DisableUnusedTextures(); + void SetFilter( TextureFilterMode t ) { m_tFilterMode = t; } + GENRTTI( Texture ); private: void LoadImagePath(const MString& path); @@ -65,7 +74,8 @@ bool m_bDeleteRaw; bool m_dynamic; bool m_bClamp; -// MString m_filename; + TextureFilterMode m_tFilterMode; + }; #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |