| 55 | |
| 56 | |
| 57 | def __createTexture(self, path): |
| 58 | texture_id = glGenTextures(1) |
| 59 | glBindTexture(GL_TEXTURE_CUBE_MAP, texture_id) |
| 60 | |
| 61 | for enum, texture_path in enumerate(("right.png", "left.png", "bottom.png", "top.png", "front.png", "back.png")): |
| 62 | full_path = os.path.join(path, texture_path) |
| 63 | |
| 64 | surface = pygame.image.load(full_path).convert() |
| 65 | surface_data = pygame.image.tostring(surface, "RGB", 1) |
| 66 | |
| 67 | width = surface.get_width() |
| 68 | height = surface.get_height() |
| 69 | |
| 70 | glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + enum, 0, GL_RGB8, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, surface_data) |
| 71 | |
| 72 | glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR) |
| 73 | glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR) |
| 74 | glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE) |
| 75 | glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE) |
| 76 | glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE) |
| 77 | |
| 78 | return texture_id |
| 79 | |
| 80 | |
| 81 | def getTexture(self): |