from pyfbsdk import *
from OpenGL import *
from OpenGL.GL import *
lPlane = FBModelPlane("MyPlane")
lPlane.Show = True
lPlane.Rotation = FBVector3d(90, 0, 0)
lPlane.Translation = FBVector3d(0, 100, -200)
lMaterial = FBMaterial("MyMaterial")
lTexture = FBTexture("MyTexture")
lMaterial.SetTexture(lTexture, FBMaterialTextureType.kFBMaterialTextureDiffuse)
lPlane.Materials.append(lMaterial)
lImageDim = 48
lImageBits = OpenGL.images.createTargetArray(GL_RED, (lImageDim, lImageDim), GL_UNSIGNED_BYTE)
for row in range(lImageDim):
for col in range(lImageDim):
pixelValue = int((row * col) * 1.0 / pow( lImageDim -1, 2.0) * 255.0);
lImageBits[row][col] = pixelValue
lGLTexIDs = glGenTextures(1)
glBindTexture(GL_TEXTURE_2D, int(lGLTexIDs))
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR)
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR)
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, lImageDim, lImageDim, 0, GL_RED, GL_UNSIGNED_BYTE, lImageBits)
glBindTexture(GL_TEXTURE_2D, 0)
lVideoMemory = FBVideoMemory("MyVideo")
lVideoMemory.SetObjectImageSize(lImageDim, lImageDim)
lVideoMemory.TextureOGLId = int(lGLTexIDs)
lTexture.Video = lVideoMemory