| 1792 | } |
| 1793 | |
| 1794 | unsigned int Textures::makeCubemapArrayTextureInternal(int num_slices, int width, int height, GLint internal_format, GLint format, unsigned char flags) { |
| 1795 | unsigned which = AllocateFreeSlot(); |
| 1796 | |
| 1797 | Texture& texture = textures[which]; |
| 1798 | texture.Init(); |
| 1799 | texture.num_slices = num_slices; |
| 1800 | texture.cube_map = true; |
| 1801 | texture.width = width; |
| 1802 | texture.height = height; |
| 1803 | texture.tex_target = GL_TEXTURE_CUBE_MAP_ARRAY_ARB; |
| 1804 | |
| 1805 | texture.use_srgb = (flags & PX_SRGB) != 0; |
| 1806 | texture.no_mipmap = (flags & PX_NOMIPMAP) != 0; |
| 1807 | texture.no_reduce = (flags & PX_NOREDUCE) != 0; |
| 1808 | |
| 1809 | CHECK_GL_ERROR(); |
| 1810 | glGenTextures(1, &texture.gl_texture_id); |
| 1811 | LOG_ASSERT(texture.gl_texture_id != INVALID_ID); |
| 1812 | LOG_ASSERT(texture.gl_texture_id != UNLOADED_ID); |
| 1813 | |
| 1814 | CHECK_GL_ERROR(); |
| 1815 | glBindTexture(texture.tex_target, texture.gl_texture_id); |
| 1816 | if (texture.no_mipmap) { |
| 1817 | glTexParameteri(texture.tex_target, GL_TEXTURE_MIN_FILTER, GL_LINEAR); |
| 1818 | } else { |
| 1819 | glTexParameteri(texture.tex_target, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); |
| 1820 | } |
| 1821 | glTexParameteri(texture.tex_target, GL_TEXTURE_MAG_FILTER, GL_LINEAR); |
| 1822 | glTexParameteri(texture.tex_target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); |
| 1823 | glTexParameteri(texture.tex_target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
| 1824 | glTexParameteri(texture.tex_target, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE); |
| 1825 | CHECK_GL_ERROR(); |
| 1826 | int level = 0; |
| 1827 | std::vector<float> pixels(width * height * num_slices * 6 * 4); |
| 1828 | for (int i = 0, len = pixels.size(); i < len; i += 16) { |
| 1829 | pixels[i + 0] = 1.0f; |
| 1830 | pixels[i + 1] = 0.0f; |
| 1831 | pixels[i + 2] = 0.0f; |
| 1832 | pixels[i + 3] = 0.0f; |
| 1833 | |
| 1834 | pixels[i + 4] = 0.0f; |
| 1835 | pixels[i + 5] = 1.0f; |
| 1836 | pixels[i + 6] = 0.0f; |
| 1837 | pixels[i + 7] = 0.0f; |
| 1838 | |
| 1839 | pixels[i + 8] = 0.0f; |
| 1840 | pixels[i + 9] = 0.0f; |
| 1841 | pixels[i + 10] = 1.0f; |
| 1842 | pixels[i + 11] = 0.0f; |
| 1843 | |
| 1844 | pixels[i + 12] = 1.0f; |
| 1845 | pixels[i + 13] = 1.0f; |
| 1846 | pixels[i + 14] = 1.0f; |
| 1847 | pixels[i + 15] = 1.0f; |
| 1848 | } |
| 1849 | CHECK_GL_ERROR(); |
| 1850 | glTexImage3D(GL_TEXTURE_CUBE_MAP_ARRAY_ARB, level, internal_format, width, height, num_slices * 6, 0, format, GL_FLOAT, &pixels[0]); |
| 1851 | CHECK_GL_ERROR(); |