blender/source/gameengine/Ketsji/BL_Shader.h
Erwin Coumans 6f3e593105 more graphics patches from Snailrose,
remove constraint fixed,
Bullet timestep now subdivides Blender game engine timestep, so it runs 60 hertz,
SphereShape reverted to old style, so no support for non-uniform scaled spheres for now,
2006-01-15 11:34:55 +00:00

103 lines
2.3 KiB
C++

#ifndef __BL_SHADER_H__
#define __BL_SHADER_H__
#include "PyObjectPlus.h"
#include "BL_Material.h"
// -----------------------------------
// user state management
typedef struct uSampler
{
unsigned int type;
int pass;
int unit;
int loc;
unsigned int glTexture;
}uSampler;
#define SAMP_2D 1
#define SAMP_CUBE 2
// ----------------
class BL_Shader : public PyObjectPlus
{
Py_Header;
private:
unsigned int mShader,
mVert,
mFrag;
int mPass;
bool mOk;
bool mUse;
uSampler mSampler[MAXTEX];
char* vertProg;
char* fragProg;
bool LinkProgram();
bool PrintInfo(int len, unsigned int handle, const char *type);
public:
BL_Shader(PyTypeObject *T=&Type);
virtual ~BL_Shader();
char* GetVertPtr();
char* GetFragPtr();
void SetVertPtr( char *vert );
void SetFragPtr( char *frag );
// ---
int getNumPass() {return mPass;}
bool use() {return mUse;}
// ---
// access
const uSampler* getSampler(int i);
const bool Ok()const;
unsigned int GetProg();
unsigned int GetVertexShader();
unsigned int GetFragmentShader();
void InitializeSampler(
int type,
int unit,
int pass,
unsigned int texture
);
// -----------------------------------
// python interface
virtual PyObject* _getattr(const STR_String& attr);
KX_PYMETHOD_DOC( BL_Shader, setSource );
KX_PYMETHOD_DOC( BL_Shader, delSource );
KX_PYMETHOD_DOC( BL_Shader, getVertexProg );
KX_PYMETHOD_DOC( BL_Shader, getFragmentProg );
KX_PYMETHOD_DOC( BL_Shader, setNumberOfPasses );
// -----------------------------------
KX_PYMETHOD_DOC( BL_Shader, isValid);
KX_PYMETHOD_DOC( BL_Shader, validate);
KX_PYMETHOD_DOC( BL_Shader, setUniform4f );
KX_PYMETHOD_DOC( BL_Shader, setUniform3f );
KX_PYMETHOD_DOC( BL_Shader, setUniform2f );
KX_PYMETHOD_DOC( BL_Shader, setUniform1f );
KX_PYMETHOD_DOC( BL_Shader, setUniform4i );
KX_PYMETHOD_DOC( BL_Shader, setUniform3i );
KX_PYMETHOD_DOC( BL_Shader, setUniform2i );
KX_PYMETHOD_DOC( BL_Shader, setUniform1i );
KX_PYMETHOD_DOC( BL_Shader, setUniformfv );
KX_PYMETHOD_DOC( BL_Shader, setUniformiv );
KX_PYMETHOD_DOC( BL_Shader, setUniformMatrix4 );
KX_PYMETHOD_DOC( BL_Shader, setUniformMatrix3 );
// these come from within the material buttons
// sampler2d/samplerCube work
KX_PYMETHOD_DOC( BL_Shader, setSampler);
};
#endif//__BL_SHADER_H__