以下是我的代码:
import sys
import pygame
teapotList = None
def loadTexture(gambar):
textureSurface = pygame.image.load(gambar)\
...
def gambarMeja():
glDisable(GL_LIGHTING)
glEnable(GL_TEXTURE_2D)
glBindTexture(GL_TEXTURE_2D, loadTexture('Batik.jpg'))
glPushMatrix()
glTranslatef(15.0, 5.0, 1.0)
glRotatef(-15, 0, 1, 0)
glRotatef(20, 1, 0, 0)
glBegin(GL_QUADS)
..
def mejaTV():
gambarMeja()
def display():
..
mejaTV()
gambarLemari()
def keyboard(key, x, y):
if key == chr(27):
sys.exit()
# Main Loop
if __name__ == "__main__":
..
glutDisplayFunc(display)
glutKeyboardFunc(keyboard)
glutMainLoop()
我想用一个动作来改变我的照片
对于此代码:glBindTexture(GL_TEXTURE_2D, loadTexture('Batik.jpg'))
我想通过按p
按钮,通过键盘操作将图片更改为glBindTexture(GL_TEXTURE_2D, loadTexture('persona.jpg'))
。代码正在使用def keyboard(key, x, y):
你能帮我解决这个问题吗
OpenGL是一个状态引擎。状态会一直保持,直到再次更改为止
在globale命名空间中添加变量
tob_batik
、tob_persona
和tob_current
:在调用
glutMainLoop()
之前加载2个纹理根据按下的键(b或p)更改^{)
在
gambarMeja
中绑定tob_current
:相关问题 更多 >
编程相关推荐