Arachnoid GLESv1.1 plugin. Compile and run (a bit glitchy and no frameskip) on the...
[mupen64plus-pandora.git] / source / mupen64plus-video-arachnoid / src / renderer / OpenGLRenderer.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 OPEN_GL_RENDERER_H_
23#define OPEN_GL_RENDERER_H_
24
25#include "m64p.h"
26#include "OpenGL.h"
27
28//Forward Declarations
29struct SPVertex;
30class RSP;
31class RDP;
32class TextureCache;
33class VI;
34class FogManager;
35
36#include "MultiTexturingExt.h"
37
38
39//*****************************************************************************
40//* OpenGL Vertex
41//! Used in vertex buffer by OpenGLRenderer.
42//*****************************************************************************
43struct GLVertex
44{
45 float x, y, z, w; //!< Vertex position
46 struct
47 {
48 float r, g, b, a;
49 } color, secondaryColor; //!< Color and secondary color
50 float s0, t0, s1, t1; //!< Texture coordinats
51 float fog; //!< Vertex fog variable
52};
53
54//*****************************************************************************
55//* OpenGL Renderer
56//! Class for rendering using OpenGL
57//*****************************************************************************
58class OpenGLRenderer
59{
60public:
61
62 //Get Singleton Instance
63 static OpenGLRenderer& getSingleton()
64 {
65 static OpenGLRenderer instance;
66 return instance;
67 }
68
69 //Destructor
70 ~OpenGLRenderer();
71
72 //Initialize
73 bool initialize(RSP* rsp, RDP* rdp, TextureCache* textureCache, VI* vi, FogManager* fogMgr);
74
75 //Flush Vertex buffer
76 void render();
77
78 //Add triangle
79 void addTriangle( SPVertex *vertices, int v0, int v1, int v2 );
80
81 //Get number of vertices
82 int getNumVertices() { return m_numVertices; }
83
84 //Render Tex Rect
85 void renderTexRect( float ulx, float uly, //Upper left vertex
86 float lrx, float lry, //Lower right vertex
87 float uls, float ult, //Upper left texcoord
88 float lrs, float lrt, //Lower right texcoord
89 bool flip); //Flip
90
91private:
92
93 //Constructor
94 OpenGLRenderer();
95
96private:
97
98 GLVertex m_vertices[256]; //!< Vertex buffer
99 unsigned char m_triangles[300][3]; //!< Triangles used to index vertices
100
101 int m_numVertices; //!< Number of vertices in vertex buffer
102 int m_numTriangles; //!< Number of triangles
103
104 RSP* m_rsp; //!< Pointer to Reality Signal Processor
105 RDP* m_rdp; //!< Pointer to Reality Drawing Processor
106 VI* m_vi; //!< Pointer to Video Interface
107 TextureCache* m_textureCache; //!< Pointer to texture cache
108 FogManager* m_fogMgr; //!< Pointer to Fog Manager used to render fog.
109
110};
111
112#endif