| 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 "CachedTexture.h" |
| 23 | |
| 24 | #include "m64p.h" |
| 25 | #include "OpenGL.h" |
| 26 | |
| 27 | //----------------------------------------------------------------------------- |
| 28 | //! Constructor |
| 29 | //----------------------------------------------------------------------------- |
| 30 | CachedTexture::CachedTexture() |
| 31 | { |
| 32 | m_id = 0; //!< id used by OpenGL to identify texture |
| 33 | m_textureSize = 0; //!< Size of texture in bytes |
| 34 | address = 0; |
| 35 | crc = 0; |
| 36 | offsetS = offsetT = 0; |
| 37 | maskS = maskT = 0; |
| 38 | clampS = clampT = 0; |
| 39 | mirrorS = mirrorT = 0; |
| 40 | line = 0; |
| 41 | size = 0; |
| 42 | format = 0; //!< Texture format |
| 43 | tMem = 0; |
| 44 | palette = 0; //!< What Texture Look Up Table to use |
| 45 | width = height = 0; // N64 width and height |
| 46 | clampWidth = clampHeight = 0; // Size to clamp to |
| 47 | realWidth = realHeight = 0; // Actual texture size |
| 48 | scaleS = scaleT = 0; // Scale to map to 0.0-1.0 |
| 49 | shiftScaleS = shiftScaleT = 0; // Scale to shift |
| 50 | } |
| 51 | |
| 52 | //----------------------------------------------------------------------------- |
| 53 | //! Destructor |
| 54 | //----------------------------------------------------------------------------- |
| 55 | CachedTexture::~CachedTexture() |
| 56 | { |
| 57 | |
| 58 | } |
| 59 | |
| 60 | //----------------------------------------------------------------------------- |
| 61 | //! Activate texture |
| 62 | //----------------------------------------------------------------------------- |
| 63 | void CachedTexture::activate() |
| 64 | { |
| 65 | glEnable(GL_TEXTURE_2D); |
| 66 | glBindTexture( GL_TEXTURE_2D, m_id ); |
| 67 | } |
| 68 | |
| 69 | //----------------------------------------------------------------------------- |
| 70 | //! Deactivate texture |
| 71 | //----------------------------------------------------------------------------- |
| 72 | void CachedTexture::deactivate() |
| 73 | { |
| 74 | glDisable(GL_TEXTURE_2D); |
| 75 | glBindTexture( GL_TEXTURE_2D, 0 ); |
| 76 | } |
| 77 | |
| 78 | //----------------------------------------------------------------------------- |
| 79 | //! Equal operator |
| 80 | //----------------------------------------------------------------------------- |
| 81 | bool CachedTexture::operator == (const CachedTexture& t) const |
| 82 | { |
| 83 | return( crc == t.crc && |
| 84 | width == t.width && |
| 85 | height == t.height && |
| 86 | clampWidth == t.clampWidth && |
| 87 | clampHeight == t.clampHeight && |
| 88 | maskS == t.maskS && |
| 89 | maskT == t.maskT && |
| 90 | mirrorS == t.mirrorS && |
| 91 | mirrorT == t.mirrorT && |
| 92 | clampS == t.clampS && |
| 93 | clampT == t.clampT && |
| 94 | format == t.format /* && |
| 95 | size == t.size */ ); |
| 96 | } |
| 97 | |
| 98 | //----------------------------------------------------------------------------- |
| 99 | //! Assign operator |
| 100 | //----------------------------------------------------------------------------- |
| 101 | CachedTexture& CachedTexture::operator = (const CachedTexture& v) |
| 102 | { |
| 103 | address = v.address; |
| 104 | crc = v.crc; |
| 105 | format = v.format; |
| 106 | size = v.size; |
| 107 | width = v.width; |
| 108 | height = v.height; |
| 109 | clampWidth = v.clampWidth; |
| 110 | clampHeight = v.clampHeight; |
| 111 | palette = v.palette; |
| 112 | /* cache.current[tile]->fulS = gSP.textureTile[tile]->fulS; |
| 113 | cache.current[tile]->fulT = gSP.textureTile[tile]->fulT; |
| 114 | cache.current[tile]->ulS = gSP.textureTile[tile]->ulS; |
| 115 | cache.current[tile]->ulT = gSP.textureTile[tile]->ulT; |
| 116 | cache.current[tile]->lrS = gSP.textureTile[tile]->lrS; |
| 117 | cache.current[tile]->lrT = gSP.textureTile[tile]->lrT;*/ |
| 118 | maskS = v.maskS; |
| 119 | maskT = v.maskT; |
| 120 | mirrorS = v.mirrorS; |
| 121 | mirrorT = v.mirrorT; |
| 122 | clampS = v.clampS; |
| 123 | clampT = v.clampT; |
| 124 | line = v.line; |
| 125 | tMem = v.tMem; |
| 126 | //lastDList = RSP.DList; |
| 127 | //frameBufferTexture = FALSE; |
| 128 | return *this; |
| 129 | } |