File: FloatTexturePrecisionTest.m

package info (click to toggle)
psychtoolbox-3 3.0.19.14.dfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 86,796 kB
  • sloc: ansic: 176,245; cpp: 20,103; objc: 5,393; sh: 2,753; python: 1,397; php: 384; makefile: 193; java: 113
file content (53 lines) | stat: -rw-r--r-- 1,528 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
function FloatTexturePrecisionTest(imagingmode)
% 11 Bit ohne sign, 12 Bit mit sign.
AssertOpenGL;

screenid = max(Screen('Screens'));
imagingmode = 0;

% Open window, with or without imaging pipeline:
[win winRect]= Screen('OpenWindow', screenid, 255, [], [], [], [], [], imagingmode);

inimg = zeros(256, 256);
count = -2048 + 1/128000;
inc = 1/65535;

for x=1:256
    for y=1:256
        inimg(y,x) = count * inc;
        count = count + 1;
    end
end

minimum = min(min(inimg))
maximum = max(max(inimg))
imagesc(inimg);

% Build 16 bpc texture:
bpc16tex = Screen('MakeTexture', win, inimg, [], [], 1);

% Build 32 bpc reference texture:
bpc32tex = Screen('MakeTexture', win, inimg, [], [], 2);

% Load difference shader:
diffshader = LoadGLSLProgramFromFiles('ColorCodeDifferenceImageShader', 1);
diffoperator = Screen('OpenProxy', win);
Screen('HookFunction', diffoperator, 'AppendShader', 'UserDefinedBlit', 'Texture difference color coding operator', diffshader);
Screen('HookFunction', diffoperator, 'Enable', 'UserDefinedBlit');
glUseProgram(diffshader);
glUniform1i(glGetUniformLocation(diffshader, 'Image1'), 0);
glUniform1i(glGetUniformLocation(diffshader, 'Image2'), 1);
glUniform1f(glGetUniformLocation(diffshader, 'Delta'), inc/2);
glUseProgram(0);

difftex = Screen('TransformTexture', bpc16tex, diffoperator, bpc32tex);

x=15
Screen('DrawLine', difftex, [255 255 0], x, 0, x, 600);
Screen('DrawTexture', win, difftex, [], winRect, [], 0);

Screen('Flip', win);

while KbCheck; end;
KbWait;
Screen('CloseAll');