X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fbackends%2Fopengl%2Ftexture_backend.cpp;h=818defdd44c475a103b96adcf2ac20d8acb7f12e;hb=HEAD;hp=ba6486778ac04b67504360e136f4774353b50ff3;hpb=8e58fc4da8443cb67fe4cd70d6f68de2be73011d;p=libs%2Fgl.git diff --git a/source/backends/opengl/texture_backend.cpp b/source/backends/opengl/texture_backend.cpp index ba648677..818defdd 100644 --- a/source/backends/opengl/texture_backend.cpp +++ b/source/backends/opengl/texture_backend.cpp @@ -2,6 +2,7 @@ #include #include #include +#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);