Arachnoid GLESv1.1 plugin. Compile and run (a bit glitchy and no frameskip) on the...
[mupen64plus-pandora.git] / source / mupen64plus-video-arachnoid / src / RSP / RSPMatrixManager.h
CommitLineData
22726e4d 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_MATRIX_MANAGER_H_
23#define RSP_MATRIX_MANAGER_H_
24
25#include "Matrix4.h"
26
27//Forward Declarations
28class Memory;
29
30//*****************************************************************************
31//! RSP Matrix Manager
32//*****************************************************************************
33class RSPMatrixManager
34{
35public:
36
37 //Constructor / Destructor
38 RSPMatrixManager();
39 ~RSPMatrixManager();
40
41 bool initialize(Memory* memory);
42
43 //Add Matrices
44 void addMatrix(unsigned int segmentAddress, bool projectionMatrix, bool push, bool replace);
45 void insertMatrix(unsigned int where, unsigned int num);
46
47 //Remove Matrices
48 void popMatrix();
49 void popMatrixN(unsigned int num);
50 void ForceMatrix( unsigned int segmentAddress );
51 void selectViewMatrix(unsigned int index) { m_modelViewMatrixTop = index; _updateCombinedMatrix(); }
52 void DMAMatrix(unsigned int segmentAddress, unsigned char index, unsigned char multiply );
53 //void RSP_ForceMatrix( unsigned int mptr );
54 //void RSP_LookAt( unsigned int l );
55 //void RSP_PerspNormalize( unsigned short scale );
56
57 void setRDRAMOffset(unsigned int offset) { m_rdramOffset = offset; }
58
59 void resetMatrices();
60
61public:
62
63 float* getModelViewMatrix() { return m_modelViewMatrices[m_modelViewMatrixTop]._m; }
64 float* getProjectionMatrix() { return m_projectionMatrices[m_projectionMatrixTop]._m; }
65 float* getViewProjectionMatrix() { return m_worldProject._m; }
66
67private:
68
69 void _loadMatrix(unsigned int addr, Matrix4& out);
70 void _setProjection(const Matrix4& mat, bool push, bool replace);
71 void _setWorldView(const Matrix4 & mat, bool push, bool replace);
72 void _updateCombinedMatrix();
73
74private:
75
76 Memory* m_memory; //!< Pointer to memory
77
78 static const int NUM_STACK_MATRICES = 60;
79
80 unsigned int m_rdramOffset;
81
82 //Stack indices
83 unsigned int m_modelViewMatrixTop;
84 unsigned int m_projectionMatrixTop;
85
86 //Matrices
87 Matrix4 m_modelViewMatrices[NUM_STACK_MATRICES]; //!< Stack with projection matrices
88 Matrix4 m_projectionMatrices[NUM_STACK_MATRICES]; //!< Stack with projection matrices
89 Matrix4 m_worldProject; //!< Combined modelviewprojection matrix
90};
91
92#endif