Commit bf250285 authored by H. Verbeet's avatar H. Verbeet Committed by Alexandre Julliard

wined3d: Restore texture bindings in the FBO code.

parent d6010ede
......@@ -5840,16 +5840,18 @@ static void set_depth_stencil_fbo(IWineD3DDevice *iface, IWineD3DSurface *depth_
if (depth_stencil_impl) {
GLenum texttarget, target;
GLint old_binding = 0;
IWineD3DSurface_PreLoad(depth_stencil);
texttarget = depth_stencil_impl->glDescription.target;
target = texttarget == GL_TEXTURE_2D ? GL_TEXTURE_2D : GL_TEXTURE_CUBE_MAP_ARB;
glGetIntegerv(texttarget == GL_TEXTURE_2D ? GL_TEXTURE_BINDING_2D : GL_TEXTURE_BINDING_CUBE_MAP_ARB, &old_binding);
glBindTexture(target, depth_stencil_impl->glDescription.textureName);
glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(target, GL_DEPTH_TEXTURE_MODE_ARB, GL_LUMINANCE);
glBindTexture(target, 0);
glBindTexture(target, old_binding);
GL_EXTCALL(glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, texttarget, depth_stencil_impl->glDescription.textureName, 0));
checkGLcall("glFramebufferTexture2DEXT()");
......@@ -5876,15 +5878,17 @@ static void set_render_target_fbo(IWineD3DDevice *iface, DWORD idx, IWineD3DSurf
if (rtimpl) {
GLenum texttarget, target;
GLint old_binding = 0;
IWineD3DSurface_PreLoad(render_target);
texttarget = rtimpl->glDescription.target;
target = texttarget == GL_TEXTURE_2D ? GL_TEXTURE_2D : GL_TEXTURE_CUBE_MAP_ARB;
glGetIntegerv(texttarget == GL_TEXTURE_2D ? GL_TEXTURE_BINDING_2D : GL_TEXTURE_BINDING_CUBE_MAP_ARB, &old_binding);
glBindTexture(target, rtimpl->glDescription.textureName);
glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glBindTexture(target, 0);
glBindTexture(target, old_binding);
GL_EXTCALL(glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT + idx, texttarget, rtimpl->glDescription.textureName, 0));
checkGLcall("glFramebufferTexture2DEXT()");
......
......@@ -1849,6 +1849,7 @@ static void check_fbo_status(IWineD3DDevice *iface) {
static void depth_blt(IWineD3DDevice *iface, GLuint texture) {
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
GLint old_binding = 0;
glPushAttrib(GL_ENABLE_BIT | GL_DEPTH_BUFFER_BIT);
......@@ -1860,6 +1861,7 @@ static void depth_blt(IWineD3DDevice *iface, GLuint texture) {
glDepthFunc(GL_ALWAYS);
GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB));
glGetIntegerv(GL_TEXTURE_BINDING_2D, &old_binding);
glBindTexture(GL_TEXTURE_2D, texture);
glEnable(GL_TEXTURE_2D);
......@@ -1872,6 +1874,8 @@ static void depth_blt(IWineD3DDevice *iface, GLuint texture) {
glVertex2f(1.0f, 1.0f);
glEnd();
glBindTexture(GL_TEXTURE_2D, old_binding);
glPopAttrib();
}
......@@ -1887,6 +1891,7 @@ static void depth_copy(IWineD3DDevice *iface) {
if (This->render_offscreen) {
static GLuint tmp_texture = 0;
GLint old_binding = 0;
TRACE("Copying onscreen depth buffer to offscreen surface\n");
......@@ -1897,6 +1902,7 @@ static void depth_copy(IWineD3DDevice *iface) {
/* Note that we use depth_blt here as well, rather than glCopyTexImage2D
* directly on the FBO texture. That's because we need to flip. */
GL_EXTCALL(glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0));
glGetIntegerv(GL_TEXTURE_BINDING_2D, &old_binding);
glBindTexture(GL_TEXTURE_2D, tmp_texture);
glCopyTexImage2D(depth_stencil->glDescription.target,
depth_stencil->glDescription.level,
......@@ -1909,6 +1915,7 @@ static void depth_copy(IWineD3DDevice *iface) {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_DEPTH_TEXTURE_MODE_ARB, GL_LUMINANCE);
glBindTexture(GL_TEXTURE_2D, old_binding);
GL_EXTCALL(glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, This->fbo));
checkGLcall("glBindFramebuffer()");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment