6
%memcpyCudaOpenGL(6, 1); % Be verbose.
7
%memcpyCudaOpenGL(5, 50); % Use 50 slots in LRU cache.
9
Screen('Preference','SkipSyncTests', 2);
10
PsychImaging('PrepareConfiguration');
11
%PsychImaging('AddTask', 'General', 'FloatingPoint32Bit');
12
w = PsychImaging('OpenWindow', 0, 0);
14
tex = ones(200, 200, 4);
16
% Read our beloved bunny image from filesystem:
17
bunnyimg = imread([PsychtoolboxRoot 'PsychDemos/konijntjes1024x768.jpg']);
18
bunnyimg(:,:,4) = 255;
20
% Maketexture in float precision with upright texture orientation:
21
bunnytex = Screen('MakeTexture', w, double(bunnyimg(:,:,1:2))/255, [], [], 2, 1);
23
bunre = Screen('Rect', bunnytex)
24
bunp = Screen('Pixelsize', bunnytex)
26
%bunnytex = Screen('Openoffscreenwindow', w, [1 1 0 0], [0 0 1024 768], 128);
27
%DrawFormattedText(bunnytex, 'HELLO WORLD!', 'center', 'center', [255 0 0]);
31
Screen('DrawTexture', w, t);
34
T = GPUTypeFromToGL(0, w, 2);
41
% Test high-level interface for pure mortals:
42
T = GPUTypeFromToGL(0, bunnytex, [], [], 0);
44
% Test low-level OpenGL object interface which does without any calls
45
% into Screen() -- Important for interop with non-ptb code and for use
46
% within imaging pipeline, ie., within Screen's execution context, as
47
% Screen is currently non-reentrant.
48
[texstruct.glhandle, texstruct.gltarget] = Screen('GetOpenGLTexture', w, t);
49
[texstruct.width, texstruct.height] = Screen('Windowsize', t);
50
texstruct.bpp = Screen('Pixelsize', t) / 8;
51
texstruct.nrchannels = 4;
52
T = GPUTypeFromToGL(0, texstruct, 1);
56
rect = Screen('Rect', t)
58
%T = GPUsingle(rand(1, 1024, 768));
66
H = T .* (0.5 + 0.5 * sin(GetSecs * 10));
68
t = GPUTypeFromToGL(1, H, 0, t, 0);
69
%ptr = GPUTypeFromToGL(6, t, 0);
70
%GPUTypeFromToGL(3, t, 0);
72
% t = GPUTypeFromToGL(1, H, 0, [], 1);
74
Screen('DrawTexture', w, t, [], [], [], 0);
76
GPUTypeFromToGL(1, H, 2, w);
78
Screen('Flip', w, 0, 2, 2);
81
Screen('DrawingFinished', w, 2, 1);
82
fps = c / (GetSecs - t0);
83
gbs = fps * 2 * numel(T) * 4 / 1024 / 1024 / 1024;
84
fprintf('FPS = %f [%f GB/sec]\n', fps, gbs);