File: AssertGLSL.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 (43 lines) | stat: -rw-r--r-- 1,516 bytes parent folder | download | duplicates (6)
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
function AssertGLSL
% AssertGLSL
%
% Break and issue an error message if the given combination of graphics
% hardware and graphics hardware driver does not support the OpenGL Shading
% Language (GLSL). This command needs to be executed after opening an
% onscreen window, because it needs a valid OpenGL context to work.
%
% HISTORY
% 3/29/06   mk     wrote it.
% 6/12/12   dn     findstr is deprecated, changed to strfind

persistent alreadycalled;
global GL
if isempty(GL)
    InitializeMatlabOpenGL([], [], 1);
end;

if isempty(alreadycalled)
    alreadycalled=1;
else
    return;
end;

try
    extensions = glGetString(GL.EXTENSIONS);
catch %#ok<*CTCH>
    error('AssertGLSL called before opening an Onscreen window! This will not work...');
end;

if isempty(extensions)
    error('AssertGLSL called before opening an Onscreen window! This will not work...');
end;

if isempty(strfind(extensions, 'GL_ARB_shading_language')) || isempty(strfind(extensions, 'GL_ARB_shader_objects'))
    Screen('CloseAll');
    error('Sorry, this M-File cannot execute on your combination of graphics hardware and driver due to complete lack of GLSL support.'); 
end;

if isempty(strfind(extensions, 'GL_ARB_fragment_shader'))
   fprintf('AssertGLSL: Warning! Your graphics hardware does not support fragment shaders. This will severely limit the use of GLSL.\n');
   fprintf('AssertGLSL: Many image processing functions will fail with MOGL errors about unsupported functions.\n');
end;