X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=plugins%2Fmodel%2Fcpicosurface.cpp;h=0fc88fb812f6565b7ecb49e03198d6aa479203d7;hb=2def0428da1f9148a4101d984a7f1b72bfde57d8;hp=f3655246eeef3f4ad02820ccfce162bf692112f0;hpb=80378101101ca1762bbf5638a9e3566893096d8a;p=xonotic%2Fnetradiant.git diff --git a/plugins/model/cpicosurface.cpp b/plugins/model/cpicosurface.cpp index f3655246..0fc88fb8 100644 --- a/plugins/model/cpicosurface.cpp +++ b/plugins/model/cpicosurface.cpp @@ -1,203 +1,203 @@ -/* -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; iDecRef(); +} + +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