-
Notifications
You must be signed in to change notification settings - Fork 0
/
OpenWindow.m
68 lines (54 loc) · 2.07 KB
/
OpenWindow.m
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
function display = OpenWindow(display)
%display = OpenWindow([display])
%
%Calls the psychtoolbox command "Screen('OpenWindow') using the 'display'
%structure convention.
%
%Inputs:
% display A structure containing display information with fields:
% screenNum Screen Number (default is 0)
% bkColor Background color (default is black: [0,0,0])
% skipChecks Flag for skpping screen synchronization (default is 0, or don't check)
% When set to 1, vbl sync check will be skipped,
% along with the text and annoying visual (!) warning
%
%Outputs:
% display Same structure, but with additional fields filled in:
% windowPtr Pointer to window, as returned by 'Screen'
% frameRate Frame rate in Hz, as determined by Screen('GetFlipInterval')
% resolution [width,height] of screen in pixels
% center [x,y] center of screeen in pixels
%
%Note: for full functionality, the additional fields of 'display' should be
%filled in:
%
% dist distance of viewer from screen (cm)
% width width of screen (cm)
%Written 11/13/07 by gmb
% 9/17/09 gmb zre added the 'center' field in ouput of display structure.
if ~exist('display','var')
display.screenNum = 0;
end
if ~isfield(display,'screenNum')
display.screenNum = 0;
end
if ~isfield(display,'bkColor')
display.bkColor = [120,120,120]; %black
end
if ~isfield(display,'skipChecks')
display.skipChecks = 0;
end
if display.skipChecks
Screen('Preference', 'Verbosity', 0);
Screen('Preference', 'SkipSyncTests',1);
Screen('Preference', 'VisualDebugLevel',0);
end
Screen('Preference', 'SuppressAllWarnings', 1);
%Open the window
[display.windowPtr,res]=Screen('OpenWindow',display.screenNum,display.bkColor);
%Set the display parameters 'frameRate' and 'resolution'
display.frameRate = 1/Screen('GetFlipInterval',display.windowPtr); %Hz
if ~isfield(display,'resolution')
display.resolution = res([3,4]);
end
display.center = floor(display.resolution/2);