this script allows one to import a bitmap image and show it when the script is run. Who created it? I need to know what to change in order to allow for a 320x240 bitmap to be displayed properly. currently is only allows 256x256. The following is the original script. Any help would be wonderful. I just need to be pointed in the right direction. thank you…
import Blender
from Blender.BGL import *
global WinSize
# ||||||||||||||||||||||||||||||||||||||||||||||||||
# Most important! This is my OpenGL drawing routine...:)
def MyDraw():
global WinSize
glClearColor(.2,.1,.2,0)
glClear(GL_COLOR_BUFFER_BIT)
glGetFloatv(GL_SCISSOR_BOX,WinSize)
MyButton = Blender.Draw.Button('exit',20,20,120,50,50)
# Do the OpenGL drawing here...
glEnable(GL_TEXTURE_2D)
glBegin(GL_QUADS)
glTexCoord2f(1.0,1.0)
glColor3f(1.0,1.0,1.0)
glVertex2d(10,10)
glTexCoord2f(0.0,1.0)
glColor3f(1.0,1.0,1.0)
glVertex2d(WinSize[2],10)
glTexCoord2f(0.0,0.0)
glColor3f(1.0,1.0,1.0)
glVertex2d(WinSize[2],WinSize[3])
glTexCoord2f(1.0,0.0)
glColor3f(1.0,1.0,1.0)
glVertex2d(10,WinSize[3])
glEnd()
glDisable(GL_TEXTURE_2D)
# You have to use glEnable/glDisable because if you don't, you
# will draw into Blender's screen area too, it really messes it up!
# This keeps the texture drawing local to your object!
#''''''''''''''''''''''''''''''''''''''''''''''''
# Event function handlers
def MyEvent(eventnum,eventmod):
if eventnum == Blender.Draw.RIGHTMOUSE:
pass
if eventnum == Blender.Draw.MOUSEX:
pass
if eventnum == Blender.Draw.MOUSEY:
pass
if eventnum == Blender.Draw.LEFTMOUSE:
pass
def ButtonEvent(num):
if num == 20:
Blender.Draw.Exit()
#''''''''''''''''''''''''''''''''''''''''
#====================================
# load the bitmap file...into "memory"
bitfile = open('c:/program files/blender/test1.bmp','rb')
filedata = []
filedata = bitfile.read()
bitfile.close()
#====================================
# ---------------------------------------
# this is where the bits of the bitmap data are loaded
# into a Buffer object for passing to OpenGL
# NOTE: In a 24 bit bitmap or above, data always starts
# at offset Hex 36 - decimal 54.
filedata = filedata[54:]
texdata = []
for v in range(len(filedata)):
texdata.append(ord(filedata[v]))
# have to reverse the data in memory....
texdata.reverse()
texbuff = Buffer(GL_BYTE,len(filedata))
for v in range(len(filedata)):
texbuff[v] = texdata[v]
# ----------------------------------------
# ++++++++++++++++++++++++++++++++++++++++
# Set up the OpenGL texture parameters
glPixelStorei(GL_UNPACK_ALIGNMENT,1)
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_REPEAT)
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT)
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR)
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR)
glTexEnvf(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_MODULATE)
glTexImage2D(GL_TEXTURE_2D,0,GL_RGB,256,256,0,GL_RGB,GL_UNSIGNED_BYTE,texbuff)
# ++++++++++++++++++++++++++++++++++++++++
# image is in video mem. now, so we can delete it
# from our memory
del filedata
del texbuff
del texdata
# get the window size
WinSize = Buffer(GL_FLOAT,4)
glShadeModel(GL_SMOOTH)
Blender.Draw.Register(MyDraw,MyEvent,ButtonEvent)
thanks again
BaDbOyHeRe 8)