Blender V2.61 - r43446

BL_BlenderShader.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) Blender Foundation
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 __BL_GPUSHADER_H__
00033 #define __BL_GPUSHADER_H__
00034 
00035 #include "GPU_material.h"
00036 
00037 #include "MT_Matrix4x4.h"
00038 #include "MT_Matrix3x3.h"
00039 #include "MT_Tuple2.h"
00040 #include "MT_Tuple3.h"
00041 #include "MT_Tuple4.h"
00042 
00043 #include "RAS_IPolygonMaterial.h"
00044 
00045 #include "KX_Scene.h"
00046 
00047 struct Material;
00048 struct Scene;
00049 class BL_Material;
00050 
00051 #define BL_MAX_ATTRIB   16
00052 
00057 class BL_BlenderShader
00058 {
00059 private:
00060     KX_Scene        *mScene;
00061     struct Scene    *mBlenderScene;
00062     struct Material *mMat;
00063     int             mLightLayer;
00064     int             mAlphaBlend;
00065     GPUMaterial     *mGPUMat;
00066 
00067     bool            VerifyShader() 
00068     {
00069         return (NULL != mGPUMat);
00070     }
00071 
00072 public:
00073     BL_BlenderShader(KX_Scene *scene, struct Material *ma, int lightlayer);
00074     virtual ~BL_BlenderShader();
00075 
00076     bool                Ok()
00077     {
00078         // same as VerifyShared
00079         return (NULL != mGPUMat);
00080     }
00081     void                SetProg(bool enable, double time=0.0);
00082 
00083     int GetAttribNum();
00084     void SetAttribs(class RAS_IRasterizer* ras, const BL_Material *mat);
00085     void Update(const class RAS_MeshSlot & ms, class RAS_IRasterizer* rasty);
00086     void ReloadMaterial();
00087     int GetAlphaBlend();
00088 
00089     void SetScene(KX_Scene *scene)
00090     {
00091         mScene = scene;
00092         mBlenderScene = scene->GetBlenderScene();
00093         ReloadMaterial();
00094     }
00095 
00096     bool Equals(BL_BlenderShader *blshader);
00097     
00098     
00099 #ifdef WITH_CXX_GUARDEDALLOC
00100 public:
00101     void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:BL_BlenderShader"); }
00102     void operator delete( void *mem ) { MEM_freeN(mem); }
00103 #endif
00104 };
00105 
00106 #endif//__BL_GPUSHADER_H__