CBitmap is a class holding the bitmap data
texture[0] is a GLuint, a member of the file_3ds class
void file_3ds::LoadBMP(char * filename)
{
CBitmap *bmp = new CBitmap(filename);
glGenTextures(1, &texture[0]); // Create The Texture
// Typical Texture Generation Using Data From The Bitmap
glBindTexture(GL_TEXTURE_2D, texture[0]);
// Generate The Texture
glTexImage2D(GL_TEXTURE_2D, 0, 3, bmp->getWidth(), bmp->getHeight(), 0, GL_RGB, GL_UNSIGNED_BYTE, bmp->getData());
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); // Linear Filtering
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); // Linear Filtering
delete bmp;
}
My drawing code:
void file_3ds::render(void)
{
int i;
// glBegin and glEnd delimit the vertices that define a primitive (in our case triangles)
glBindTexture(GL_TEXTURE_2D, texture[0]);
glBegin(GL_TRIANGLES);
for (i = 0; i < object->polygons_qty ; i++)
{
glNormal3f(
object->face.norm[0],
object->face.norm[1],
object->face.norm[2]);
//ββββββ FIRST VERTEX ββββββ
// Normal of the first vertex
glNormal3fv (object->vertex[ object->face.a ].norm);
// Texture coordinates of the first vertex
glTexCoord2f( object->mapcoord[ object->face.a ].u,
object->mapcoord[ object->face.a ].v);
// Coordinates of the first vertex
glVertex3f( object->vertex[ object->face.a ].x,
object->vertex[ object->face.a ].y,
object->vertex[ object->face.a ].z); //Vertex definition
//ββββββ SECOND VERTEX ββββββ
// Normal of the first vertex
glNormal3fv (object->vertex[ object->face.b ].norm);
// Texture coordinates of the second vertex
glTexCoord2f( object->mapcoord[ object->face.b ].u,
object->mapcoord[ object->face.b ].v);
// Coordinates of the second vertex
glVertex3f( object->vertex[ object->face.b ].x,
object->vertex[ object->face.b ].y,
object->vertex[ object->face.b ].z);
//ββββββ THIRD VERTEX ββββββ
// Normal of the first vertex
glNormal3fv (object->vertex[ object->face.c ].norm);
// Texture coordinates of the third vertex
glTexCoord2f( object->mapcoord[ object->face.c ].u,
object->mapcoord[ object->face.c ].v);
// Coordinates of the Third vertex
glVertex3f( object->vertex[ object->face.c ].x,
object->vertex[ object->face.c ].y,
object->vertex[ object->face.c ].z);
}
glEnd();
}
</pre>
My problem:
I dont get a texture :''(
It meets all demands for textures, its 256x256 etc Its in the path blablabla. I simply dont get to see a texture on my model, and Im positive it has uv coordinates </i>