]> git.tdb.fi Git - libs/gl.git/blobdiff - source/texturecube.cpp
Use libmspmath to provide vector and matrix operations
[libs/gl.git] / source / texturecube.cpp
index ddb0c1e05189113257d55d94656e1c4391fa3fa9..ef9d25297a4285c5ec630cd65e3237c6cddbf471 100644 (file)
@@ -1,6 +1,6 @@
+#include "arb_texture_cube_map.h"
 #include "bindable.h"
 #include "error.h"
-#include "extension.h"
 #include "texturecube.h"
 
 using namespace std;
@@ -23,7 +23,7 @@ TextureCube::TextureCube():
        size(0),
        allocated(0)
 {
-       static RequireVersion _ver(1, 3);
+       static Require _req(ARB_texture_cube_map);
 }
 
 void TextureCube::storage(PixelFormat fmt, unsigned sz)
@@ -32,6 +32,7 @@ void TextureCube::storage(PixelFormat fmt, unsigned sz)
                throw invalid_operation("TextureCube::storage");
        if(sz==0)
                throw invalid_argument("TextureCube::storage");
+       require_pixelformat(fmt);
 
        ifmt = fmt;
        size = sz;
@@ -53,7 +54,7 @@ void TextureCube::image(TextureCubeFace face, unsigned level, PixelFormat fmt, D
 
        unsigned s = get_level_size(level);
        if(s==0)
-               throw invalid_argument("TextureCube::image");
+               throw out_of_range("TextureCube::image");
 
        Bind _bind(this, true);
        glTexImage2D(face, level, ifmt, s, s, 0, fmt, type, data);
@@ -135,7 +136,7 @@ Vector3 TextureCube::get_texel_direction(TextureCubeFace face, unsigned u, unsig
        const Vector3 &fv = get_face_direction(face);
        const Vector3 &sv = get_s_direction(face);
        const Vector3 &tv = get_t_direction(face);
-       return Vector3(fv.x+s*sv.x, fv.y+t*tv.y, fv.z+s*sv.z+t*tv.z);
+       return fv+s*sv+t*tv;
 }
 
 } // namespace GL