| 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 | #ifndef RSP_VERTEX_MANAGER_H_ |
| 23 | #define RSP_VERTEX_MANAGER_H_ |
| 24 | |
| 25 | //Forward declarations |
| 26 | class Memory; |
| 27 | class RSPMatrixManager; |
| 28 | class RSPLightManager; |
| 29 | class OpenGLManager; |
| 30 | |
| 31 | enum TexCoordGenType |
| 32 | { |
| 33 | TCGT_NONE = 0, |
| 34 | TCGT_LINEAR = 1, |
| 35 | TCGT_GEN = 2, |
| 36 | }; |
| 37 | |
| 38 | //----------------------------------------------------------------------------- |
| 39 | //! Signal Processor Vertex |
| 40 | //----------------------------------------------------------------------------- |
| 41 | struct SPVertex |
| 42 | { |
| 43 | float x, y, z, w; |
| 44 | float nx, ny, nz; |
| 45 | float r, g, b, a; |
| 46 | float s, t; |
| 47 | float xClip, yClip, zClip; |
| 48 | float flag; |
| 49 | }; |
| 50 | |
| 51 | //***************************************************************************** |
| 52 | //! RSP Vertex Manager |
| 53 | //***************************************************************************** |
| 54 | class RSPVertexManager |
| 55 | { |
| 56 | public: |
| 57 | |
| 58 | //Constructor / Destructor |
| 59 | RSPVertexManager(); |
| 60 | ~RSPVertexManager(); |
| 61 | |
| 62 | bool initialize(OpenGLManager* openGLMgr, Memory* memory, RSPMatrixManager* matrixMgr, RSPLightManager* lightMgr); |
| 63 | |
| 64 | //Vertices |
| 65 | void setVertices( unsigned int address, unsigned int numVertices, unsigned int firstVertexIndex); |
| 66 | void modifyVertex( unsigned int vtx, unsigned int where, unsigned int val ); |
| 67 | void setVertexColor(unsigned int vertexIndex, float r, float g, float b, float a); |
| 68 | void setVertexTextureCoord(unsigned int vertexIndex, float s, float t); |
| 69 | |
| 70 | void ciVertex(unsigned int segmentAddress, unsigned int n, unsigned int v0 ); |
| 71 | |
| 72 | void addConkerVertices(unsigned int segmentAddress, unsigned int n, unsigned int v0 ); |
| 73 | |
| 74 | void DMAVertex( unsigned int v, unsigned int n, unsigned int v0 ); |
| 75 | void DMAOffsets( unsigned int mtxoffset, unsigned int vtxoffset ); |
| 76 | void setVertexColorBase( unsigned int rdramAddress ) { m_colorBaseRDRAMAddress = rdramAddress; } |
| 77 | |
| 78 | bool add1Triangle( unsigned int v0, unsigned int v1, unsigned int v2); |
| 79 | void add2Triangles( int v00, int v01, int v02, int flag0, |
| 80 | int v10, int v11, int v12, int flag1 ); |
| 81 | void add4Triangles( int v00, int v01, int v02, |
| 82 | int v10, int v11, int v12, |
| 83 | int v20, int v21, int v22, |
| 84 | int v30, int v31, int v32 ); |
| 85 | void addDMATriangles( unsigned int tris, unsigned int n ); |
| 86 | void add1Quadrangle( int v0, int v1, int v2, int v4 ); |
| 87 | void setTexCoordGenType(TexCoordGenType texCoordGenType) { m_texCoordGenType = texCoordGenType; } |
| 88 | |
| 89 | void setRDRAMOffset(unsigned int offset) { m_rdramOffset = offset; } |
| 90 | void setBillboard(unsigned int billboard) { m_billboard = billboard; } |
| 91 | unsigned int getBillboard() { return m_billboard; } |
| 92 | |
| 93 | void setConkerAddress(unsigned int segmentAddress); |
| 94 | |
| 95 | public: |
| 96 | |
| 97 | SPVertex* getVertex(unsigned int index) { return &m_vertices[index]; } |
| 98 | |
| 99 | private: |
| 100 | |
| 101 | void _processVertex( unsigned int v ); |
| 102 | |
| 103 | private: |
| 104 | |
| 105 | OpenGLManager* m_openGLMgr; |
| 106 | Memory* m_memory; |
| 107 | RSPMatrixManager* m_matrixMgr; |
| 108 | RSPLightManager* m_lightMgr; |
| 109 | |
| 110 | //Vertex Buffer |
| 111 | static const unsigned int MAX_VERTICES = 300; |
| 112 | SPVertex m_vertices[MAX_VERTICES]; |
| 113 | |
| 114 | unsigned int m_colorBaseRDRAMAddress; //!< Address in RDRAM where colors for vertices are located (used by Perfect Dark) |
| 115 | |
| 116 | unsigned int m_rdramOffset; |
| 117 | |
| 118 | unsigned int m_billboard; |
| 119 | TexCoordGenType m_texCoordGenType; //!< Texture Coordinate Generation Technique |
| 120 | |
| 121 | unsigned int m_conkerRDRAMAddress; |
| 122 | }; |
| 123 | |
| 124 | #endif |