diff --git a/src/gl/textures/gl_hwtexture.cpp b/src/gl/textures/gl_hwtexture.cpp index 0ab9457fa4..855ae362f5 100644 --- a/src/gl/textures/gl_hwtexture.cpp +++ b/src/gl/textures/gl_hwtexture.cpp @@ -207,8 +207,6 @@ unsigned int FHardwareTexture::CreateTexture(unsigned char * buffer, int w, int } } // store the physical size. - texwidth = rw; - texheight = rh; int sourcetype; if (glTextureBytes > 0) @@ -467,14 +465,14 @@ void FHardwareTexture::UnbindAll() // //=========================================================================== -int FHardwareTexture::GetDepthBuffer() +int FHardwareTexture::GetDepthBuffer(int width, int height) { if (glDepthID == 0) { glGenRenderbuffers(1, &glDepthID); glBindRenderbuffer(GL_RENDERBUFFER, glDepthID); glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, - GetTexDimension(texwidth), GetTexDimension(texheight)); + GetTexDimension(width), GetTexDimension(height)); glBindRenderbuffer(GL_RENDERBUFFER, 0); } return glDepthID; @@ -487,10 +485,12 @@ int FHardwareTexture::GetDepthBuffer() // //=========================================================================== -void FHardwareTexture::BindToFrameBuffer() +void FHardwareTexture::BindToFrameBuffer(int width, int height) { + width = GetTexDimension(width); + height = GetTexDimension(height); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, glDefTex.glTexID, 0); - glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, GetDepthBuffer()); - glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, GetDepthBuffer()); + glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, GetDepthBuffer(width, height)); + glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, GetDepthBuffer(width, height)); } diff --git a/src/gl/textures/gl_hwtexture.h b/src/gl/textures/gl_hwtexture.h index 9dac63cbba..7ddcd27a41 100644 --- a/src/gl/textures/gl_hwtexture.h +++ b/src/gl/textures/gl_hwtexture.h @@ -60,7 +60,6 @@ public: private: - short texwidth = 0, texheight = 0; bool forcenocompression; TranslatedTexture glDefTex; @@ -71,7 +70,7 @@ private: TranslatedTexture * GetTexID(int translation); - int GetDepthBuffer(); + int GetDepthBuffer(int w, int h); void Resize(int swidth, int sheight, int width, int height, unsigned char *src_data, unsigned char *dst_data); public: @@ -81,7 +80,7 @@ public: static void Unbind(int texunit); static void UnbindAll(); - void BindToFrameBuffer(); + void BindToFrameBuffer(int w, int h); unsigned int Bind(int texunit, int translation, bool needmipmap); void AllocateBuffer(int w, int h, int texelsize); diff --git a/src/gl/textures/gl_material.cpp b/src/gl/textures/gl_material.cpp index be71fffd24..99a6f133af 100644 --- a/src/gl/textures/gl_material.cpp +++ b/src/gl/textures/gl_material.cpp @@ -207,6 +207,11 @@ const FHardwareTexture *FGLTexture::Bind(int texunit, int clampmode, int transla wt->GenTime[0] = screen->FrameTime; } } + else + { + w = tex->GetWidth(); + h = tex->GetHeight(); + } if (!hwtex->CreateTexture(buffer, w, h, texunit, needmipmap, translation, "FGLTexture.Bind")) { // could not create texture @@ -762,7 +767,7 @@ void FMaterial::BindToFrameBuffer() FHardwareTexture::Unbind(0); ClearLastTexture(); } - mBaseLayer->mHwTexture->BindToFrameBuffer(); + mBaseLayer->mHwTexture->BindToFrameBuffer(mWidth, mHeight); } //==========================================================================