/* Copyright (C) 1999-2007 id Software, Inc. and contributors. For a list of contributors, see the accompanying CONTRIBUTORS file. 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 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 */ #include "cpicosurface.h" // public CPicoSurface::CPicoSurface(picoSurface_t *pSurface) { refCount = 1; m_pSurface = pSurface; // PicoFixSurfaceNormals( pSurface ); AccumulateBBox(); m_shader = QERApp_Shader_ForName(GetShaderName()); } CPicoSurface::~CPicoSurface() { m_shader->DecRef(); } void CPicoSurface::Draw(int state, int rflags) { Draw(state, m_shader, rflags); } void CPicoSurface::Draw(int state, IShader *pShader, int rflags) { int j; if( !(rflags & (DRAW_RF_SEL_OUTLINE|DRAW_RF_SEL_FILL|DRAW_RF_XY)) ) { if(state & DRAW_GL_TEXTURE_2D) { g_QglTable.m_pfn_qglBindTexture(GL_TEXTURE_2D, pShader->getTexture()->texture_number); if( (rflags & DRAW_RF_CAM) && (pShader->getFlags() & QER_ALPHAFUNC) ) { int nFunc = 0; float fRef = 0.f; g_QglTable.m_pfn_qglColor4f( 1.f, 1.f, 1.f, 1.f ); // identity g_QglTable.m_pfn_qglEnable( GL_ALPHA_TEST ); pShader->getAlphaFunc( &nFunc, &fRef ); g_QglTable.m_pfn_qglAlphaFunc( nFunc, fRef ); } } else { //g_QglTable.m_pfn_qglColor3fv( pShader->getTexture()->color ); /* g_QglTable.m_pfn_qglEnableClientState(GL_COLOR_ARRAY);*/ } if( !(state & DRAW_GL_WIRE) && (pShader->getFlags() & QER_CULL) ) { if( pShader->getCull() == 2 ) { g_QglTable.m_pfn_qglDisable( GL_CULL_FACE ); g_QglTable.m_pfn_qglPolygonMode (GL_FRONT, GL_FILL); } else // is 1 { g_QglTable.m_pfn_qglCullFace( GL_BACK ); } } } switch( PicoGetSurfaceType(m_pSurface) ) { case PICO_TRIANGLES: g_QglTable.m_pfn_qglBegin(GL_TRIANGLES); for (j=0; jgetFlags() & QER_ALPHAFUNC) ) { g_QglTable.m_pfn_qglDisable( GL_ALPHA_TEST ); } /* if(!(state & DRAW_GL_TEXTURE_2D)) { g_QglTable.m_pfn_qglDisableClientState(GL_COLOR_ARRAY); }*/ if( !(state & DRAW_GL_WIRE) && (pShader->getFlags() & QER_CULL) ) { if( pShader->getCull() == 2 ) { g_QglTable.m_pfn_qglPolygonMode (GL_FRONT, GL_LINE); g_QglTable.m_pfn_qglEnable( GL_CULL_FACE ); } else // is 1 { g_QglTable.m_pfn_qglCullFace( GL_FRONT ); } } } } // private void CPicoSurface::AccumulateBBox() { int i; picoVec_t *p; aabb_clear(&m_BBox); for (i=0; i