Python Reference Guide
 
Loading...
Searching...
No Matches
Samples\Video\VideoMemory.py
1# Copyright 2012 Autodesk, Inc. All rights reserved.
2# Use of this software is subject to the terms of the Autodesk license agreement
3# provided at the time of installation or download, or which otherwise accompanies
4# this software in either electronic or hard copy form.
5# ...
6# This scipt is to demonstrate the usage of FBVideoMemory.
7# ...
8#
9# Topic: FBMaterial, FBTexture, FBMaterialTextureType, FBVideoMemory, FBImage
10#
11
12from pyfbsdk import *
13from OpenGL import *
14from OpenGL.GL import *
15# pyOpenGL Library must be installed for this script to work
16
17# Create a cube
18lPlane = FBModelPlane("MyPlane")
19lPlane.Show = True
20# Move it around to let it fully visible in the viewport
21lPlane.Rotation = FBVector3d(90, 0, 0)
22lPlane.Translation = FBVector3d(0, 100, -200)
23# Create a material
24lMaterial = FBMaterial("MyMaterial")
25# Create a texture
26lTexture = FBTexture("MyTexture")
27# Set texture to material's diffuse channel.
28lMaterial.SetTexture(lTexture, FBMaterialTextureType.kFBMaterialTextureDiffuse)
29# Attach material to cube
30lPlane.Materials.append(lMaterial)
31
32# Create Image pixels data buffer
33lImageDim = 48
34lImageBits = OpenGL.images.createTargetArray(GL_RED, (lImageDim, lImageDim), GL_UNSIGNED_BYTE)
35for row in range(lImageDim):
36 for col in range(lImageDim):
37 pixelValue = int((row * col) * 1.0 / pow( lImageDim -1, 2.0) * 255.0);
38 lImageBits[row][col] = pixelValue
39
40# Create GL Texture and upload image data
41lGLTexIDs = glGenTextures(1)
42glBindTexture(GL_TEXTURE_2D, int(lGLTexIDs))
43glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR)
44glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR)
45glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, lImageDim, lImageDim, 0, GL_RED, GL_UNSIGNED_BYTE, lImageBits)
46glBindTexture(GL_TEXTURE_2D, 0)
47
48# Create FBVideoMemory
49lVideoMemory = FBVideoMemory("MyVideo")
50lVideoMemory.SetObjectImageSize(lImageDim, lImageDim)
51lVideoMemory.TextureOGLId = int(lGLTexIDs) #Set external OGL texture ID.
52
53# Connect VideoMemory to Texture
54lTexture.Video = lVideoMemory
55
56
Material class.
Definition: pyfbsdk_generated.h:10458
Plane model class.
Definition: pyfbsdk_generated.h:11944
See samples: HUDElements.py, MaterialAndTexture.py, TextureAnimation.py, VideoInput....
Definition: pyfbsdk_generated.h:19477
FBVideoMemory allow external media source (which can't be supported by MoBu natively) User could cr...
Definition: pyfbsdk_generated.h:21025
Python built-in int class.
Definition: pyfbsdk.h:59