fixed spacing in the headers to get rid of some warnings and some other
[blender.git] / source / gameengine / GamePlayer / common / GPC_RenderTools.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
33 #ifndef __GPC_RENDERTOOLS_H
34 #define __GPC_RENDERTOOLS_H
35
36 #if defined(WIN32) || defined(__APPLE__)
37         #ifdef WIN32
38                 #include <windows.h>
39                 #include <GL/gl.h>
40         #else // WIN32
41                 // __APPLE__ is defined
42                 #include <AGL/gl.h>
43         #endif // WIN32
44 #else //defined(WIN32) || defined(__APPLE__)
45         #include <GL/gl.h>
46 #endif //defined(WIN32) || defined(__APPLE__)
47
48
49 #include "RAS_IRenderTools.h"
50
51 #include "BMF_Api.h"
52
53
54 class GPC_RenderTools : public RAS_IRenderTools
55 {
56 public:
57         GPC_RenderTools();
58         virtual ~GPC_RenderTools();
59
60         virtual void EndFrame(RAS_IRasterizer* rasty);
61         virtual void BeginFrame(RAS_IRasterizer* rasty);
62
63         void DisableOpenGLLights()
64         {
65                 glDisable(GL_LIGHTING);
66                 glDisable(GL_COLOR_MATERIAL);
67                 glDisableClientState(GL_NORMAL_ARRAY);
68         }
69
70         void EnableOpenGLLights()
71         {
72                 glEnable(GL_LIGHTING);
73                 glColorMaterial(GL_FRONT_AND_BACK,GL_DIFFUSE);
74                 glEnable(GL_COLOR_MATERIAL);
75                 glEnableClientState(GL_NORMAL_ARRAY);
76         }
77
78         int ProcessLighting(int layer);
79
80         void Perspective(int a, int width, int height, float mat[4][4], float viewmat[4][4])
81         {
82                 if(a== 0)
83                 {
84                         glMatrixMode(GL_PROJECTION);
85                         glMatrixMode(GL_MODELVIEW);
86                         glLoadIdentity();
87                 }
88                 else
89                 {
90                         if(a== 1)
91                         {
92                                 glMatrixMode(GL_PROJECTION);
93                                 glMatrixMode(GL_MODELVIEW);
94                         }
95                 }
96         }
97
98         /**
99          * @attention mode is ignored here
100          */
101         virtual void RenderText2D(
102                                         RAS_TEXT_RENDER_MODE mode,
103                                         const char* text,
104                                         int xco,
105                                         int yco,
106                                         int width,
107                                         int height);
108
109         /**
110          * Renders text into a (series of) polygon(s), using a texture font,
111          * Each character consists of one polygon (one quad or two triangles)
112          */
113         virtual void RenderText(
114                                         int mode,
115                                         RAS_IPolyMaterial* polymat,
116                                         float v1[3],
117                                         float v2[3],
118                                         float v3[3],
119                                         float v4[3]);
120
121         void Render(RAS_IRasterizer* rasty,double* oglmatrix,int objectdrawmode)
122         {
123                 glPopMatrix();
124                 glPushMatrix();
125                 glMultMatrixd(oglmatrix);
126         }
127
128         void applyTransform(RAS_IRasterizer* rasty, double* oglmatrix, int objectdrawmode);
129
130         virtual void PushMatrix()
131         {
132                 glPushMatrix();
133         }
134
135         virtual void PopMatrix()
136         {
137                 glPopMatrix();
138         }
139
140         virtual class RAS_IPolyMaterial* CreateBlenderPolyMaterial(
141                         const STR_String &texname,
142                         bool ba,
143                         const STR_String& matname,
144                         int tile,
145                         int tilexrep,int tileyrep,
146                         int mode,
147                         int transparant,
148                         int lightlayer,
149                         bool bIsTriangle,
150                         void* clientobject,
151                         void* tface);
152
153         int applyLights(int objectlayer);
154
155 protected:
156         /** 
157          * Copied from KX_BlenderGL.cpp in KX_blenderhook
158          */
159         void BL_RenderText(
160                 int mode,
161                 const char* textstr,
162                 int textlen,
163                 struct TFace* tface,
164                 float v1[3],float v2[3],float v3[3],float v4[3]);
165         void BL_spack(unsigned int ucol)
166         {
167                 char *cp = (char *)&ucol;               
168                 glColor3ub(cp[3], cp[2], cp[1]);
169         }
170
171
172         BMF_Font* m_font;
173 };
174
175 #endif  // __GPC_RENDERTOOLS_H
176