View Single Post
  #2  
Old 04-09-2009, 03:53 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Yes, you can copy the image data directly into an existing Vizard texture using the texture.setImageData() command. Here is a sample script:
Code:
import viz
import wx
viz.go()

def WXIMAGE_TO_TEXTURE(image,texture):
	"""Convert wxImage object to Vizard texture"""
	img = image.Mirror(False)
	tex.setImageData(img.GetData(),[img.GetWidth(),img.GetHeight()])

#Create wxImage from a bitmap
app = wx.PySimpleApp()
img = wx.Image('image.bmp')

#Create blank Vizard texture
tex = viz.addBlankTexture([1,1])

#Copy image to texture
WXIMAGE_TO_TEXTURE(img,tex)

#Create quad to display texture
quad = viz.addTexQuad(pos=(0,1.8,2),texture=tex)
Reply With Quote