Original Post
i am parsing an md2 file, and everything works fine, except texturing. on frame 0, the object is perfect. then after that frame, it turns green (green shaded texture). i think it might be something im doing with opengl (not model parsing - lighting?), but I've looked back on some specifications and tutorials, and can't see where im going wrong. Thanks for your time.
void InitGL()
{
glShadeModel(GL_SMOOTH);
glClearColor(0 , 0 , 0 , 0);
glClearDepth(40);
glEnable(GL_TEXTURE_2D);
glEnable(GL_DEPTH_TEST);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(60 , 800/600 , 1 , 200);
glMatrixMode(GL_MODELVIEW);
}
void LoadTexture(int texture_id , const char *tex)
{
SDL_Surface *texture = IMG_Load(tex);
if(texture)
{
/* create texture */
glGenTextures(1, &texture_id);
glBindTexture(GL_TEXTURE_2D, texture_id);
/* load in texture */
glTexImage2D( GL_TEXTURE_2D , 0 , 3 ,
texture->w , texture->h , 0 , GL_BGR,
GL_UNSIGNED_BYTE , texture->pixels);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
SDL_FreeSurface(texture);
}
else
{
cerr << "error : loading texture " << tex << "\n";
}
}
// when drawing model, using opengl commands
glBindTexture(GL_TEXTURE_2D, texture_id);
// ...