File: moglgetbuffer.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 (33 lines) | stat: -rw-r--r-- 1,174 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
function outmatrix = moglgetbuffer(ptr, mattype, nrbytes)
% outmatrix = moglgetbuffer(ptr, mattype, nrbytes) -- Copy content of buffer to matrix.
%
% This creates a matrix of type 'mattype' and size 'nrbytes' bytes and then
% copies the content of memory buffer 'ptr' into the matrix. The matrix is
% then returned. ptr needs to be a handle to a buffer previously created via
% ptr=moglmalloc() or ptr = moglcalloc(...). At most nrbytes are copied - if
% the source buffer is too small for nrbytes, only the amount is copied thats
% contained in the buffer.
%
% mattype can be currently one of:
% GL.DOUBLE - for double values, GL.UNSIGNED_INT - for 32 bit unsigned integers.
% GL.UNSIGNED_BYTE - for unsigned bytes, aka uint8 values.
%

% 16.05.2006 Written (MK)

% ---protected---

  if nargin < 1 || isempty(ptr)
     error('Missing required argument ptr.');
     end;

  if nargin < 2 || isempty(mattype)
     error('Missing required argument mattype.');
     end;

  if nargin < 3 || isempty(nrbytes) || nrbytes < 0
     error('Missing or invalid (negative) argument nrbytes.');
     end;

outmatrix = moglcore('moglcopybuffertomatrix', ptr, mattype, nrbytes);
return;