update for MingW/CMake
[blender-staging.git] / source / gameengine / BlenderRoutines / KX_BlenderRenderTools.h
1 /**
2  * $Id$
3  *
4  * ***** BEGIN GPL 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.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software Foundation,
18  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19  *
20  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
21  * All rights reserved.
22  *
23  * The Original Code is: all of this file.
24  *
25  * Contributor(s): none yet.
26  *
27  * ***** END GPL LICENSE BLOCK *****
28  */
29
30 #ifndef __KX_BLENDERRENDERTOOLS
31 #define __KX_BLENDERRENDERTOOLS
32
33 #if defined(WIN32) && !defined(FREE_WINDOWS)
34 // don't show stl-warnings
35 #pragma warning (disable:4786)
36 #endif
37
38 #include "RAS_IRenderTools.h"
39
40 #ifdef WITH_CXX_GUARDEDALLOC
41 #include "MEM_guardedalloc.h"
42 #endif
43
44 struct KX_ClientObjectInfo;
45 class KX_RayCast;
46
47 /* BlenderRenderTools are a set of tools to apply 2D/3D graphics effects, which
48  * are not part of the (polygon) Rasterizer. Effects like 2D text, 3D (polygon)
49  * text, lighting.
50  *
51  * Most of this code is duplicated in GPC_RenderTools, so this should be
52  * moved to some common location to avoid duplication. */
53
54 class KX_BlenderRenderTools  : public RAS_IRenderTools
55 {
56         int             m_lastlightlayer;
57         bool    m_lastlighting;
58         void    *m_lastauxinfo;
59         static unsigned int m_numgllights;
60
61 public:
62                                                 KX_BlenderRenderTools();
63         virtual                         ~KX_BlenderRenderTools();       
64
65         void                            EndFrame(RAS_IRasterizer* rasty);
66         void                            BeginFrame(RAS_IRasterizer* rasty);
67
68         void                            EnableOpenGLLights(RAS_IRasterizer *rasty);
69         void                            DisableOpenGLLights();
70         void                            ProcessLighting(RAS_IRasterizer *rasty, bool uselights, const MT_Transform& viewmat);
71
72         void                        RenderText2D(RAS_TEXT_RENDER_MODE mode,
73                                                                          const char* text,
74                                                                          int xco,
75                                                                          int yco,
76                                                                          int width,
77                                                                          int height);
78         void                            RenderText(int mode,
79                                                                    class RAS_IPolyMaterial* polymat,
80                                                                    float v1[3],
81                                                                    float v2[3],
82                                                                    float v3[3],
83                                                                    float v4[3],
84                                                                    int glattrib);
85
86         void                            applyTransform(RAS_IRasterizer* rasty, double* oglmatrix, int objectdrawmode);
87         int                                     applyLights(int objectlayer, const MT_Transform& viewmat);
88
89         void                            PushMatrix();
90         void                            PopMatrix();
91
92         bool RayHit(KX_ClientObjectInfo* client, class KX_RayCast* result, void * const data);
93         bool NeedRayCast(KX_ClientObjectInfo*) { return true; }
94
95         virtual void MotionBlur(RAS_IRasterizer* rasterizer);
96
97         virtual void SetClientObject(RAS_IRasterizer *rasty, void* obj);
98         
99         
100 #ifdef WITH_CXX_GUARDEDALLOC
101 public:
102         void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:KX_BlenderRenderTools"); }
103         void operator delete( void *mem ) { MEM_freeN(mem); }
104 #endif
105 };
106
107 #endif //__KX_BLENDERRENDERTOOLS
108
109
110