Animation of Textures


 I was wondering if there's anybody who knows of a good way to animate textures.  I need to animate 6 (and only 6) different Quads with textures that are 1024 x 1024 in resolution.  That's pretty much anywhere from 150 to 180 frames per second at that resolution.  I have my program working now, but, it takes a few seconds to load new textures and it's too long to wait.  I need it to load within a second or two.  Any suggestions?

 Thanks ahead of time,
 Nathan Warden

Uploading a 1024x1024 texture to the GPU should be pretty fast. Are you using gluMipmap2D ? If so, that’s probably what’s slowing you down. You might want to pregenerate all the mipmaps in order to free the CPU.


… and probably switch to .dds would help

Originally posted by Nathan Warden:
I was wondering if there’s anybody who knows of a good way to animate textures. I need to animate 6 (and only 6) different Quads with textures that are 1024 x 1024 in resolution.
If your various textures are correlated (i.e. can be derived from each other), you could use a texture palette thro dependent textures, and just reload the palette texture (whose size is going to be relatively much smaller) everytime.

I appreciate all of the responses so far.

Reply to Ysaneya’s post,

I’m not MipMapping anything, actually, my panorama isn’t seemless unless I don’t mipmap. When I mipmap I get obvious seams at each edge.

Here’s a few things that might be the problem.

 A) I'm using a compressed format (JPEG)
 B) I'm using a library to load the Image Rep (but, I don't think this is a problem since it is one of my system libraries).

I agree that it’s pretty fast, but, right now I am loading 150 images into memory before I can animate the panorama for one second. Here are the specs:

 Resolution: 512 x 512
 Format: JPEG
 Size Per Image: ~164k
 Total Size of All: 25 MB

Now if I rendered these images at the resolution I want (1024 x 1024) then the Total size is increased to 100MB.

Does this sound like it is still feasible to implement in this manner?

Here’s my code for loading the texture:
It’s written in Cocoa,but, 95% of it should be easy to read:

  • (BOOL) loadBitmap:(NSString *)filename intoIndex:(int)texIndex
    BOOL success = FALSE;
    NSBitmapImageRep *theImage;
    int bitsPPixel, bytesPRow;
    unsigned char *theImageData;
    int rowNum, destRowNum;

    // Reads in the Image Data

    // This would be the same as writing like this in regular C++
    // theImage = NSBitmapImageRep.imageRepWithContentsOfFile(filename);

      theImage = [ NSBitmapImageRep imageRepWithContentsOfFile:filename ];

    if( theImage != nil )
    bitsPPixel = [ theImage bitsPerPixel ];
    bytesPRow = [ theImage bytesPerRow ];
    if( bitsPPixel == 24 ) // No alpha channel
    texFormat[ texIndex ] = GL_RGB;
    else if( bitsPPixel == 32 ) // There is an alpha channel
    texFormat[ texIndex ] = GL_RGBA;
    texSize[ texIndex ].width = [ theImage pixelsWide ];
    texSize[ texIndex ].height = [ theImage pixelsHigh ];
    texBytes[ texIndex ] = calloc( bytesPRow * texSize[ texIndex ].height,
    1 );
    if( texBytes[ texIndex ] != NULL )
    success = TRUE;
    theImageData = [ theImage bitmapData ];
    destRowNum = 0;
    for( rowNum = texSize[ texIndex ].height - 1; rowNum >= 0;
    rowNum–, destRowNum++ )
    // Copy the entire row in one shot
    memcpy( texBytes[ texIndex ] + ( destRowNum * bytesPRow ),
    theImageData + ( rowNum * bytesPRow ),
    bytesPRow );

    return success;