Initial revision
[blender.git] / source / gameengine / Rasterizer / RAS_OpenGLRasterizer / RAS_OpenGLRasterizer.h
1 /**
2  * $Id$
3  *
4  * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version. The Blender
10  * Foundation also sells licenses for use in proprietary software under
11  * the Blender License.  See http://www.blender.org/BL/ for information
12  * about this.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software Foundation,
21  * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
22  *
23  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
24  * All rights reserved.
25  *
26  * The Original Code is: all of this file.
27  *
28  * Contributor(s): none yet.
29  *
30  * ***** END GPL/BL DUAL LICENSE BLOCK *****
31  */
32 #ifndef __RAS_OPENGLRASTERIZER
33 #define __RAS_OPENGLRASTERIZER
34
35 #ifdef WIN32
36 #pragma warning (disable:4786)
37 #endif
38
39 #include "MT_CmMatrix4x4.h"
40 #include <vector>
41 using namespace std;
42
43
44 #include "RAS_IRasterizer.h"
45 #include "RAS_MaterialBucket.h"
46 #include "RAS_ICanvas.h"
47
48 /**
49  * 3D rendering device context.
50  */
51 class RAS_OpenGLRasterizer : public RAS_IRasterizer
52 {
53
54         RAS_ICanvas*    m_2DCanvas;
55         
56         // fogging vars
57         bool                    m_fogenabled;
58         float                   m_fogstart;
59         float                   m_fogdist;
60         float                   m_fogr;
61         float                   m_fogg;
62         float                   m_fogb;
63         
64         float                   m_redback;
65         float                   m_greenback;
66         float                   m_blueback;
67         float                   m_alphaback;
68
69         bool                    m_bEXT_compiled_vertex_array;
70
71         double                  m_time;
72         MT_CmMatrix4x4  m_viewmatrix;
73         MT_Point3               m_campos;
74
75         int                             m_stereomode;
76         int                             m_curreye;
77         float                   m_eyeseparation;
78         float                   m_focallength;
79         int                             m_noOfScanlines;
80
81 protected:
82         int                             m_drawingmode;
83         /** Stores the caching information for the last material activated. */
84         RAS_IPolyMaterial::TCachingInfo m_materialCachingInfo;
85
86 public:
87         double GetTime();
88         RAS_OpenGLRasterizer(RAS_ICanvas* canv);
89         virtual ~RAS_OpenGLRasterizer();
90
91
92
93         enum
94         {
95                         KX_BOUNDINGBOX = 1,
96                         KX_WIREFRAME,
97                         KX_SOLID,
98                         KX_SHADED,
99                         KX_TEXTURED 
100         };
101
102         enum
103         {
104                         KX_DEPTHMASK_ENABLED =1,
105                         KX_DEPTHMASK_DISABLED,
106         };
107         virtual void    SetDepthMask(int depthmask);
108
109         virtual void    SetMaterial(const RAS_IPolyMaterial& mat);
110         virtual bool    Init();
111         virtual void    Exit();
112         virtual bool    BeginFrame(int drawingmode, double time);
113         virtual void    ClearDepthBuffer();
114         virtual void    ClearCachingInfo(void);
115         virtual void    EndFrame();
116         virtual void    SetRenderArea();
117
118         virtual void    SetStereoMode(const int stereomode);
119         virtual bool    Stereo();
120         virtual void    SetEye(const int eye);
121         virtual void    SetEyeSeparation(const float eyeseparation);
122         virtual void    SetFocalLength(const float focallength);
123
124         virtual void    SwapBuffers();
125         virtual void    IndexPrimitives(
126                                                 const vecVertexArray& vertexarrays,
127                                                 const vecIndexArrays & indexarrays,
128                                                 int mode,
129                                                 class RAS_IPolyMaterial* polymat,
130                                                 class RAS_IRenderTools* rendertools,
131                                                 bool useObjectColor,
132                                                 const MT_Vector4& rgbacolor
133                                         );
134
135         virtual void    IndexPrimitives_Ex(
136                                                 const vecVertexArray& vertexarrays,
137                                                 const vecIndexArrays & indexarrays,
138                                                 int mode,
139                                                 class RAS_IPolyMaterial* polymat,
140                                                 class RAS_IRenderTools* rendertools,
141                                                 bool useObjectColor,
142                                                 const MT_Vector4& rgbacolor
143                                         );
144
145         virtual void    IndexPrimitives_3DText(
146                                                 const vecVertexArray& vertexarrays,
147                                                 const vecIndexArrays & indexarrays,
148                                                 int mode,
149                                                 class RAS_IPolyMaterial* polymat,
150                                                 class RAS_IRenderTools* rendertools,
151                                                 bool useObjectColor,
152                                                 const MT_Vector4& rgbacolor
153                                         );
154
155         virtual void    SetProjectionMatrix(MT_CmMatrix4x4 & mat);
156         virtual void    SetProjectionMatrix(MT_Matrix4x4 & mat);
157         virtual void    SetViewMatrix(
158                                                 const MT_Matrix4x4 & mat,
159                                                 const MT_Vector3& campos,
160                                                 const MT_Point3 &camLoc,
161                                                 const MT_Quaternion &camOrientQuat
162                                         );
163
164         virtual const   MT_Point3& GetCameraPosition();
165         virtual void    LoadViewMatrix();
166         
167         virtual void    SetFog(
168                                                 float start,
169                                                 float dist,
170                                                 float r,
171                                                 float g,
172                                                 float b
173                                         );
174
175         virtual void    SetFogColor(
176                                                 float r,
177                                                 float g,
178                                                 float b
179                                         );
180
181         virtual void    SetFogStart(float fogstart);
182         virtual void    SetFogEnd(float fogend);
183
184         void                    DisableFog();
185         virtual void    DisplayFog();
186
187         virtual void    SetBackColor(
188                                                 float red,
189                                                 float green,
190                                                 float blue,
191                                                 float alpha
192                                         );
193         
194         virtual void    SetDrawingMode(int drawingmode);
195         virtual int             GetDrawingMode();
196
197         virtual void    EnableTextures(bool enable);
198         virtual void    SetCullFace(bool enable);
199
200         virtual MT_Matrix4x4 GetFrustumMatrix(
201                                                         float left,
202                                                         float right,
203                                                         float bottom,
204                                                         float top,
205                                                         float frustnear,
206                                                         float frustfar
207                                                 );
208
209         virtual void    SetSpecularity(
210                                                 float specX,
211                                                 float specY,
212                                                 float specZ,
213                                                 float specval
214                                         );
215
216         virtual void    SetShinyness(float shiny);
217         virtual void    SetDiffuse(
218                                                 float difX,
219                                                 float difY,
220                                                 float difZ,
221                                                 float diffuse
222                                         );
223
224 };
225
226 #endif //__RAS_OPENGLRASTERIZER