GIR OpenGL {gir} | R Documentation |
For full details of OpenGL functions or constants, consult http://www.opengl.org
or your local man 3
pages.
NOT ALL FUNCTIONS HAVE BEEN BOUND. FIXME! See gl_funcs.r or gl_funcs.c for details.
You'll notice that GIR is not a 100% exact binding of OpenGL. This is due to the fact R is interpreted (so we can do things like detecting types and parameter lengths at runtime), and has a slightly different type structure to the C-style languages that OpenGL was written against (the default numeric type is double-precision floating-point; there are no bytes or shorts; also, no pointers).
Also, R's integers are always signed. Thus unsigned ints, where applicable, have to be represented as reals.
gl*ntv functions (e.g glVertex3fv) are replaced by gl*v functions taking an R vector (e.g glVertexv). The components of the vector can be real (double) or integer (or, in the case of glEdgeFlagv, boolean). Their types, and the length of the vector, determine which underlying gl function is called. Lengths that don't make sense (e.g <2 or >4 for glVertex) will cause errors. In cases where the argument a function takes is interpreted differently based on its type (a number of gl functions consider the largest representable value of an integral argument as 1.0, and the smallest as 0.0 or -1.0), and that type is not native to R, the original function (with the original suffix) is preserved.
glLightfv
, glLightiv
-> glLightv
glLightModelfv
, glLightModeliv
-> glLightModelv
glMaterialfv
, glMaterialiv
-> glMaterialv
glLoadMatrixf
, glLoadMatrixd
-> glLoadMatrix
glMultMatrixf
, glMultMatrixd
-> glMultMatrix
glNormal3dfis
-> glNormal3v
, glNormal3dv
, glNormal3fv
, glNormal3iv
, glNormal3sv
glVertex234dfis
-> glVertexv
, glVertexdv
, glVertexfv
, glVertexiv
, glVertexsv
glColor34dfubis
-> glColorv
, glColordv
, glColorfv
,
glColoriv
, glColorbv
, glColorsv
, glColorubv
,
glColoruiv
, glColorusv
glTexCoord1234dfis
-> glTexCoordv
, glTexCoordsv
glTexEnvfv
, glTexEnviv
-> glTexEnvv
glTexGendv
, glTexGenfv
, glTexGeniv
-> glTexGenv
glTexParameterfv
, glTexParameteriv
-> glTexParameterv
glFogfv
, glFogiv
-> glFogv
anything I've missed -> something hopefully sane
glGetBooleanv
, glGetDoublev
, glGetFloatv
, glGetIntegerv
:
Instead of accepting a pointer to an array in which to store their results,
they return a vector. Additionally, they take an extra parameter 'len',
which is the length of the array that the gl function expects (in booleans,
doubles, floats or ints, respectively).
If this is incorrect, unpleasant things will happen (heap corruption).
In this respect, it's just like in C. :)
glGetTexParameterfiv
, glGetTexLevelParameterfiv
:
In a similar fashion, these now do not accept a pointer, rather returning
their results as a vector. They don't need an extra 'len' parameter, though;
they're simple enough not to need it.
glGenTextures
:
Takes one less argument (textures
); returns the resulting texture names
in a vector of length n.
glDeleteTextures
:
Takes one less argument (n
); instead of requiring n to be specified, the
length of the textures vector is used.
All functions that require a packed array of bytes (glTexture
*, etc) must
be called with a 'raw' vector. girAsRaw
is a good way of getting one from
arbitrary data.