Blender  V2.59
BL_BlenderShader.h
Go to the documentation of this file.
00001 /*
00002  * $Id: BL_BlenderShader.h 35063 2011-02-22 10:33:14Z jesterking $
00003  *
00004  * ***** BEGIN GPL LICENSE BLOCK *****
00005  *
00006  * This program is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU General Public License
00008  * as published by the Free Software Foundation; either version 2
00009  * of the License, or (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software Foundation,
00018  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00019  *
00020  * The Original Code is Copyright (C) Blender Foundation
00021  * All rights reserved.
00022  *
00023  * The Original Code is: all of this file.
00024  *
00025  * Contributor(s): none yet.
00026  *
00027  * ***** END GPL LICENSE BLOCK *****
00028  */
00029 
00034 #ifndef __BL_GPUSHADER_H__
00035 #define __BL_GPUSHADER_H__
00036 
00037 #include "GPU_material.h"
00038 
00039 #include "MT_Matrix4x4.h"
00040 #include "MT_Matrix3x3.h"
00041 #include "MT_Tuple2.h"
00042 #include "MT_Tuple3.h"
00043 #include "MT_Tuple4.h"
00044 
00045 #include "RAS_IPolygonMaterial.h"
00046 
00047 #include "KX_Scene.h"
00048 
00049 struct Material;
00050 struct Scene;
00051 class BL_Material;
00052 
00053 #define BL_MAX_ATTRIB   16
00054 
00059 class BL_BlenderShader
00060 {
00061 private:
00062         KX_Scene                *mScene;
00063         struct Scene    *mBlenderScene;
00064         struct Material *mMat;
00065         int                             mLightLayer;
00066         int                             mBlendMode;
00067         GPUMaterial     *mGPUMat;
00068 
00069         bool                    VerifyShader() 
00070         {
00071                 return (NULL != mGPUMat);
00072         }
00073 
00074 public:
00075         BL_BlenderShader(KX_Scene *scene, struct Material *ma, int lightlayer);
00076         virtual ~BL_BlenderShader();
00077 
00078         bool                            Ok()
00079         {
00080                 // same as VerifyShared
00081                 return (NULL != mGPUMat);
00082         }
00083         void                            SetProg(bool enable, double time=0.0);
00084 
00085         int GetAttribNum();
00086         void SetAttribs(class RAS_IRasterizer* ras, const BL_Material *mat);
00087         void Update(const class RAS_MeshSlot & ms, class RAS_IRasterizer* rasty);
00088         void ReloadMaterial();
00089         int GetBlendMode();
00090 
00091         void SetScene(KX_Scene *scene)
00092         {
00093                 mScene = scene;
00094                 mBlenderScene = scene->GetBlenderScene();
00095                 ReloadMaterial();
00096         }
00097 
00098         bool Equals(BL_BlenderShader *blshader);
00099         
00100         
00101 #ifdef WITH_CXX_GUARDEDALLOC
00102 public:
00103         void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:BL_BlenderShader"); }
00104         void operator delete( void *mem ) { MEM_freeN(mem); }
00105 #endif
00106 };
00107 
00108 #endif//__BL_GPUSHADER_H__