File: TextureTest.m

package info (click to toggle)
psychtoolbox-3 3.0.14.20170103%2Bgit6-g605ff5c.dfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 103,044 kB
  • ctags: 69,483
  • sloc: ansic: 167,371; cpp: 11,232; objc: 4,708; sh: 1,875; python: 383; php: 344; makefile: 207; java: 113
file content (51 lines) | stat: -rw-r--r-- 1,386 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
% TextureTest
%
% Exercises the new Screen('DrawTexture') command in the OS X Psychtolbox 
% which replaces Screen('CopyWindow').   
%

% HISTORY
%  6/28/04    awi     wrote it.

% Tests which we make of textures:
%
%  That that after drawing a texture onto the screen that GetImage returns
%  the identical matrix


screenNumber=max(Screen('Screens'));
% Open and onscreen window on the second display 
w=Screen('OpenWindow',screenNumber, 0,[],32,2);

%make some textures out of matrices
gradientVector=[0:255];
gradientMat=repmat(gradientVector, 256, 1);
gradientMatColor=gradientMat;
gradientMatColor(:,:,2)=fliplr(gradientMat(:,:,1));
gradientMatColor(:,:,3)=gradientMat(:,:,1)';
gradientMatColorAlpha=gradientMatColor;
gradientMatColorAlpha(:,:,4)=ones(256) * 255;
angleMat=zeros(256);
angleMat(1:128,1)=255;
for im=1:256
    for in=1:256
        if im==in
            angleMat(im,in)=255;
        end
    end
end
tColor=Screen('MakeTexture', w, gradientMatColor);
tColorAlpha=Screen('MakeTexture', w, gradientMatColor);
a=Screen('MakeTexture', w, angleMat);
t=Screen('MakeTexture', w, gradientMat);

% See if drawing works at all
Screen('FillRect', w, 0);
Screen('FillRect', w, [255 0 0 255], [600 600 800 800]);

targetRect=RectOfMatrix(gradientMat);
Screen('DrawTexture', w, a, targetRect, OffsetRect(targetRect, 100, 100));
Screen('Flip', w);

WaitSecs(5);
Screen('CloseAll');