close all;
clear;
sca;
PsychDefaultSetup(2);
screens = Screen('Screens');
screenNumber = max(screens);
white = WhiteIndex(screenNumber);
black = BlackIndex(screenNumber);
grey = white / 2;
inc = white - grey;
[window, windowRect] = PsychImaging('OpenWindow', screenNumber, grey);
[screenXpixels, screenYpixels] = Screen('WindowSize', window);
ifi = Screen('GetFlipInterval', window);
[xCenter, yCenter] = RectCenter(windowRect);
Screen('BlendFunction', window, 'GL_SRC_ALPHA', 'GL_ONE_MINUS_SRC_ALPHA');
checkerboard = repmat(eye(2), 2, 2);
checkerTexture = Screen('MakeTexture', window, checkerboard);
yPos = yCenter;
xPos = linspace(screenXpixels * 0.2, screenXpixels * 0.8, 4);
[s1, s2] = size(checkerboard);
baseRect = [0 0 s1 s2] .* 50;
dstRects = nan(4, 4);
for i = 1:4
dstRects(:, i) = CenterRectOnPointd(baseRect, xPos(i), yPos);
end
colorMod = [1 1 1; 1 0 0; 0 1 0; 0 0 1]';
filterMode = 0;
angles = rand(1, 4) .* 360;
degPerFrame = 3;
topPriorityLevel = MaxPriority(window);
Priority(topPriorityLevel);
vbl = Screen('Flip', window);
waitframes = 1;
topPriorityLevel = MaxPriority(window);
Priority(topPriorityLevel);
while ~KbCheck
Screen('DrawTextures', window, checkerTexture, [], dstRects,...
angles, filterMode, [], colorMod);
vbl = Screen('Flip', window, vbl + (waitframes - 0.5) * ifi);
angles = angles + degPerFrame;
end
sca;