]> git.tdb.fi Git - libs/gl.git/blob - source/backends/opengl/texture2dmultisample_backend.cpp
Move all OpenGL-specific code to a separate directory
[libs/gl.git] / source / backends / opengl / texture2dmultisample_backend.cpp
1 #include <msp/gl/extensions/arb_direct_state_access.h>
2 #include <msp/gl/extensions/arb_texture_multisample.h>
3 #include <msp/gl/extensions/arb_texture_storage_multisample.h>
4 #include "texture2dmultisample.h"
5 #include "texture2dmultisample_backend.h"
6
7 namespace Msp {
8 namespace GL {
9
10 OpenGLTexture2DMultisample::OpenGLTexture2DMultisample():
11         Texture(GL_TEXTURE_2D_MULTISAMPLE)
12 {
13         static Require _req(ARB_texture_multisample);
14 }
15
16 void OpenGLTexture2DMultisample::allocate()
17 {
18         unsigned width = static_cast<const Texture2DMultisample *>(this)->width;
19         unsigned height = static_cast<const Texture2DMultisample *>(this)->height;
20         unsigned samples = static_cast<const Texture2DMultisample *>(this)->samples;
21
22         GLenum gl_fmt = get_gl_pixelformat(storage_fmt);
23         if(ARB_texture_storage_multisample)
24         {
25                 if(ARB_direct_state_access)
26                         glTextureStorage2DMultisample(id, samples, gl_fmt, width, height, false);
27                 else
28                 {
29                         bind_scratch();
30                         glTexStorage2DMultisample(target, samples, gl_fmt, width, height, false);
31                 }
32         }
33         else
34         {
35                 bind_scratch();
36                 glTexImage2DMultisample(target, samples, gl_fmt, width, height, false);
37         }
38         apply_swizzle();
39 }
40
41 } // namespace GL
42 } // namespace Msp