#include <msp/gl/extensions/arb_texture_storage.h>
#include <msp/io/memory.h>
#include <msp/strings/format.h>
-#include "bindable.h"
#include "error.h"
#include "texturecube.h"
throw invalid_operation("TextureCube::allocate");
if(level>=levels)
throw invalid_argument("TextureCube::allocate");
- if(allocated&(64<<level))
- return;
bool direct = ARB_texture_storage && ARB_direct_state_access;
if(!direct)
void TextureCube::allocate_(unsigned level)
{
+ if(allocated&(64<<level))
+ return;
+
if(ARB_texture_storage)
{
+ GLenum fmt = get_gl_pixelformat(storage_fmt);
if(ARB_direct_state_access)
- glTextureStorage2D(id, levels, storage_fmt, size, size);
+ glTextureStorage2D(id, levels, fmt, size, size);
else
- glTexStorage2D(target, levels, storage_fmt, size, size);
+ glTexStorage2D(target, levels, fmt, size, size);
apply_swizzle();
allocated |= (64<<levels)-1;
}
}
unsigned lsz = get_level_size(level);
- PixelComponents comp = get_components(storage_fmt);
+ GLenum fmt = get_gl_pixelformat(storage_fmt);
+ GLenum comp = get_gl_components(get_components(storage_fmt));
GLenum type = get_gl_type(get_component_type(storage_fmt));
- glTexImage2D(face, level, storage_fmt, lsz, lsz, 0, comp, type, data);
+ glTexImage2D(face, level, fmt, lsz, lsz, 0, comp, type, data);
if(level==0)
{
{
for(unsigned i=0; i<6; ++i)
if(enumerate_faces(i)!=face)
- glTexImage2D(enumerate_faces(i), level, storage_fmt, lsz, lsz, 0, comp, type, 0);
+ glTexImage2D(enumerate_faces(i), level, fmt, lsz, lsz, 0, comp, type, 0);
allocated |= 64<<level;
}
allocate_(level);
- PixelComponents comp = get_components(storage_fmt);
+ GLenum comp = get_gl_components(get_components(storage_fmt));
GLenum type = get_gl_type(get_component_type(storage_fmt));
if(ARB_direct_state_access)
glTextureSubImage3D(id, level, x, y, get_face_index(face), wd, ht, 1, comp, type, data);