DrawTexture color behaving oddly

I'm having a strange issue: I'm not receiving any errors in the command window, but my textures aren't being fully filled in with the specified color.  Everything else works.

Here are the relevant lines of code: 

Screen('BlendFunction', MainWindow, 'GL_SRC_ALPHA', 'GL_ONE_MINUS_SRC_ALPHA');

rectWSP = 8.5; rectHSP = 50.5;

template   = Screen('MakeTexture', MainWindow, [0 0 rectWSP rectHSP]);
sourceRect = [0 0 rectWSP rectHSP];
stimRect   = [-rectWSP/2, -rectHSP/2, rectWSP/2, rectHSP/2]; 

rects(r,:) = CenterRectOnPoint(stimRect, centroid(1)-400+100*r, centroid(2)+200);

Screen('DrawTextures', MainWindow, template, sourceRect, rects(r,:), orientations(r), [], [], stimCol(1,:);


stimCol is set to, say, [0 250 100], but the textures then appear to be half green and half black (like this ).

I'm using OSX 10.7.2 with Java 1.6.0_29, and MATLAB 7.10.0 with PTB 3.0.9. Any help would be greatly appreciated!


- Nicole

--- In psychtoolbox@yahoogroups.com, "jardine_nl" <jardinenotsardine@...> wrote:
>
> Fixed -- instead of using MakeTexture to create the texture index, for some reason creating the texture index using OpenOffscreenWindow works.
> >

It is not clear why that should work either, because this ...

template = Screen('MakeTexture', MainWindow, [0 0 rectWSP rectHSP]);

... is wrong: You are converting an image into a texture which consists of four gray value pixels with the values 0, 0 , rectWSP and rectHSP. Your texture is a 4 pixel image with the gray values 0, 0, 8 and 50, so no surprise that half of your texture is black.

What you probably wanted was:

template = Screen('MakeTexture', MainWindow, 255 * ones(rectHSP, rectWSP));

or

template = Screen('OpenOffscreenwindow', MainWindow, 255, [0 0 rectWSP rectHSP]);

but rectWSP = 8.5; rectHSP = 50.5; is a no-go with fractional values in such a case.

I assume you use textures here instead of simple 'FillRect', because you want to rotate them by arbitrary angles? Otherwise 'FillRect' would be more simple.

-mario


> - Nicole
>
> --- In psychtoolbox@yahoogroups.com, "jardine_nl" <jardinenotsardine@> wrote:
> >
> > I'm having a strange issue: I'm not receiving any errors in the command
> > window, but my textures aren't being fully filled in with the specified
> > color. Everything else works.
> > Here are the relevant lines of code:
> >
> > Screen('BlendFunction', MainWindow, 'GL_SRC_ALPHA',
> > 'GL_ONE_MINUS_SRC_ALPHA');
> >
> > rectWSP = 8.5; rectHSP = 50.5;
> >
> > template = Screen('MakeTexture', MainWindow, [0 0 rectWSP rectHSP]);
> > sourceRect = [0 0 rectWSP rectHSP];
> > stimRect = [-rectWSP/2, -rectHSP/2, rectWSP/2, rectHSP/2];
> >
> >
> > rects(r,:) = CenterRectOnPoint(stimRect, centroid(1)-400+100*r,
> > centroid(2)+200);
> >
> >
> >
> > Screen('DrawTextures', MainWindow, template, sourceRect, rects(r,:),
> > orientations(r), [], [], stimCol(1,:);
> >
> >
> >
> >
> > stimCol is set to, say, [0 250 100], but the textures then appear to be
> > half green and half black (like this <http://imgur.com/rGajw> ).
> >
> > I'm using OSX 10.7.2 with Java 1.6.0_29, and MATLAB 7.10.0 with PTB
> > 3.0.9. Any help would be greatly appreciated!
> >
> >
> >
> >
> > - Nicole
> >
>