Frans,
I decided to go with this version instead:
------------------------------
w=Screen('OpenWindow', screenNumber);
sizeX=20;
sizeY=10;
for j = 1:800
posx = rand * 1024;
posy = rand * 786;
color = rand * 255;
Screen('FillRect', w, [color color color] ,[ posx posy posx+sizeX
posy+sizeY]);
end
imgtest = Screen('GetImage', w, [], 'backBuffer');
imgtexture = Screen('MakeTexture', w, imgtest);
....
...
sometimes later:
Screen('DrawTexture', w, imgtexture);
Screen('Flip', w );
------------------------------
this is due to the fact that I do some complicated calculations which
I need to do before the experiment. There's not enough time to
calculate this between each trial. I know that GetImage is
comparatively slow but I don't see any alternative to this.
Andreas
I decided to go with this version instead:
------------------------------
w=Screen('OpenWindow', screenNumber);
sizeX=20;
sizeY=10;
for j = 1:800
posx = rand * 1024;
posy = rand * 786;
color = rand * 255;
Screen('FillRect', w, [color color color] ,[ posx posy posx+sizeX
posy+sizeY]);
end
imgtest = Screen('GetImage', w, [], 'backBuffer');
imgtexture = Screen('MakeTexture', w, imgtest);
....
...
sometimes later:
Screen('DrawTexture', w, imgtexture);
Screen('Flip', w );
------------------------------
this is due to the fact that I do some complicated calculations which
I need to do before the experiment. There's not enough time to
calculate this between each trial. I know that GetImage is
comparatively slow but I don't see any alternative to this.
Andreas
On 1/20/07, Frans Cornelissen <f.w.cornelissen@...> wrote:
>
> Andreas,
>
> There is no real problem here, and for this you do not even need to invoke
> the use of textures.
> In the OpenGL toolbox, nothing appears on screen until you issue a screen
> flip command
>
> So your bit of code could look like:
>
> Screen('FillRect', window, gray);
> [h,v]=WindowSize(window); % to make this somewhat resolution independent
> % create a screen with 800 items on it
> for j = 1:800
> posx = round(rand * h);
> posy = round(rand * v);
> ...
> ...
> Screen('FillRect', window, colorTarget ,[ posx posy posx+sizeX
> posy+sizeY]);
> end
>
> Screen('Flip', window); % show rectangles on screen
>
> So, in fact it is simpler.
> Of course, the above assumes there is enough time to do this (i.e. you don't
> need to
> do a new screen every frame at very high refresh).
>
> You could also take a look at dotdemo.m in the PsychDemo folder, which shows
> a way of drawing many dots (of different sizes) using one Screen Drawdots
> command.
>
>
> Gr.
> Frans
>
>
>
>
>
>
> btw: about the whole think in textures problem. I really need to
> create my displays before the experiment. my display contains of maybe
> up to 800 rects so I rather compute everything before the experiment:
>
> BigScreens(i) = Screen(window,'OpenOffscreenWindow');
> Screen(BigScreens(i),'FillRect', gray);
>
> % create a screen with 800 items on it
> for j = 1:800
>
> posx = rand * 1024;
> posy = rand * 786;
> ...
> ...
> Screen(BigScreens(i),'FillRect', colorTarget ,[ posx
> posy
> posx+sizeX posy+sizeY]);
> end
>