|
setUniform4fsetUniform4f(name, fx,fy,fz, fw)Used to pass four float values from the main program to the vertex or fragment program.name: Type:
string
fx:Type: float
fy:Type: float
fz:Type: float
fw:Type: float
Sample Code# define the main part of the programdef main():# get the current scenescene = GameLogic.getCurrentScene()# get a list of the objects in the sceneobjList = scene.objects# Get the object you want to useobj = objList['OBCube']# Only one mesh on Cubemesh = obj.meshes[0]# only one material on meshmat = mesh.materials[0]# Using Blender GLSL Materials or Blender Multitexture Materials?if hasattr( mat, 'getMaterialIndex') == True:#Get shader envelopeshader = mat.getShader()# shader envelope created?if shader != None:# set the shadershader.setSource(VertexShader, FragmentShader, True)# pass vec4 float variable to shadershader.setUniform4f("RedGreenBlueAlpha", 0.0, 1.0, 0.0, 1.0)####### end of main program def# Import OpenGL code as a stringVertexProgram = """ |