-
Notifications
You must be signed in to change notification settings - Fork 1
/
initialize3Screen.m
77 lines (60 loc) · 3.19 KB
/
initialize3Screen.m
1
function ScreenInfo = initializeScreen(WhichScreen)% gets the screen info% finds out the appropriate values for black, white, and gray% ScreenInfo = initializeScreen(WhichScreen);%% ScreenInfo = initializeScreen() with no arguments returns a fictitious/typical screen info%AssertOpenGL;InitializeMatlabOpenGL(1);if nargin<1 disp('Making a fictitious Screen structure'); % SK why do we need this? ScreenInfo.PixelSize = 0.0609; ScreenInfo.Xmax = 640; ScreenInfo.Ymax = 480; ScreenInfo.FrameRate = 124.8918; ScreenInfo.Dist = 64; returnend[ret, systemName] = system('hostname');ScreenInfo.whiteIndex = WhiteIndex(WhichScreen);ScreenInfo.blackIndex = BlackIndex(WhichScreen);ScreenInfo.grayIndex = round((ScreenInfo.whiteIndex+ScreenInfo.blackIndex)/2);% Make sure that on floating point framebuffers we still get a well defined grayif ScreenInfo.grayIndex == ScreenInfo.whiteIndex ScreenInfo.grayIndex = ScreenInfo.whiteIndex / 2;endScreenInfo.WhichScreen = WhichScreen;%ScreenInfo.PixelDepth = 8; % SK: what is this used for?Screen('CloseAll');WaitSecs(0.5);% the following line needs be enabled for proper linear superposition%[windowPtr, ScreenRect] = Screen('OpenWindow', WhichScreen, [], [], ScreenInfo.PixelDepth, [], [], [], kPsychNeed16BPCFloat);% SK [windowPtr, ScreenRect] = Screen('OpenWindow', WhichScreen, [], [], ScreenInfo.PixelDepth);% SK Screen('BlendFunction', windowPtr, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); % needed for alpha blending (LB 071019)% SK Screen('FillRect', windowPtr, gray); Screen('Flip', windowPtr); % force gray screen% Open a double buffered fullscreen window and set default background color to gray% [ScreenInfo.windowPtr, ScreenInfo.screenRect]=Screen('OpenWindow', WhichScreen, ScreenInfo.grayIndex);[ScreenInfo.windowPtr(1), ScreenInfo.screenRect(1,:)]=Screen('OpenWindow', WhichScreen, ScreenInfo.grayIndex, [0 0 750 600]);% [ScreenInfo.windowPtr(2), ScreenInfo.screenRect(2,:)]=Screen('OpenWindow', WhichScreen, ScreenInfo.grayIndex, [750 0 1650 600]);% [ScreenInfo.windowPtr(3), ScreenInfo.screenRect(3,:)]=Screen('OpenWindow', WhichScreen, ScreenInfo.grayIndex, [1650 0 2400 600]);% Enable alpha blendingScreen('BlendFunction', ScreenInfo.windowPtr(1), GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);ScreenInfo.Xmax = RectWidth(ScreenInfo.screenRect(1,:));ScreenInfo.Ymax = RectHeight(ScreenInfo.screenRect(1,:));ScreenInfo.FrameRate = FrameRate(WhichScreen);% make a linear Clut (do this even though you will do ltLoadCalibration later!!!)Screen('LoadNormalizedGammaTable', WhichScreen, repmat( (0:255)', 1, 3)/255);if ~isempty(strfind(systemName, 'zupervision')) ScreenInfo.MonitorType = 'SyncMaster 173s'; ScreenInfo.MonitorSize = 34; % cm - horizontal ScreenInfo.CalibrationDir = 'C:\Calibrations\'; else ScreenInfo.MonitorType = 'Unknown'; ScreenInfo.MonitorSize = 1; ScreenInfo.CalibrationDir = 'C:\Calibrations\';endScreenInfo.PixelSize = ScreenInfo.MonitorSize/ScreenInfo.Xmax; % size of pixeldisp(['You are using a ' ScreenInfo.MonitorType]);disp(['The refresh rate is ' num2str(ScreenInfo.FrameRate,'%3.3f') ' Hz']);fprintf('The resolution is %dx%d pixels.\n',ScreenInfo.Xmax, ScreenInfo.Ymax);