I’ve downloaded a md2 model viewer, and added my own code to load the .tga texture for a model.
But somehow, all I get is a flat shading, nothing is textured.
This is what I do after I load it:
(md2Texture is a pointer to a Texture)
glGenTextures(1, &md2Texture->texID);
glBindTexture(GL_TEXTURE_2D, md2Texture->texID);
glTexImage2D(GL_TEXTURE_2D, 0, md2Texture->bpp / 8, md2Texture->width, md2Texture->height, 0, md2Texture->type, GL_UNSIGNED_BYTE, md2Texture->imageData);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
if (md2Texture->imageData)
{
free(md2Texture->imageData);
}
model->modelTex = md2Texture;
At the beginning of the program, this is the initialization:
glClearColor(0.6f, 0.6f, 0.6f, 0.5f);
glClearDepth(1.0f);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
glLightfv(GL_LIGHT1, GL_AMBIENT, LightAmbient);
glLightfv(GL_LIGHT1, GL_DIFFUSE, LightDiffuse);
glLightfv(GL_LIGHT1, GL_POSITION,LightPosition);
glEnable(GL_LIGHT1);
glEnable(GL_LIGHTING);
glEnable(GL_NORMALIZE);
glShadeModel(GL_FLAT);
Any help would be greatly appreciated, as I’ve been stuck here for a while
Thanks,
rabies