X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fnetradiant.git;a=blobdiff_plain;f=libs%2Fshaderlib.h;h=1d9f5e0a7983216b7660f698ae2e28980b829701;hp=56e0592fcbaa57b59108d9c38e29def0ba4f2f4d;hb=f6b4543bd54926411cb71a776bc5b37eea846c4f;hpb=12b372f89ce109a4db9d510884fbe7d05af79870 diff --git a/libs/shaderlib.h b/libs/shaderlib.h index 56e0592f..1d9f5e0a 100644 --- a/libs/shaderlib.h +++ b/libs/shaderlib.h @@ -1,94 +1,103 @@ /* -Copyright (C) 2001-2006, William Joseph. -All Rights Reserved. + Copyright (C) 2001-2006, William Joseph. + All Rights Reserved. -This file is part of GtkRadiant. + This file is part of GtkRadiant. -GtkRadiant is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. + GtkRadiant is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. -GtkRadiant is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. + GtkRadiant is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with GtkRadiant; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -*/ + You should have received a copy of the GNU General Public License + along with GtkRadiant; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ -#if !defined (INCLUDED_SHADERLIB_H) +#if !defined ( INCLUDED_SHADERLIB_H ) #define INCLUDED_SHADERLIB_H #include "string/string.h" #include "character.h" #include "ishaders.h" -inline bool shader_equal(const char* shader, const char* other) -{ - return string_equal_nocase(shader, other); +inline bool shader_equal( const char* shader, const char* other ){ + return string_equal_nocase( shader, other ); } -inline bool shader_equal_n(const char* shader, const char* other, std::size_t n) -{ - return string_equal_nocase_n(shader, other, n); +inline bool shader_equal_n( const char* shader, const char* other, std::size_t n ){ + return string_equal_nocase_n( shader, other, n ); } -inline bool shader_less(const char* shader, const char* other) -{ - return string_less_nocase(shader, other); +inline bool shader_less( const char* shader, const char* other ){ + return string_less_nocase( shader, other ); } -inline bool shader_equal_prefix(const char* string, const char* prefix) -{ - return shader_equal_n(string, prefix, string_length(prefix)); +inline bool shader_equal_prefix( const char* string, const char* prefix ){ + return shader_equal_n( string, prefix, string_length( prefix ) ); } class shader_less_t { public: - bool operator()(const CopiedString& shader, const CopiedString& other) const - { - return shader_less(shader.c_str(), other.c_str()); - } +bool operator()( const CopiedString& shader, const CopiedString& other ) const { + return shader_less( shader.c_str(), other.c_str() ); +} }; -inline bool shader_valid(const char* shader) -{ - return string_is_ascii(shader) - && strchr(shader, ' ') == 0 - && strchr(shader, '\n') == 0 - && strchr(shader, '\r') == 0 - && strchr(shader, '\t') == 0 - && strchr(shader, '\v') == 0 - && strchr(shader, '\\') == 0; +static inline bool shader_is_diffuse( const char *shader ){ + return + /* Quetoo */ + !string_equal_suffix( shader, "_h" ) + && !string_equal_suffix( shader, "_local" ) + && !string_equal_suffix( shader, "_nm" ) + && !string_equal_suffix( shader, "_s" ) + /* DarkPlaces */ + && !string_equal_suffix( shader, "_bump" ) + && !string_equal_suffix( shader, "_glow" ) + && !string_equal_suffix( shader, "_gloss" ) + && !string_equal_suffix( shader, "_luma" ) + && !string_equal_suffix( shader, "_norm" ) + && !string_equal_suffix( shader, "_pants" ) + && !string_equal_suffix( shader, "_shirt" ) + && !string_equal_suffix( shader, "_reflect" ) + ; } -inline const char* GlobalTexturePrefix_get() -{ - return GlobalShaderSystem().getTexturePrefix(); +inline bool shader_valid( const char* shader ){ + return string_is_ascii( shader ) + && strchr( shader, ' ' ) == 0 + && strchr( shader, '\n' ) == 0 + && strchr( shader, '\r' ) == 0 + && strchr( shader, '\t' ) == 0 + && strchr( shader, '\v' ) == 0 + && strchr( shader, '\\' ) == 0 + && shader_is_diffuse( shader ); } -inline bool shader_is_texture(const char* name) -{ - return shader_equal_prefix(name, GlobalTexturePrefix_get()); +inline const char* GlobalTexturePrefix_get(){ + return GlobalShaderSystem().getTexturePrefix(); } -inline const char* shader_get_textureName(const char* name) -{ - return name + string_length(GlobalTexturePrefix_get()); +inline bool shader_is_texture( const char* name ){ + return shader_equal_prefix( name, GlobalTexturePrefix_get() ); } -inline bool texdef_name_valid(const char* name) -{ - return shader_valid(name) && shader_is_texture(name); +inline const char* shader_get_textureName( const char* name ){ + return name + string_length( GlobalTexturePrefix_get() ); } -inline const char* texdef_name_default() -{ - return GlobalTexturePrefix_get(); +inline bool texdef_name_valid( const char* name ){ + return shader_valid( name ) && shader_is_texture( name ); +} + +inline const char* texdef_name_default(){ + return GlobalTexturePrefix_get(); }