void texture4::loadImage( image &in )
    {
    jAssert( in.isValid() );

    if( img != 0 )
        {
        glDeleteTextures( 1, &img );
        }

    width = in.width();
    height = in.height();

    float *tempBuf = new float[ 4 * width * height ];

    glGenTextures( 1, &img );
    glBindTexture( GL_TEXTURE_2D, img );

    // select modulate to mix texture with color for shading
    glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE );

    glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
    glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
    glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
    glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );

    for( unsigned int y=0; y<height; y++ )
        {
        for( unsigned int x=0; x<width; x++ )
            {
            struct image::colourPacket *here = in.at( x, y );
            int base = 4 * ( x + y * width );
            tempBuf[ base ] = here->r;
            tempBuf[ base + 1 ] = here->g;
            tempBuf[ base + 2 ] = here->b;
            tempBuf[ base + 3 ] = here->a;
            }
        }


    glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_FLOAT, (const GLvoid *)tempBuf );

    delete [] tempBuf;
    }