| 1 | /****************************************************************************** |
| 2 | * Arachnoid Graphics Plugin for Mupen64Plus |
| 3 | * http://bitbucket.org/wahrhaft/mupen64plus-video-arachnoid/ |
| 4 | * |
| 5 | * Copyright (C) 2007 Kristofer Karlsson, Rickard Niklasson |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or |
| 8 | * modify it under the terms of the GNU General Public License |
| 9 | * as published by the Free Software Foundation; either version 2 |
| 10 | * of the License, or (at your option) any later version. |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | * GNU General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License |
| 18 | * along with this program; if not, write to the Free Software |
| 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 20 | *****************************************************************************/ |
| 21 | |
| 22 | #include "DummyCombiner.h" |
| 23 | #include "CombinerStructs.h" |
| 24 | #include "ExtensionChecker.h" |
| 25 | #include "MultiTexturingExt.h" |
| 26 | |
| 27 | //----------------------------------------------------------------------------- |
| 28 | //* Initialize |
| 29 | //! Checks if multitexturing is supported |
| 30 | //----------------------------------------------------------------------------- |
| 31 | void DummyCombiner::initialize() |
| 32 | { |
| 33 | ARB_multitexture = isExtensionSupported("GL_ARB_multitexture"); |
| 34 | } |
| 35 | |
| 36 | //----------------------------------------------------------------------------- |
| 37 | //* Create New Texture Enviroment |
| 38 | //! Allocates a new texture enviroment |
| 39 | //! @param[in] colorCombiner How to combine and get a color |
| 40 | //! @param[in] alphaCombiner How to combine and get an alpha value |
| 41 | //! @return The texture enviroment that was created |
| 42 | //----------------------------------------------------------------------------- |
| 43 | TexEnvCombiner* DummyCombiner::createNewTextureEnviroment(Combiner* colorCombiner, Combiner *alphaCombiner) |
| 44 | { |
| 45 | TexEnvCombiner* texEnv = new TexEnvCombiner(); |
| 46 | texEnv->usesT0 = false; |
| 47 | texEnv->usesT1 = false; |
| 48 | texEnv->mode = GL_REPLACE; |
| 49 | texEnv->vertex.color = COMBINED; |
| 50 | texEnv->vertex.alpha = COMBINED; |
| 51 | |
| 52 | //For each stage in alpha combiner |
| 53 | for (int i = 0; i < alphaCombiner->numStages; i++) |
| 54 | { |
| 55 | //For each operation in stage |
| 56 | for (int j = 0; j < alphaCombiner->stage[i].numOps; j++) |
| 57 | { |
| 58 | CombinerOp* op = &colorCombiner->stage[i].op[j]; |
| 59 | |
| 60 | if ( op->param1 == TEXEL0 ) |
| 61 | { |
| 62 | texEnv->usesT0 = true; |
| 63 | } |
| 64 | } |
| 65 | } |
| 66 | return texEnv; |
| 67 | } |
| 68 | |
| 69 | //----------------------------------------------------------------------------- |
| 70 | //* Set Texture Enviroment |
| 71 | //! Sets OpenGL (enables texturing) |
| 72 | //----------------------------------------------------------------------------- |
| 73 | void DummyCombiner::setTextureEnviroment(TexEnvCombiner* texEnv) |
| 74 | { |
| 75 | //Enable Texturing |
| 76 | if ( ARB_multitexture ) |
| 77 | glActiveTextureARB( GL_TEXTURE0_ARB ); |
| 78 | |
| 79 | if ( texEnv->usesT0 ) |
| 80 | glEnable( GL_TEXTURE_2D ); |
| 81 | else |
| 82 | glDisable( GL_TEXTURE_2D ); |
| 83 | } |