| 1855 | } |
| 1856 | |
| 1857 | unsigned int Textures::makeFlatCubemapArrayTextureInternal(int num_slices, int width, int height, GLint internal_format, GLint format, unsigned char flags) { |
| 1858 | unsigned which = AllocateFreeSlot(); |
| 1859 | |
| 1860 | Texture& texture = textures[which]; |
| 1861 | texture.Init(); |
| 1862 | texture.num_slices = num_slices; |
| 1863 | texture.width = width * 6; |
| 1864 | texture.height = height; |
| 1865 | texture.tex_target = GL_TEXTURE_2D_ARRAY; |
| 1866 | |
| 1867 | texture.format = format; |
| 1868 | texture.internal_format = internal_format; |
| 1869 | |
| 1870 | texture.use_srgb = (flags & PX_SRGB) != 0; |
| 1871 | texture.no_mipmap = (flags & PX_NOMIPMAP) != 0; |
| 1872 | texture.no_reduce = (flags & PX_NOREDUCE) != 0; |
| 1873 | |
| 1874 | CHECK_GL_ERROR(); |
| 1875 | glGenTextures(1, &texture.gl_texture_id); |
| 1876 | LOG_ASSERT(texture.gl_texture_id != INVALID_ID); |
| 1877 | LOG_ASSERT(texture.gl_texture_id != UNLOADED_ID); |
| 1878 | |
| 1879 | CHECK_GL_ERROR(); |
| 1880 | glBindTexture(texture.tex_target, texture.gl_texture_id); |
| 1881 | texture.wrap_s = m_wrap_s; |
| 1882 | texture.wrap_t = m_wrap_t; |
| 1883 | texture.min_filter = min_filter; |
| 1884 | texture.mag_filter = mag_filter; |
| 1885 | glTexParameteri(texture.tex_target, GL_TEXTURE_MIN_FILTER, texture.min_filter); |
| 1886 | glTexParameteri(texture.tex_target, GL_TEXTURE_MAG_FILTER, texture.mag_filter); |
| 1887 | glTexParameteri(texture.tex_target, GL_TEXTURE_WRAP_S, texture.wrap_s); |
| 1888 | glTexParameteri(texture.tex_target, GL_TEXTURE_WRAP_T, texture.wrap_t); |
| 1889 | CHECK_GL_ERROR(); |
| 1890 | std::vector<float> pixels(width * height * num_slices * 6 * 4, 0.0f); |
| 1891 | glTexImage3D(texture.tex_target, 0, internal_format, width * 6, height, num_slices, 0, format, GL_FLOAT, &pixels[0]); |
| 1892 | glGenerateMipmap(GL_TEXTURE_2D_ARRAY); |
| 1893 | CHECK_GL_ERROR(); |
| 1894 | |
| 1895 | RebindTexture(GetActiveTexture()); |
| 1896 | return which; |
| 1897 | } |
| 1898 | |
| 1899 | TextureRef Textures::getDetailColorArray() { |
| 1900 | PROFILED_TEXTURE_MUTEX_LOCK |