diff options
author | Erwin Coumans <blender@erwincoumans.com> | 2006-02-13 08:45:32 +0300 |
---|---|---|
committer | Erwin Coumans <blender@erwincoumans.com> | 2006-02-13 08:45:32 +0300 |
commit | e4790aef46f7ca0b4ab01c34f043be9e7b1fa7f1 (patch) | |
tree | 0d83145e454cc7b5947ec657dbd9e415aac9d809 /source/gameengine/Ketsji/BL_Shader.h | |
parent | 6c325d74f534d259820c2b2d94d5b73b3acf0a35 (diff) |
Improved OpenGL Shader Language support for game engine. The python interface is much simplified. Drawback is that scripts need to be updated next release. Testfiles:
http://www.continuousphysics.com/ftp/pub/test/index.php?dir=blender/&file=demos-2.42.zip
patch by Charlie Carley (snailrose @ elysiun.com)
Diffstat (limited to 'source/gameengine/Ketsji/BL_Shader.h')
-rw-r--r-- | source/gameengine/Ketsji/BL_Shader.h | 86 |
1 files changed, 70 insertions, 16 deletions
diff --git a/source/gameengine/Ketsji/BL_Shader.h b/source/gameengine/Ketsji/BL_Shader.h index 25db6a0b9f4..6536fdc8175 100644 --- a/source/gameengine/Ketsji/BL_Shader.h +++ b/source/gameengine/Ketsji/BL_Shader.h @@ -3,6 +3,13 @@ #include "PyObjectPlus.h" #include "BL_Material.h" +#include "BL_Texture.h" +// -- +#include "MT_Matrix4x4.h" +#include "MT_Matrix3x3.h" +#include "MT_Tuple2.h" +#include "MT_Tuple3.h" +#include "MT_Tuple4.h" // ----------------------------------- // user state management @@ -12,20 +19,26 @@ typedef struct uSampler int pass; int unit; int loc; - unsigned int glTexture; + BL_Texture* gl_texture; + int flag; }uSampler; #define SAMP_2D 1 #define SAMP_CUBE 2 +#define ATTRIBMAX 1 + +// uSampler::flag; +enum +{ + OWN=1 +}; // ---------------- class BL_Shader : public PyObjectPlus { Py_Header; private: - unsigned int mShader, - mVert, - mFrag; + unsigned int mShader; int mPass; bool mOk; bool mUse; @@ -33,14 +46,41 @@ private: char* vertProg; char* fragProg; bool mError; - char* mLog; + + int mAttr; + int mPreDefLoc; + int mPreDefType; + bool mDeleteTexture; bool LinkProgram(); - void PrintInfo( int len, unsigned int handle,int *num); public: BL_Shader(PyTypeObject *T=&Type); virtual ~BL_Shader(); + enum AttribTypes{ + SHD_TANGENT =1 + }; + + enum GenType { + MODELVIEWMATRIX, + MODELVIEWMATRIX_TRANSPOSE, + MODELVIEWMATRIX_INVERSE, + MODELVIEWMATRIX_INVERSETRANSPOSE, + + // Model matrix + MODELMATRIX, + MODELMATRIX_TRANSPOSE, + MODELMATRIX_INVERSE, + MODELMATRIX_INVERSETRANSPOSE, + + // View Matrix + VIEWMATRIX, + VIEWMATRIX_TRANSPOSE, + VIEWMATRIX_INVERSE, + VIEWMATRIX_INVERSETRANSPOSE, + CAM_POS + }; + char* GetVertPtr(); char* GetFragPtr(); void SetVertPtr( char *vert ); @@ -53,18 +93,28 @@ public: // --- // access const uSampler* getSampler(int i); - const bool Ok()const; + void SetSampler(int loc, int unit); + const bool Ok()const; unsigned int GetProg(); - unsigned int GetVertexShader(); - unsigned int GetFragmentShader(); - - void InitializeSampler( - int type, - int unit, - int pass, - unsigned int texture - ); + void SetProg(bool enable); + int GetAttribute(){return mAttr;}; + + void InitializeSampler( int type, int unit, int pass, BL_Texture* texture ); + + void Update( const class KX_MeshSlot & ms, class RAS_IRasterizer* rasty ); + + // form tuhopuu2 + virtual int GetAttribLocation(const STR_String& name); + virtual void BindAttribute(const STR_String& attr, int loc); + virtual int GetUniformLocation(const STR_String& name); + virtual void SetUniform(int uniform, const MT_Tuple2& vec); + virtual void SetUniform(int uniform, const MT_Tuple3& vec); + virtual void SetUniform(int uniform, const MT_Tuple4& vec); + virtual void SetUniform(int uniform, const unsigned int& val); + virtual void SetUniform(int uniform, const float& val); + virtual void SetUniform(int uniform, const MT_Matrix4x4& vec, bool transpose=false); + virtual void SetUniform(int uniform, const MT_Matrix3x3& vec, bool transpose=false); // ----------------------------------- // python interface @@ -94,6 +144,10 @@ public: KX_PYMETHOD_DOC( BL_Shader, setUniformMatrix4 ); KX_PYMETHOD_DOC( BL_Shader, setUniformMatrix3 ); + KX_PYMETHOD_DOC( BL_Shader, setUniformDef ); + + KX_PYMETHOD_DOC( BL_Shader, setAttrib ); + // these come from within the material buttons // sampler2d/samplerCube work KX_PYMETHOD_DOC( BL_Shader, setSampler); |