9ab7b772cf9fdb4dbea7bb6f82b98277bce90137
[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 #include "RAS_IRasterizer.h"
44 #include "RAS_MaterialBucket.h"
45 #include "RAS_ICanvas.h"
46
47 /**
48  * 3D rendering device context.
49  */
50 class RAS_OpenGLRasterizer : public RAS_IRasterizer
51 {
52
53         RAS_ICanvas*    m_2DCanvas;
54         
55         // fogging vars
56         bool                    m_fogenabled;
57         float                   m_fogstart;
58         float                   m_fogdist;
59         float                   m_fogr;
60         float                   m_fogg;
61         float                   m_fogb;
62         
63         float                   m_redback;
64         float                   m_greenback;
65         float                   m_blueback;
66         float                   m_alphaback;
67
68         double                  m_time;
69         MT_CmMatrix4x4  m_viewmatrix;
70         MT_Point3               m_campos;
71
72         StereoMode              m_stereomode;
73         StereoEye               m_curreye;
74         float                   m_eyeseparation;
75         float                   m_focallength;
76         int                             m_noOfScanlines;
77         
78         bool                    InterlacedStereo() const;
79
80 protected:
81         int                             m_drawingmode;
82         /** Stores the caching information for the last material activated. */
83         RAS_IPolyMaterial::TCachingInfo m_materialCachingInfo;
84
85 public:
86         double GetTime();
87         RAS_OpenGLRasterizer(RAS_ICanvas* canv);
88         virtual ~RAS_OpenGLRasterizer();
89
90         /*enum DrawType
91         {
92                         KX_BOUNDINGBOX = 1,
93                         KX_WIREFRAME,
94                         KX_SOLID,
95                         KX_SHADED,
96                         KX_TEXTURED
97         };
98
99         enum DepthMask
100         {
101                         KX_DEPTHMASK_ENABLED =1,
102                         KX_DEPTHMASK_DISABLED,
103         };*/
104         virtual void    SetDepthMask(DepthMask depthmask);
105
106         virtual void    SetMaterial(const RAS_IPolyMaterial& mat);
107         virtual bool    Init();
108         virtual void    Exit();
109         virtual bool    BeginFrame(int drawingmode, double time);
110         virtual void    ClearDepthBuffer();
111         virtual void    ClearCachingInfo(void);
112         virtual void    EndFrame();
113         virtual void    SetRenderArea();
114
115         virtual void    SetStereoMode(const StereoMode stereomode);
116         virtual bool    Stereo();
117         virtual void    SetEye(const StereoEye eye);
118         virtual StereoEye       GetEye();
119         virtual void    SetEyeSeparation(const float eyeseparation);
120         virtual float   GetEyeSeparation();
121         virtual void    SetFocalLength(const float focallength);
122         virtual float   GetFocalLength();
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(const 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         virtual void    SetLines(bool enable);
200
201         virtual MT_Matrix4x4 GetFrustumMatrix(
202                                                         float left,
203                                                         float right,
204                                                         float bottom,
205                                                         float top,
206                                                         float frustnear,
207                                                         float frustfar,
208                                                         bool perspective
209                                                 );
210
211         virtual void    SetSpecularity(
212                                                 float specX,
213                                                 float specY,
214                                                 float specZ,
215                                                 float specval
216                                         );
217
218         virtual void    SetShinyness(float shiny);
219         virtual void    SetDiffuse(
220                                                 float difX,
221                                                 float difY,
222                                                 float difZ,
223                                                 float diffuse
224                                         );
225
226 };
227
228 #endif //__RAS_OPENGLRASTERIZER
229