justingardner / mgl

A suite of mex/m files for displaying psychophysics stimuli
http://justingardner.net/mgl
Other
18 stars 22 forks source link

metal branch drawing with mglGluDisk and mglFixationCross #81

Closed austinchkuo closed 1 year ago

austinchkuo commented 1 year ago

On mgl2.0, calling mglGluDisk and mglFixationCross in some order draws a fixation cross and a disk in the proper order they are called. For example, calling mglGluDisk to draw a disk and then calling mglFixationCross to draw a cross will draw the cross on top of the disk, while calling mglFixationCross first will draw the cross under the disk.

%% mgl2.0
% draw a cross on top of a disk

myscreen.background = 'gray';
myscreen.displayName = 'test';
mglSetSID(-1)
myscreen = initScreen(myscreen)
mglGluDisk(0,0,2,0.2) % draw a dark circle in the center of the screen
mglFixationCross(7) % then draw a white cross that extends beyond the circle
mglFlush

% draw a disk on top of a cross

mglFixationCross(7)
mglGluDisk(0,0,2,0.2)
mglFlush

However, in mglMetal, the disk is always drawn on top of the cross no matter the order of the function calls.

%% mglMetal
% draw a cross on top of a disk (incorrect - results in disk on top of cross)

myscreen.background = 'gray';
myscreen = initScreen(myscreen)
mglGluDisk(0,0,2,0.2);
mglFixationCross(7);
mglFlush;

% draw a disk on top of a cross (still results in disk on top of cross, although now is expected behavior)

mglFixationCross(7);
mglGluDisk(0,0,2,0.2);
mglFlush;

A related type of issue is also clearly apparent when calling mglRetinotopy using mglMetal, where the fixation cross is obscured as soon as the task is started, while calling mglRetinotopy in mgl2.0 correctly displays the fixation cross on top of the retinotopy stimuli.

justingardner commented 1 year ago

This appears to have be an issue with the z coordinate setting for 2D vertices in different mgl functions = mglMetalDots had a setting of 0 and milLines2 had a setting of 1. Now, they both have the same setting of 0 and the ordering comes out as expected.