Index: OSGFBOViewport.cpp
===================================================================
RCS file: /cvsroot/opensg/OpenSG/Source/System/Window/OSGFBOViewport.cpp,v
retrieving revision 1.11
diff -u -r1.11 OSGFBOViewport.cpp
--- OSGFBOViewport.cpp	30 Aug 2007 16:03:43 -0000	1.11
+++ OSGFBOViewport.cpp	1 Sep 2007 18:23:48 -0000
@@ -884,22 +884,28 @@
                         // deactivate viewport settings
                         deactivate();
 
-                        win->validateGLObject(getTextures(0)->getGLId());
+			GLenum target;
+			// copy ALL attached textures.
+			// Most likely there's just one texture attached, the color
+			// buffer or the depth buffer. But in case both are attached, copy both!
+			for(UInt16 nt = 0; nt < getTextures().getSize(); nt++)
+		 	{
+                        	win->validateGLObject(getTextures(nt)->getGLId());
                         
-                        GLenum target = getTextures(0)->getTarget();
+                        	target = getTextures(nt)->getTarget();
                         
-                        // TODO; check if target is valid and allow usage of 3d texture slices
-                        if (target == GL_NONE)
-                            target = GL_TEXTURE_2D;
+                        	// TODO; check if target is valid and allow usage of 3d texture slices
+                        	if (target == GL_NONE)
+                            		target = GL_TEXTURE_2D;
                         
-                        glBindTexture(target, 
-                            win->getGLObjectId(getTextures(0)->getGLId()));
+                        	glBindTexture(target, 
+                            		win->getGLObjectId(getTextures(nt)->getGLId()));
                         
-                        glCopyTexSubImage2D(target, 0, x1, y1, 0, 0, tw, th);
-                        
-                        if (glGetError() != GL_NO_ERROR)
-                            SWARNING << "Error in Texture-Creation! " << endLog;    
+                        	glCopyTexSubImage2D(target, 0, x1, y1, 0, 0, tw, th);
                         
+                        	if (glGetError() != GL_NO_ERROR)
+                            		SWARNING << "Error in Texture-Creation! " << endLog;    
+                         }
                         glBindTexture(target, 0);
                     }
                 }
