]> git.tdb.fi Git - libs/gl.git/blob - source/core/texture2dmultisample.cpp
Move all OpenGL-specific code to a separate directory
[libs/gl.git] / source / core / texture2dmultisample.cpp
1 #include "deviceinfo.h"
2 #include "error.h"
3 #include "texture2dmultisample.h"
4
5 using namespace std;
6
7 namespace Msp {
8 namespace GL {
9
10 Texture2DMultisample::Texture2DMultisample():
11         width(0),
12         height(0)
13 { }
14
15 void Texture2DMultisample::storage(PixelFormat fmt, unsigned wd, unsigned ht, unsigned sm)
16 {
17         if(width>0)
18         {
19                 if(fmt!=format || wd!=width || ht!=height || sm!=samples)
20                         throw incompatible_data("Texture2DMultisample::storage");
21                 return;
22         }
23         if(wd==0 || ht==0)
24                 throw invalid_argument("Texture2DMultisample::storage");
25         if(!sm || sm>DeviceInfo::get_global().limits.max_samples)
26                 throw invalid_argument("Texture2DMultisample::storage");
27
28         set_format(fmt);
29         width = wd;
30         height = ht;
31         samples = sm;
32
33         allocate();
34 }
35
36 void Texture2DMultisample::image(const Graphics::Image &, unsigned)
37 {
38         throw invalid_operation("Texture2DMultisample::image");
39 }
40
41 uint64_t Texture2DMultisample::get_data_size() const
42 {
43         return id ? width*height*get_pixel_size(format)*samples : 0;
44 }
45
46 } // namespace GL
47 } // namespace Msp