Circular aperture

Hi

I have set up an openGL scene using psychtoolbox and I would like to visualize it through a circular aperture.
I looked around in the forums but I was unable to find what I want.
I also looked in some of the provided demos but didn't know how to integrate the code with my scene.

From what I encountered, there are 2 main methods: either using screen('fillOval'..) and blending or by copying the circular aperture over the stimuli using screen('CopyWindow'..)

I tried using both without success (the scene was seen through the usual rectangular aperture).

Could someone point me out the best of the two methods and tell me how to use it?

Thanks!
Thanks everyone for the help, it worked out fine.
For those interested in the details, here's my code:

Screen(win,'BlendFunction',GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
bColor = 255 ;
n = 1000 ; % size of matrix
R = 300 ; % radius
n2 = floor(n/2) ;
[x,y] = meshgrid(-n2:n2) ;
M = zeros(2*n2+1, 2*n2+1, 2);
M(:,:,2) = sqrt(x.^2 + y.^2) > R ; %disk formula
masktex = Screen('MakeTexture', win, M .* bColor);

And in the display loop, I used this:
Screen('DrawTexture', win, masktex);


--- In psychtoolbox@yahoogroups.com, "Mario" <mario.kleiner@...> wrote:
>
> The simple solution is to define and then Screen('DrawTexture') an alpha-mask texture with proper alpha-blending enabled after your Screen('EndOpengl') call when rendering the spheres is done and before the Screen('Flip'), like in AlphaImageDemo, as Jochen told you.
>
> A possibly more efficient but more difficult to implement solution would be to define a 3d occluder - a 3d plane with a hole in it and draw that in front of your virtual camera (properly aligned) or use stencil buffer testing. That way the gpu could discard spheres outside the aperture because they would be occluded by the aperture, thereby saving a bit of computation time.
>
> But i'd go for the first simple solution if it works out well enough.
> -mario
>
> --- In psychtoolbox@yahoogroups.com, "breidiroy" <breidiroy@> wrote:
> >
> > My scene is a bunch of spheres (maybe 10000 of them).
> >
> > I just need to look at these spheres from a circular aperture.
> >
> > Roy
> >
> > --- In psychtoolbox@yahoogroups.com, Peter Meilstrup <peter.meilstrup@> wrote:
> > >
> > > Depending how complicated your scene is, the easiest route might be to
> > > keep writing it in OpenGL and use the Z-buffer as a mask.
> > >
> > > Peter
> > >
> >
>