OpenGL ES doesn't accept DEPTH_COMPONENT together with BYTE types.
glDeleteTextures(1, &id);
}
+DataType Texture::get_alloc_type(PixelFormat fmt)
+{
+ return (fmt==DEPTH_COMPONENT ? UNSIGNED_SHORT : UNSIGNED_BYTE);
+}
+
void Texture::update_parameter(int mask) const
{
if(TexUnit::current().get_texture()!=this)
#define MSP_GL_TEXTURE_H_
#include <msp/datafile/objectloader.h>
+#include "datatype.h"
#include "gl.h"
+#include "pixelformat.h"
#include "predicate.h"
#include "resource.h"
~Texture();
protected:
+ static DataType get_alloc_type(PixelFormat);
+
void update_parameter(int) const;
public:
void set_min_filter(TextureFilter);
if(allocated&(1<<level))
return;
- image(level, get_base_pixelformat(ifmt), UNSIGNED_BYTE, 0);
+ PixelFormat base_fmt = get_base_pixelformat(ifmt);
+ image(level, base_fmt, get_alloc_type(base_fmt), 0);
}
void Texture1D::image(unsigned level, PixelFormat fmt, DataType type, const void *data)
#ifndef MSP_GL_TEXTURE1D_H_
#define MSP_GL_TEXTURE1D_H_
-#include "datatype.h"
-#include "pixelformat.h"
#include "texture.h"
namespace Msp {
if(allocated&(1<<level))
return;
- image(level, get_base_pixelformat(ifmt), UNSIGNED_BYTE, 0);
+ PixelFormat base_fmt = get_base_pixelformat(ifmt);
+ image(level, base_fmt, get_alloc_type(base_fmt), 0);
}
void Texture2D::image(unsigned level, PixelFormat fmt, DataType type, const void *data)
#include <string>
#include <msp/graphics/image.h>
-#include "datatype.h"
-#include "pixelformat.h"
#include "resource.h"
#include "texture.h"
if(allocated&(1<<level))
return;
- image(level, get_base_pixelformat(ifmt), UNSIGNED_BYTE, 0);
+ PixelFormat base_fmt = get_base_pixelformat(ifmt);
+ image(level, base_fmt, get_alloc_type(base_fmt), 0);
}
void Texture3D::image(unsigned level, PixelFormat fmt, DataType type, const void *data)
#define MSP_GL_TEXTURE3D_H_
#include <string>
-#include "datatype.h"
-#include "pixelformat.h"
#include "texture.h"
namespace Msp {
if(allocated&(1<<level))
return;
+ PixelFormat base_fmt = get_base_pixelformat(ifmt);
+ DataType type = get_alloc_type(base_fmt);
for(unsigned i=0; i<6; ++i)
- image(enumerate_faces(i), level, get_base_pixelformat(ifmt), UNSIGNED_BYTE, 0);
+ image(enumerate_faces(i), level, base_fmt, type, 0);
}
void TextureCube::image(TextureCubeFace face, unsigned level, PixelFormat fmt, DataType type, const void *data)
#define MSP_GL_TEXTURECUBE_H_
#include <msp/graphics/image.h>
-#include "datatype.h"
-#include "pixelformat.h"
#include "texture.h"
#include "vector.h"
#include <msp/gl/extensions/arb_texture_cube_map.h>