[docs]defget_texture_cube(self,dir_path,ext='png'):faces=['right','left','top','bottom']+['front','back'][::-1]# textures = [pg.image.load(dir_path + f'{face}.{ext}').convert() for face in faces]textures=[]forfaceinfaces:texture=pg.image.load(dir_path+f'{face}.{ext}').convert()iffacein['right','left','front','back']:texture=pg.transform.flip(texture,flip_x=True,flip_y=False)else:texture=pg.transform.flip(texture,flip_x=False,flip_y=True)textures.append(texture)size=textures[0].get_size()texture_cube=self.ctx.texture_cube(size=size,components=3,data=None)foriinrange(6):texture_data=pg.image.tostring(textures[i],'RGB')texture_cube.write(face=i,data=texture_data)returntexture_cube
[docs]defget_texture(self,path):# NOTE: Flip the texture along the Y-axis because PyGame has a downward Y-axistexture=pg.image.load(path).convert()texture=pg.transform.flip(texture,flip_x=False,flip_y=True)texture=self.ctx.texture(size=texture.get_size(),components=3,data=pg.image.tostring(texture,'RGB'))# Mipmappingtexture.filter=(mgl.LINEAR_MIPMAP_LINEAR,mgl.LINEAR)texture.build_mipmaps()# Anisotropic filteringtexture.anisotropy=32.0returntexture