I am having timing issues with my experiment, I am trying to implement an SSVEP speller with flashing boxes. At each frame I implement the following code that creates the rectangle with the specified color and I use to "DrawText" to indicate the text of letters. However, when I do so, the number of missed flips is very high (above 90%), when I removed all text drawing the performance is normal and very good (around 1%).
I am using window 7 64 bits, with Matlab 2017b, Psychtoolbox-3, I have installed Gstreamer.
My question is how can I correctly display text without performance issues? I tried both DrawText and DrawFormattedText but there is no change. I tried to save the letters into a texture and load the texture but I am not sure how to display the text and draw boxes on top of it with both of them appearing.
Thanks a lot.
function all_rects = create_rects(char_struct,window,drawing_colors,drawing_color_index,black,cue,text_texture)
penWidthPixels = 2;
Screen('TextFont', window, 'Courier New');
Screen('TextSize', window, 15);
num_targets = length(char_struct);
all_rects = nan(4,num_targets);
for i=1:num_targets
baseRect = [0 0 char_struct(i).size(1) char_struct(i).size(2)];
all_rects(:,i) = CenterRectOnPointd(baseRect, char_struct(i).x_location, char_struct(i).y_location);
Screen('FillRect',window,reshape(drawing_colors(drawing_color_index(i)+1,:),[1,3]),all_rects(:,i));
if length(char_struct(i).text) > 1 && ~strcmp(char_struct(i).text,'SPACE')
Screen('DrawText',window, char_struct(i).text,char_struct(i).x_location-15, char_struct(i).y_location+3,0, 100)
elseif strcmp(char_struct(i).text,'SPACE')
Screen('DrawText',window,char_struct(i).text,char_struct(i).x_location-40,char_struct(i).y_location+3,0,100);
else
Screen('DrawText',window, char_struct(i).text,char_struct(i).x_location-5, char_struct(i).y_location+3,0, 100);
end
end
Screen('FrameRect', window, black, all_rects,penWidthPixels);
if cue ~=0
Screen('FrameRect', window, [255 0 0], all_rects(:,cue),penWidthPixels);
end
Screen('DrawingFinished', window);
The flipping is implemented in the main loop with:
vbl = Screen('Flip', window,vbl + 0.5 * ifi);