/* =========================================================================== maya2q3 - export .md3 files from maya Copyright (C) 2005 HermitWorks Entertainment Corporation This program 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. This program 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 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. =========================================================================== */ #include "common.h" namespace shader { ShaderContext::ShaderContext( void ) : m_time( 0 ), m_showDetail( true ) { } Shader::Shader( const char *name ) : m_shaderStarted( false ), m_currPass( (size_t)~0 ), m_name( name ) { InitDefault(); } size_t Shader::GetStageCount( void ) const { return m_numStages; } Shader::StageInfo Shader::GetStageInfo( size_t index ) const { const ShaderStage &stage = m_stages[ index ]; StageInfo ret; ret.numImages = stage.bundle.numTextures; for( size_t i = 0; i < ret.numImages; i++ ) { StageInfo::ImageInfo &ii = ret.images[i]; ii.name = stage.bundle.texNames[i]; ii.width = stage.bundle.texWidths[i]; ii.height = stage.bundle.texHeights[i]; } switch( stage.state & StateBits::TexAddr_Bits ) { case StateBits::TexAddr_Clamp: ret.wrapClampMode = GL_CLAMP; break; case StateBits::TexAddr_ClampToEdge: ret.wrapClampMode = GL_CLAMP_TO_EDGE; break; default: ret.wrapClampMode = GL_REPEAT; break; } ret.mipmap = !m_noMips; return ret; } GLuint Shader::StageInfo::LoadImage( size_t index ) const { unsigned int w, h; //dummy vars return Shader::LoadTexture( images[index].name, mipmap, wrapClampMode, w, h ); } bool Shader::HasTransparency( void ) const { for( int i = 0; i < m_numStages; i++ ) if( !(m_stages[i].state & StateBits::AlphaTest_Bits) && (m_stages[i].state & StateBits::DstBlend_Bits) == StateBits::DstBlend_Zero ) //stage is opaque return false; return true; } };