How do you crop an image and save them as 2 OpenGL textures in PyGame?
This is my code for loading a full image:
def loadImage(image):
img = pygame.image.load(image))
textureData = pygame.image.tostring(img, "RGBA", 1)
texture = glGenTextures(1)
glBindTexture(GL_TEXTURE_2D, texture)
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, img.get_width(), img.get_height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, textureData)
return texture
Is it possible to create textureData
with a cropped part of the image or can this be done with the OpenGL functions - I see that you could just replace img.get_height()
with img.get_height()/2
if you want, but you wouldn't be able to choose a rectangle that doesn't start at (0,0) by changing those 4th and 5th parameters.