@@ -106,8 +106,9 @@ def init():
106
106
img2 = pygame .image .load ("images/back2.png" )
107
107
img2_rect = img .get_rect (center = (screen_size [0 ]/ 2 , screen_size [1 ]/ 2 ))
108
108
global screen
109
- screen = pygame .Surface (screen_size )
110
- screen .blit (img , img_rect )
109
+ screen = pygame .Surface (screen_size , SRCALPHA )
110
+ # screen.set_alpha(0)
111
+ # screen.blit(img, img_rect)
111
112
112
113
picture_exchange ()
113
114
@@ -129,8 +130,10 @@ def init():
129
130
130
131
global texLocation
131
132
texLocation = glGetUniformLocation (shaderProgram , "textureObj" )
133
+ light_angle = glGetUniformLocation (shaderProgram , "angle" )
132
134
glUseProgram (shaderProgram )
133
135
glUniform1i (texLocation , 0 )
136
+ glUniform1f (light_angle , 0 )
134
137
135
138
def clear (color = (0 , 0 , 0 )):
136
139
pygame .display .flip ()
@@ -143,7 +146,6 @@ def picture_exchange():
143
146
height = screen .get_height ()
144
147
glTexImage2D (GL_TEXTURE_2D , 0 , 3 , width , height , 0 , GL_RGB , GL_UNSIGNED_BYTE , textureData )
145
148
146
-
147
149
def render ():
148
150
picture_exchange ()
149
151
glDrawArrays (GL_QUADS , 0 , 4 )
@@ -169,6 +171,7 @@ def rotatewindow():
169
171
spd_collect = 0
170
172
angle_spd = 2
171
173
flip_spd = 10
174
+ move_spd = 0.1
172
175
quick_save = False
173
176
has_save = False
174
177
global save_matrix
@@ -225,7 +228,15 @@ def load_matrix_file():
225
228
elif e .key == pygame .K_x :
226
229
glRotatef (flip_spd , 0 , 0 , - 1 )
227
230
228
-
231
+ elif e .key == pygame .K_RIGHT :
232
+ glTranslatef (move_spd , 0 , 0 )
233
+ elif e .key == pygame .K_LEFT :
234
+ glTranslatef (- move_spd , 0 , 0 )
235
+ elif e .key == pygame .K_UP :
236
+ glTranslatef (0 , move_spd , 0 )
237
+ elif e .key == pygame .K_DOWN :
238
+ glTranslatef (0 , - move_spd , 0 )
239
+
229
240
elif e .key == pygame .K_0 :
230
241
if not (quick_save ):
231
242
glPushMatrix ()
@@ -241,7 +252,7 @@ def load_matrix_file():
241
252
elif e .key == pygame .K_3 :
242
253
if has_save :
243
254
glLoadMatrixf (save_matrix )
244
- has_save = False
255
+ # has_save = False
245
256
elif e .key == pygame .K_1 :
246
257
glLoadMatrixf (correct_matrix )
247
258
@@ -294,9 +305,6 @@ def load_matrix_file():
294
305
screen .blit (img , img_rect )
295
306
render ()
296
307
297
- # render()
298
- # clear()
299
-
300
308
if __name__ == '__main__' :
301
309
move = False
302
310
angle = 0
0 commit comments