I can’t understand how to texture this pyramid in PyOpenGL. I tried to do everything according to the guides, but it turned out only to paint everything in one color, but I need to use png texture. My code is:
import pygame
from OpenGL import GL, GLU
verticies = (
(-1, -1, -1),
(-1, -1, 1),
(1, -1, 1),
(1, -1, -1),
(0, 1, 0),
)
edges = ((0, 1), (0, 3), (2, 3), (2, 1), (0, 4), (1, 4), (2, 4), (3, 4))
def Cube():
GL.glBegin(GL.GL_TRIANGLE_STRIP)
for edge in edges:
for vertex in edge:
GL.glVertex3fv(verticies[vertex])
GL.glEnd()
def main():
pygame.init()
display = (800, 600)
pygame.display.set_mode(display, pygame.DOUBLEBUF | pygame.OPENGL)
GLU.gluPerspective(45, (display[0] / display[1]), 0.1, 50)
GL.glTranslatef(0, 0, -5)
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
quit()
GL.glRotatef(1, 0, 1, 0)
GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT)
Cube()
pygame.display.flip()
pygame.time.wait(10)
main()
Can you explain how to do this?