This file is indexed.

/usr/share/psychtoolbox-3/PsychOpenGL/moglCreateFBO.m is in psychtoolbox-3-common 3.0.9+svn2579.dfsg1-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
function [fbo , texids] = moglCreateFBO(width, height, nrbuffers, layers, format, withdepth, withstencil)
% [fbo , texids] = moglCreateFBO(width, height [, nrbuffers, layers, format, withdepth, withstencil])
%
% moglCreateFBO creates a standard OpenGL Framebuffer Object, suitable for
% computer vision and other GPGPU tasks and returns a handle to it.
%
% The FBO will have a size of width x height pixels and its 'nrbuffers'
% color buffers will have textures with 'layers' layers (default = 4 for RGBA)
% attached.
% 'format' specifies the data format. It defaults to single precision
% floating point resolution (32 bit float). If 'withdepth' > 0 then a
% depth buffer gets attached as well. If 'withstencil' > 0 then a stencil
% drawable gets attached as well.
%
% The function will create appropriate textures and renderbuffers, create
% an appropriate FBO and attach the textures and renderbuffers. After
% validation, the handle to the FBO is returned.

% History:
% 30.05.2006 Wrote it. (MK)

global GL;

% Child protection:
AssertGLSL;

% Hack, needs to be improved...
if IsLinux
    % Redefine vor NVidia:
    GL.RGBA_FLOAT32_APPLE = hex2dec('8883');
end;

if nargin < 2
    error('Must specify a widht x height of FBO in CreateGLFBO!');
end;

if nargin < 3
    nrbuffers = 1;
end;

if isempty(nrbuffers)
    nrbuffers = 1;
end;

if nargin < 4
    layers = 4;
end;
if isempty(layers)
    layers = 4;
end;

if nargin < 5
    format = GL.RGBA_FLOAT32_APPLE;
end;
if isempty(format)
    format = GL.RGBA_FLOAT32_APPLE;
end;

if nargin < 6
    withdepth = 0;
end;
if isempty(withdepth)
    withdepth = 0;
end;

if nargin < 7
    withstencil = 0;
end;
if isempty(withstencil)
    withstencil = 0;
end;

if nrbuffers > glGetIntegerv(GL.MAX_COLOR_ATTACHMENTS_EXT)
    error('moglCreateFBO: Sorry this hardware does not support the requested number of color buffers.');
end;

% Enable 2D rectangle textures. Power-of-two textures are known to make
% trouble on many older gfx-cards...
glEnable(GL.TEXTURE_RECTANGLE_EXT);

% Generate texture objects:
texids=glGenTextures(nrbuffers);

% Create a framebuffer object:
fbo = glGenFramebuffersEXT(1);

% Bind fbo:
glBindFramebufferEXT(GL.FRAMEBUFFER_EXT, fbo);

% Create and attach textures as color buffer attachments:
for i=1:nrbuffers
    % Enable texture by binding it:
    glBindTexture(GL.TEXTURE_RECTANGLE_EXT,texids(i));

    % Create representation: A rectangle texture with only mipmap level zero
    % and without a border, single precision float, RGBA:
    glTexImage2D(GL.TEXTURE_RECTANGLE_EXT, 0, format, width, height, 0, GL.RGBA, GL.FLOAT, 0);

    % Setup texture wrapping behaviour to clamp, as other behaviours are
    % unsupported on many gfx-cards for rectangle textures:
    glTexParameterfv(GL.TEXTURE_RECTANGLE_EXT,GL.TEXTURE_WRAP_S,GL.CLAMP);
    glTexParameterfv(GL.TEXTURE_RECTANGLE_EXT,GL.TEXTURE_WRAP_T,GL.CLAMP);

    % Setup filtering for the textures - Use nearest neighbour as floating
    % point filtering usually unsupported.
    glTexParameterfv(GL.TEXTURE_RECTANGLE_EXT,GL.TEXTURE_MAG_FILTER,GL.NEAREST);
    glTexParameterfv(GL.TEXTURE_RECTANGLE_EXT,GL.TEXTURE_MIN_FILTER,GL.NEAREST);

    % Choose texture application function to be a neutral REPLACE:
    glTexEnvfv(GL.TEXTURE_ENV,GL.TEXTURE_ENV_MODE,GL.REPLACE);

    % Unbind it after setup:
    glBindTexture(GL.TEXTURE_RECTANGLE_EXT, 0);

    % Attach textures mipmap level zero as color buffer:
    glFramebufferTexture2DEXT(GL.FRAMEBUFFER_EXT, GL.COLOR_ATTACHMENT0_EXT + i - 1, GL.TEXTURE_RECTANGLE_EXT, texids(i), 0);    
end;
    
% Check if FBO is framebuffer complete:
fbostatus = glCheckFramebufferStatusEXT(GL.FRAMEBUFFER_EXT);
if not(fbostatus == GL.FRAMEBUFFER_COMPLETE_EXT)
    glDeleteFramebuffersEXT(1, fbo);
    glDeleteTextures(length(texids), texids);
    fprintf('Error code from framebuffer status call: %i\n', fbostatus);
    error('Failed to setup framebuffer object!');
    return;
end;
    
% Unbind it:
glBindFramebufferEXT(GL.FRAMEBUFFER_EXT, 0);

% Done. Return handle to FBO and texture:
return;