1 from pyglet
import font
,image
2 from pyglet
.gl
.gl
import *
4 from geom
import vector
6 class menuitem (object):
7 def __init__(self
,str,x
=0,y
=0):
9 self
.pos
= vector (x
,y
)
10 self
.bg
= image
.load('data/menuitem.png').texture
11 self
.is_highlighted
= False
13 self
.text
= font
.Text(font
.load('Arial',32),
21 glBindTexture (GL_TEXTURE_2D
, self
.bg
.id)
22 glTexParameteri (GL_TEXTURE_2D
, GL_TEXTURE_WRAP_T
, GL_CLAMP_TO_BORDER
)
23 glTexParameteri (GL_TEXTURE_2D
, GL_TEXTURE_WRAP_S
, GL_CLAMP_TO_BORDER
)
26 self
.is_highlighted
= True
29 def unhighlight(self
):
30 self
.is_highlighted
= False
34 glBindTexture (GL_TEXTURE_2D
, self
.bg
.id)
35 glBegin (GL_TRIANGLE_STRIP
)
37 glColor4d (0.0, 0.0, 1.0, self
.alpha
)
38 glTexCoord2d (self
.bg
.tex_coords
[0],
39 self
.bg
.tex_coords
[1])
40 glVertex2d (-self
.bg
.width
/ 2,
43 glTexCoord2d (self
.bg
.tex_coords
[3],
44 self
.bg
.tex_coords
[4])
45 glVertex2d ( self
.bg
.width
/ 2,
48 glTexCoord2d (self
.bg
.tex_coords
[9],
49 self
.bg
.tex_coords
[10])
50 glVertex2d (-self
.bg
.width
/ 2,
53 glTexCoord2d (self
.bg
.tex_coords
[6],
54 self
.bg
.tex_coords
[7])
55 glVertex2d ( self
.bg
.width
/ 2,