+++ /dev/null
-#include "bindable.h"
-#include "error.h"
-#include "extension.h"
-#include "texturecube.h"
-
-using namespace std;
-
-namespace {
-
-// An array to facilitate looping through the cube faces
-Msp::GL::TextureCubeFace faces[6] =
-{
- Msp::GL::POSITIVE_X,
- Msp::GL::NEGATIVE_X,
- Msp::GL::POSITIVE_Y,
- Msp::GL::NEGATIVE_Y,
- Msp::GL::POSITIVE_Z,
- Msp::GL::NEGATIVE_Z
-};
-
-}
-
-
-namespace Msp {
-namespace GL {
-
-TextureCube::TextureCube():
- Texture(GL_TEXTURE_CUBE_MAP),
- size(0),
- allocated(0)
-{
- static RequireVersion _ver(1, 3);
-}
-
-void TextureCube::storage(PixelFormat fmt, unsigned sz)
-{
- if(size>0)
- throw invalid_operation("TextureCube::storage");
- if(sz==0)
- throw invalid_argument("TextureCube::storage");
-
- ifmt = fmt;
- size = sz;
-}
-
-void TextureCube::allocate(unsigned level)
-{
- if(allocated&(1<<level))
- return;
-
- for(unsigned i=0; i<6; ++i)
- image(faces[i], level, get_base_pixelformat(ifmt), UNSIGNED_BYTE, 0);
-}
-
-void TextureCube::image(TextureCubeFace face, unsigned level, PixelFormat fmt, DataType type, const void *data)
-{
- if(size==0)
- throw invalid_operation("TextureCube::image");
-
- unsigned s = get_level_size(level);
- if(s==0)
- throw invalid_argument("TextureCube::image");
-
- Bind _bind(this, true);
- glTexImage2D(face, level, ifmt, s, s, 0, fmt, type, data);
-
- // XXX Allocation should be tracked per-face, but we'll run out of bits
- allocated |= 1<<level;
- if(gen_mipmap && level==0)
- {
- for(; s; s>>=1, ++level) ;
- allocated |= (1<<level)-1;
- }
-}
-
-unsigned TextureCube::get_level_size(unsigned level)
-{
- return size>>level;
-}
-
-} // namespace GL
-} // namespace Msp