Fixed a nasty bug in texture loading.

Signed-off-by: Xiaomao Chen <xiaomao5@live.com>