# Drawing in textures is flipped vs. off screen windows.

**URL:** <https://psychtoolbox.discourse.group/t/drawing-in-textures-is-flipped-vs-off-screen-windows/1837>\
**Category:** Uncategorized\
**Created:** [June 11, 2007, 9:16am UTC](https://psychtoolbox.discourse.group/t/drawing-in-textures-is-flipped-vs-off-screen-windows/1837 "2007-06-11T09:16:40Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![empedia](https://avatars.discourse-cdn.com/v4/letter/e/e19adc/32.png) [@empedia](https://psychtoolbox.discourse.group/u/empedia)\
**Post date:** [June 11, 2007, 9:16am UTC](https://psychtoolbox.discourse.group/t/drawing-in-textures-is-flipped-vs-off-screen-windows/1837/1 "2007-06-11T09:16:40Z")

</div>

Hi,  
  
I am converting some PTB2 to PTB3 code and have come across a problem  
such that drawing into textures is flipped compared to drawing in off  
screen windows.  
  
The following code should illustrate the problem  
  
function test\_texture  
  
bgd = [127 127 127]; %background colour  
p = 2; %interval duration  
  
% Open window  
screencount=size(screen('screens'),2);  
if screencount\>1  
 screenRect=screen(1,'rect');  
else  
 screenRect=screen(0,'rect');  
end  
  
window = Screen(0, 'OpenWindow', bgd, screenRect, 32,2);  
Screen('TextFont', window, 'Arial');  
Screen('TextSize', window, 20);  
Screen('DrawText', window, 'Please wait...', screenRect(3)/2-100,  
screenRect(4)/2, 0);  
Screen('Flip', window);  
Screen('Flip',window,getsecs+2,1);   
  
%Using off screen window   
Screen('DrawText', window, 'OffScreen window ', screenRect(3)/2-100,  
screenRect(4)/2, 0);  
Screen('Flip', window);  
Screen('Flip',window,getsecs+2,1);  
offscrwin = Screen(window, 'OpenOffscreenWindow', bgd);  
Rect=CenterRect([0 0 300 300],screenRect);  
Screen('drawline',offscrwin,[255 0 0],Rect(1),Rect(2),Rect(3),Rect(4),1);  
  
Screen('drawtexture',window, offscrwin);%, window);  
Screen('Flip', window);  
Screen('Flip',window,getsecs+2,1);  
  
%Using draw texture  
Screen('DrawText', window, 'Draw Texture', screenRect(3)/2-100,  
screenRect(4)/2, 0);  
Screen('Flip', window);  
Screen('Flip',window,getsecs+2,1);  
Rect=CenterRect([0 0 300 300],screenRect);  
bgd\_texture=repmat(127,300,300);  
bgd=SCREEN('MakeTexture',window,bgd\_texture);  
Screen('drawline',bgd,[255 0 0],0,0,300,300,1);  
Screen('DrawTexture', window,bgd);  
Screen('Flip', window);  
Screen('Flip',window,getsecs+2,1);  
  
sca;  
  
Here I draw a diagonal line into both an off screen window and a  
texture - I would expect the same result when drawing on-screen  
however drawing into the texture results in a flip around the vertical  
axis.  
  
I realise that drawing into textures is not the most efficient process  
 and reading [http://psychtoolbox.org/wikka.php?wakka=FaqTextureWindow](http://psychtoolbox.org/wikka.php?wakka=FaqTextureWindow)  
implies that the texture is indeed flipped to "OpenGL row-major image  
format". However it implies also that "After creation, they are  
(nearly) synonymous."   
  
This clearly is not the case at least on my hardware - XP SP2 with  
Gforce 7600 (also verified on Gforce 6600).  
  
So unless I am missing something here is this a bug or by design and  
if so I think the Wiki should be updated to explicitly state this  
fundamental difference to avoid future confusion.  
  
Thanks,  
  
Matthew.
