- Image img("models/" + fileName);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, img.width(), img.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, img.data());
+
+ std::string path;
+ if (fileName.data[0] == '*') {
+ // embedded
+ int embIdx = atoi(&fileName.data[1]);
+ aiTexture *texture = scene.mTextures[embIdx];
+ if (texture->mHeight == 0) {
+ Image img((unsigned char*)texture->pcData, texture->mWidth, texture->achFormatHint);
+ glTexImage2D(GL_TEXTURE_2D, 0, img.internalFormat(), img.width(), img.height(), 0, img.format(), img.type(), img.data());
+ } else {
+ fprintf(stderr, "TODO: handle uncompressed embedded textures");
+ abort();
+ }
+ } else {
+ // not embedded
+ Image img("models/" + std::string(fileName.C_Str()));
+ glTexImage2D(GL_TEXTURE_2D, 0, img.internalFormat(), img.width(), img.height(), 0, img.format(), img.type(), img.data());
+ }
+
+ // magnifying - no bigger mipmap available, so use linear filtering
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ // minifying - use a linear blend of two mipmaps
+ // which are themselves filtered linearly
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
+
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
+