Camera
or AW
objects. Instead, we will need the PIL
Python module (make sure you have this installed on your computer, it
may be called Pillow
, e.g., py27-Pillow
.
Using PIL
, we will
aw.py
or camera.py
modules.
gldraw.py
from camera import Camera
from aw import AW
and replace them with
from PIL import Image
global rotating
global x_angle, x_delta
global y_angle, y_delta
global prev_x, prev_y
global camera
global aw
and replace them with
global texName
Initialize texName = None
in the main()
function (remember it is a global
).
init()
function
global texName
and set it via
texName = glGenTextures(1)
PIL
# read in texture
img = Image.open("mandrill.png").rotate(180).transpose(Image.FLIP_LEFT_RIGHT)
(imw, imh) = img.size
# map texture
glBindTexture(GL_TEXTURE_2D,texName)
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_CLAMP)
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_CLAMP)
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST)
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST)
# target, level, internalFormat, img.w, img.h, border, format, type, texels
glTexImage2D(GL_TEXTURE_2D,
0,
GL_RGBA,
imw,imh,
0,
GL_RGBA,
GL_UNSIGNED_BYTE,
img.convert("RGBA").tobytes())
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE)
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
glEnable(GL_BLEND)
glEnable(GL_TEXTURE_2D)
display()
function
gluPerspective(65.0, 1.0, 1.0, 1000.0)
to
w = glutGet(GLUT_WINDOW_WIDTH)
h = glutGet(GLUT_WINDOW_HEIGHT)
gluOrtho2D(0.0,w,0.0,h)
# render
glBegin(GL_QUADS)
glTexCoord2f(0,0)
glVertex2i(0,0)
glTexCoord2f(1,0)
glVertex2i(w,0)
glTexCoord2f(1,1)
glVertex2i(w,h)
glTexCoord2f(0,1)
glVertex2i(0,h)
glEnd()
aw
, camera
. Those
should all be removed.
tar.gz
archive of your asg##/ directory, including:
README
file containing
.py
source)
handin
web page