View Full Version : Fastest way to load images on runtime, pyOpenGL

09 September 2006, 12:36 PM
Hey everyone

I'm not sure how many people hear are familair with python, pygame or pyOpenGl but hopefully you can help. The problem i have is with performance speed.
am working on some code at the moment where my program will be sent an image string and i then show it in a pyOpenGl window. This happens continuously . The code i have works but is very slow. The code i am currently using is

glBindTexture( GL_TEXTURE_2D, self.textures[i])
gluBuild2DMipmaps( GL_TEXTURE_2D, 4, 640, 480, GL_RGBA, GL_UNSIGNED_BYTE, self.image_strings[i])

At the moment the image width and height is not base 2 which is why i'm using mipmaps. Currently the back-end is not completed and can not send me a string. I am mimicking this by using an array of image strings (self.image_strings) untill it is ready.

After this code i call this to apply the texture


glBindTexture(GL_TEXTURE_2D, self.textures[self.frame])

if self.max_frame > 1:

self.frame = self.frame + self.direction
if self.frame == self.max_frame - 1 or self.frame == 0:
self.direction *= -1

glAlphaFunc( GL_GREATER, 0.15 )

glTexCoord2f(0.0, 0.0); glVertex3f(-1.0, -1.0, 0) # Bottom Left Of The Texture and Quad
glTexCoord2f(1.0, 0.0); glVertex3f( 1.0, -1.0, 0) # Bottom Right Of The Texture and Quad
glTexCoord2f(1.0, 1.0); glVertex3f( 1.0, 1.0, 0) # Top Right Of The Texture and Quad
glTexCoord2f(0.0, 1.0); glVertex3f(-1.0, 1.0, 0)

posting this right now i notice that i call glBindTexture twice; do i need to do this ( i will test it), and would it make a difference. From what i read the only way i can make this faster while still using mipmapping would be to create a thread for the load image so while it loads it won't stop the program, in some type of weired double buffering way.

Any help is appreciated

Thanks in advance

CGTalk Moderation
09 September 2006, 12:36 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.