]> git.tdb.fi Git - libs/gl.git/blobdiff - source/backends/opengl/texture_backend.cpp
Check the flat qualifier from the correct member
[libs/gl.git] / source / backends / opengl / texture_backend.cpp
index ba6486778ac04b67504360e136f4774353b50ff3..818defdd44c475a103b96adcf2ac20d8acb7f12e 100644 (file)
@@ -2,6 +2,7 @@
 #include <msp/gl/extensions/arb_texture_swizzle.h>
 #include <msp/gl/extensions/ext_framebuffer_object.h>
 #include <msp/gl/extensions/khr_debug.h>
+#include "device.h"
 #include "gl.h"
 #include "error.h"
 #include "texture.h"
@@ -12,8 +13,6 @@ using namespace std;
 namespace Msp {
 namespace GL {
 
-OpenGLTexture *OpenGLTexture::scratch_binding = 0;
-
 OpenGLTexture::OpenGLTexture(unsigned t):
        target(t)
 {
@@ -25,9 +24,17 @@ OpenGLTexture::OpenGLTexture(unsigned t):
        }
 }
 
+OpenGLTexture::OpenGLTexture(OpenGLTexture &&other):
+       id(other.id),
+       target(other.target),
+       debug_name(move(other.debug_name))
+{
+       other.id = 0;
+}
+
 OpenGLTexture::~OpenGLTexture()
 {
-       if(this==scratch_binding)
+       if(this==Device::get_current().get_state().scratch_texture)
                unbind_scratch();
        if(id)
                glDeleteTextures(1, &id);
@@ -111,6 +118,7 @@ void OpenGLTexture::set_debug_name(const string &name)
 
 void OpenGLTexture::bind_scratch()
 {
+       const OpenGLTexture *&scratch_binding = Device::get_current().get_state().scratch_texture;
        if(!scratch_binding)
                glActiveTexture(GL_TEXTURE0);
        if(scratch_binding!=this)
@@ -124,6 +132,7 @@ void OpenGLTexture::bind_scratch()
 
 void OpenGLTexture::unbind_scratch()
 {
+       const OpenGLTexture *&scratch_binding = Device::get_current().get_state().scratch_texture;
        if(scratch_binding)
        {
                glBindTexture(scratch_binding->target, 0);