|
23 | 23 | % Init the structure that will contain PTB setup |
24 | 24 | cfg = struct; |
25 | 25 |
|
26 | | - % Set some colors to be choosen as background |
27 | | - cfg.white = [255 255 255]; |
28 | | - cfg.black = [0 0 0]; |
29 | | - cfg.grey = mean([cfg.black; cfg.white]); |
30 | | - |
31 | 26 | % Set the PTB window background manually |
32 | | - cfg.backgroundColor = cfg.grey; |
| 27 | + cfg.color.background = [127 127 27]; |
33 | 28 |
|
34 | 29 | % Init PTB, see the Sub-Functions below |
35 | 30 | cfg = devSandbox_initPTB(cfg); |
|
40 | 35 | % ------------------------------------------------------------------------- |
41 | 36 |
|
42 | 37 | % Define black and white |
43 | | - white = WhiteIndex(cfg.screen); |
| 38 | + white = WhiteIndex(cfg.screen.idx); |
44 | 39 | grey = white / 2; |
45 | 40 | inc = white - grey; |
46 | 41 |
|
|
95 | 90 | mask(:, :, 2) = grating .* contrast; |
96 | 91 |
|
97 | 92 | % Make our grating mask texture |
98 | | - gratingMaskTex = Screen('MakeTexture', cfg.win, mask); |
| 93 | + gratingMaskTex = Screen('MakeTexture', cfg.screen.win, mask); |
99 | 94 |
|
100 | 95 | % Make a black and white noise mask half the size of our grating. This will |
101 | 96 | % be scaled upon drawing to make a "chunky" noise texture which our grating |
|
104 | 99 | noise = rand(round(visibleSize / 2)) .* white; |
105 | 100 |
|
106 | 101 | % Make our noise texture |
107 | | - noiseTexture = Screen('MakeTexture', cfg.win, noise); |
| 102 | + noiseTexture = Screen('MakeTexture', cfg.screen.win, noise); |
108 | 103 |
|
109 | 104 | % Make a destination rectangle for our textures and center this on the |
110 | 105 | % screen |
111 | 106 | dstRect = [0 0 visibleSize visibleSize]; |
112 | | - dstRect = CenterRect(dstRect, cfg.winRect); |
| 107 | + dstRect = CenterRect(dstRect, cfg.screen.winRect); |
113 | 108 |
|
114 | 109 | % Calculate the wait duration |
115 | | - waitDuration = waitframes * cfg.ifi; |
| 110 | + waitDuration = waitframes * cfg.screen.ifi; |
116 | 111 |
|
117 | 112 | % Recompute pixPerCycle, this time without the ceil() operation from above. |
118 | 113 | % Otherwise we will get wrong drift speed due to rounding errors |
|
123 | 118 | shiftPerFrame = cyclesPerSecond * pixPerCycle * waitDuration; |
124 | 119 |
|
125 | 120 | % Sync us to the vertical retrace |
126 | | - vbl = Screen('Flip', cfg.win); |
| 121 | + vbl = Screen('Flip', cfg.screen.win); |
127 | 122 |
|
128 | 123 | % Set the frame counter to zero, we need this to 'drift' our grating |
129 | 124 | frameCounter = 0; |
|
142 | 137 | srcRect = [xoffset 0 xoffset + visibleSize visibleSize]; |
143 | 138 |
|
144 | 139 | % Draw noise texture to the screen |
145 | | - Screen('DrawTexture', cfg.win, noiseTexture, [], dstRect, []); |
| 140 | + Screen('DrawTexture', cfg.screen.win, noiseTexture, [], dstRect, []); |
146 | 141 |
|
147 | 142 | % Draw grating mask |
148 | | - Screen('DrawTexture', cfg.win, gratingMaskTex, srcRect, dstRect, []); |
| 143 | + Screen('DrawTexture', cfg.screen.win, gratingMaskTex, srcRect, dstRect, []); |
149 | 144 |
|
150 | 145 | % Flip to the screen on the next vertical retrace |
151 | | - vbl = Screen('Flip', cfg.win, vbl + (waitframes - 0.5) * cfg.ifi); |
| 146 | + vbl = Screen('Flip', cfg.screen.win, vbl + (waitframes - 0.5) * cfg.screen.ifi); |
152 | 147 |
|
153 | 148 | end |
154 | 149 |
|
|
182 | 177 | PsychDefaultSetup(2); |
183 | 178 |
|
184 | 179 | % Get the screen numbers and draw to the external screen if avaliable |
185 | | - cfg.screen = max(Screen('Screens')); |
| 180 | + cfg.screen.idx = max(Screen('Screens')); |
186 | 181 |
|
187 | 182 | % Open an on screen window |
188 | | - [cfg.win, cfg.winRect] = Screen('OpenWindow', cfg.screen, cfg.backgroundColor); |
| 183 | + [cfg.screen.win, cfg.screen.winRect] = Screen('OpenWindow', cfg.screen.idx, cfg.color.background); |
189 | 184 |
|
190 | 185 | % Get the size of the on screen window |
191 | | - [cfg.winWidth, cfg.winHeight] = WindowSize(cfg.win); |
| 186 | + [cfg.screen.winWidth, cfg.screen.winHeight] = WindowSize(cfg.screen.win); |
192 | 187 |
|
193 | 188 | % Query the frame duration |
194 | | - cfg.ifi = Screen('GetFlipInterval', cfg.win); |
195 | | - |
196 | | - % Get the Center of the Screen |
197 | | - cfg.center = [cfg.winRect(3), cfg.winRect(4)] / 2; |
| 189 | + cfg.screen.ifi = Screen('GetFlipInterval', cfg.screen.win); |
198 | 190 |
|
199 | 191 | % Set up alpha-blending for smooth (anti-aliased) lines |
200 | | - Screen('BlendFunction', cfg.win, 'GL_SRC_ALPHA', 'GL_ONE_MINUS_SRC_ALPHA'); |
| 192 | + Screen('BlendFunction', cfg.screen.win, 'GL_SRC_ALPHA', 'GL_ONE_MINUS_SRC_ALPHA'); |
201 | 193 |
|
202 | 194 | end |
203 | 195 |
|
|
0 commit comments