Hi Mario,
Thanks for trying out the glBindTexture command on multiple monitors.
Here is the relevant portion of the code.
Passing in argument 10 to the function will cause the error. Getting
rid of the glBindTexture command will make it compile.
David
function [] = Stereo_reduced(viewMode)
if(nargin() < 1)
viewMode = 9; %Default to red/blue anaglyph
end
% Is the script running in OpenGL Psychtoolbox?
AssertOpenGL;
InitializeMatlabOpenGL;
% Find the screen to use for display:
screenid=max(Screen('Screens'));
if viewMode == 10
% Yes. Do we have at least two separate displays for both views?
if length(Screen('Screens')) < 2
error('Sorry, for stereoMode 10 you''ll need at least 2
separate display screens in non-mirrored mode.');
end
if ~IsWin
% Assign left-eye view (the master window) to main display:
screenid = 0;
else
% Assign left-eye view (the master window) to main display:
screenid = 1;
end
end
ListenChar(2)
try
% Enable unified mode of KbName, so KbName accepts identical key
names on
% all operating systems:
KbName('UnifyKeyNames');
% Open a double-buffered full-screen window on the main displays
screen.
[windowPtr , winRect] = Screen('OpenWindow', screenid, 0, [], [],
[], viewMode, []);
if viewMode == 10
% In dual-window, dual-display mode, we open the slave window on
% the secondary screen. Please note that, after opening this
window
% with the same parameters as the "master-window", we won't touch
% it anymore until the end of the experiment. PTB will take
care of
% managing this window automatically as appropriate for a stereo
% display setup. That is why we are not even interested in the
window
% handles of this window:
if IsWin
slaveScreen = 2;
else
slaveScreen = 1;
end
Screen('OpenWindow', slaveScreen, 0, [], [], [], viewMode, []);
end
% Initially fill left- and right-eye image buffer with black
background
% color:
Screen('SelectStereoDrawBuffer', windowPtr, 0);
Screen('FillRect', windowPtr, BlackIndex(screenid));
Screen('SelectStereoDrawBuffer', windowPtr, 1);
Screen('FillRect', windowPtr, BlackIndex(screenid));
% Show cleared start screen:
Screen('Flip', windowPtr);
glActiveTexture(GL.TEXTURE1);
glTexEnvi(GL.TEXTURE_ENV, GL.TEXTURE_ENV_MODE, GL.MODULATE);
glActiveTexture(GL.TEXTURE0);
glTexEnvi(GL.TEXTURE_ENV, GL.TEXTURE_ENV_MODE, GL.MODULATE);
glClearDepth(1.0);
DEPTHTEXSIZE=1024;
depthtex_id=1;
for i=1:DEPTHTEXSIZE
texture(i)=10;
end
charimage=uint8(texture);
glBindTexture(GL.TEXTURE_1D, depthtex_id)
glTexImage1D(GL.TEXTURE_1D, 0, GL.LUMINANCE8,
DEPTHTEXSIZE, 0, GL.LUMINANCE, GL.UNSIGNED_BYTE, charimage)
glTexParameteri(GL.TEXTURE_1D,
GL.TEXTURE_MIN_FILTER, GL.LINEAR);
glTexParameteri(GL.TEXTURE_1D,
GL.TEXTURE_MAG_FILTER, GL.LINEAR);
glTexParameteri(GL.TEXTURE_1D, GL.TEXTURE_WRAP_S,
GL.CLAMP);
glActiveTexture(GL.TEXTURE1);
glTexEnvi(GL.TEXTURE_ENV, GL.TEXTURE_ENV_MODE, GL.MODULATE);
glActiveTexture(GL.TEXTURE0);
glTexEnvi(GL.TEXTURE_ENV, GL.TEXTURE_ENV_MODE, GL.MODULATE);
% Display loop: hit escape to exit
while (1)
[strInputName, x, y] = bvlWaitForInput(0.001);
if strcmp(strInputName, 'ESCAPE')
ListenChar(0);
break;
end
end
% Close onscreen window and release all other ressources:
Screen('CloseAll');
% Reenable Synctests after this simple demo:
Screen('Preference','SkipSyncTests',1);
% Well done!
%return
catch
% Executes in case of an error: Closes onscreen window:
Screen('CloseAll');
ListenChar(0);
psychrethrow(psychlasterror);
end;
--- In
psychtoolbox@yahoogroups.com, "Mario Kleiner"
<mario.kleiner@...> wrote:
>
> Please post all your relevant code up to the glBindTexture
> call. Adding a simple glBindTexture() doesn't cause any
> problem on my setup, so this should work.
>
> -mario
>
> --- In psychtoolbox@yahoogroups.com, "david_h514" <davem.hoffman@>
wrote:
> >
> > Hello,
> > I am trying to set up a haploscope using two CRT monitors. I have
> > been attempting to use the Stereo mode of Screen to handle the two
> > displays. I am rendering my stimuli with GL.
> >
> > The code works fine in anaglyph stereo and multi display stereo with
> > my scene of GL primitives.
> >
> > However, once I add a glBindTexture command after my Screen
> > ('OpenWindow') command, the program will only run in anaglyph mode.
> > When I try to run it in the multi-screen mode it says:
> >
> > ??? MOGL-Error: Your OpenGL command glBindTexture() caused the
> > following OpenGL error: invalid operation. Aborted.
> >
> > These are my Screen commands
> >
> > [windowPtr , winRect] = Screen('OpenWindow', screenid, 0, [], [], [],
> > viewMode, 0);
> >
> > if viewMode==10
> > Screen('OpenWindow', 1, 0, [], [], [], viewMode, 0);
> > end
> >
> > I've tried it on an intel-imac and an intel-MacPro, with the same
> > problem turning up on both setups.
> >
> > Does anyone know what might be wrong, or have some example code where
> > they bound textures on a multiple monitor setup?
> >
> > Thanks,
> > David
> >
>