| 455 | } |
| 456 | |
| 457 | TextureRef Textures::LoadCubeMapMipmapsHDR(const char* filename) { |
| 458 | TextureRef tex; |
| 459 | FILE* cache_file = my_fopen(filename, "rb"); |
| 460 | if (cache_file) { |
| 461 | int version; |
| 462 | fread(&version, sizeof(int), 1, cache_file); |
| 463 | if (version == kCubeMapHDRVersion) { |
| 464 | int size, width; |
| 465 | fread(&size, sizeof(int), 1, cache_file); |
| 466 | fread(&width, sizeof(int), 1, cache_file); |
| 467 | float* data = (float*)alloc.stack.Alloc(sizeof(float) * size); |
| 468 | fread(&data[0], sizeof(float), size, cache_file); |
| 469 | fclose(cache_file); |
| 470 | tex = Textures::Instance()->makeCubemapTexture(128, 128, GL_RGBA16F, GL_RGBA, Textures::MIPMAPS); |
| 471 | Textures::Instance()->SetTextureName(tex, filename); |
| 472 | int mip_level = 0; |
| 473 | int index = 0; |
| 474 | while (width > 1) { |
| 475 | for (int i = 0; i < 6; i++) { |
| 476 | glTexSubImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, mip_level, 0, 0, width, width, GL_BGRA, GL_FLOAT, &data[index]); |
| 477 | index += width * width * 4; |
| 478 | } |
| 479 | ++mip_level; |
| 480 | width /= 2; |
| 481 | } |
| 482 | alloc.stack.Free(data); |
| 483 | } |
| 484 | } |
| 485 | return tex; |
| 486 | } |
| 487 | |
| 488 | void Texture::Init() { |
| 489 | width = 0; |
nothing calls this directly
no test coverage detected