Blender V2.61 - r43446

KX_BlenderRenderTools.h

Go to the documentation of this file.
00001 /*
00002  * ***** BEGIN GPL LICENSE BLOCK *****
00003  *
00004  * This program is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU General Public License
00006  * as published by the Free Software Foundation; either version 2
00007  * of the License, or (at your option) any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software Foundation,
00016  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00017  *
00018  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
00019  * All rights reserved.
00020  *
00021  * The Original Code is: all of this file.
00022  *
00023  * Contributor(s): none yet.
00024  *
00025  * ***** END GPL LICENSE BLOCK *****
00026  */
00027 
00032 #ifndef __KX_BLENDERRENDERTOOLS
00033 #define __KX_BLENDERRENDERTOOLS
00034 
00035 #if defined(WIN32) && !defined(FREE_WINDOWS)
00036 // don't show stl-warnings
00037 #pragma warning (disable:4786)
00038 #endif
00039 
00040 #include "RAS_IRenderTools.h"
00041 
00042 #ifdef WITH_CXX_GUARDEDALLOC
00043 #include "MEM_guardedalloc.h"
00044 #endif
00045 
00046 struct KX_ClientObjectInfo;
00047 class KX_RayCast;
00048 
00049 /* BlenderRenderTools are a set of tools to apply 2D/3D graphics effects, which
00050  * are not part of the (polygon) Rasterizer. Effects like 2D text, 3D (polygon)
00051  * text, lighting.
00052  *
00053  * Most of this code is duplicated in GPC_RenderTools, so this should be
00054  * moved to some common location to avoid duplication. */
00055 
00056 class KX_BlenderRenderTools  : public RAS_IRenderTools
00057 {
00058     int     m_lastlightlayer;
00059     bool    m_lastlighting;
00060     void    *m_lastauxinfo;
00061     static unsigned int m_numgllights;
00062 
00063 public:
00064                         KX_BlenderRenderTools();
00065     virtual             ~KX_BlenderRenderTools();   
00066 
00067     void                EndFrame(RAS_IRasterizer* rasty);
00068     void                BeginFrame(RAS_IRasterizer* rasty);
00069 
00070     void                EnableOpenGLLights(RAS_IRasterizer *rasty);
00071     void                DisableOpenGLLights();
00072     void                ProcessLighting(RAS_IRasterizer *rasty, bool uselights, const MT_Transform& viewmat);
00073 
00074     void                RenderText3D(int fontid,
00075                                      const char* text,
00076                                      int size,
00077                                      int dpi,
00078                                      float* color,
00079                                      double* mat,
00080                                      float aspect);
00081 
00082     void        RenderText2D(RAS_TEXT_RENDER_MODE mode,
00083                                      const char* text,
00084                                      int xco,
00085                                      int yco,
00086                                      int width,
00087                                      int height);
00088     void                RenderText(int mode,
00089                                    class RAS_IPolyMaterial* polymat,
00090                                    float v1[3],
00091                                    float v2[3],
00092                                    float v3[3],
00093                                    float v4[3],
00094                                    int glattrib);
00095 
00096     void                applyTransform(RAS_IRasterizer* rasty, double* oglmatrix, int objectdrawmode);
00097     int                 applyLights(int objectlayer, const MT_Transform& viewmat);
00098 
00099     void                PushMatrix();
00100     void                PopMatrix();
00101 
00102     bool RayHit(KX_ClientObjectInfo* client, class KX_RayCast* result, void * const data);
00103     bool NeedRayCast(KX_ClientObjectInfo*) { return true; }
00104 
00105     virtual void MotionBlur(RAS_IRasterizer* rasterizer);
00106 
00107     virtual void SetClientObject(RAS_IRasterizer *rasty, void* obj);
00108     
00109     
00110 #ifdef WITH_CXX_GUARDEDALLOC
00111 public:
00112     void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:KX_BlenderRenderTools"); }
00113     void operator delete( void *mem ) { MEM_freeN(mem); }
00114 #endif
00115 };
00116 
00117 #endif //__KX_BLENDERRENDERTOOLS
00118 
00119 
00120