![]() |
ARX
1.0
The next-generation open source augmented reality toolkit.
|
#include <ARX/ARG/arg.h>
#include <string.h>
#include "arg_gl.h"
#include "arg_gl3.h"
#include "arg_gles2.h"
Functions | |
uint16_t | arglOpenGLVersion () |
ARGL_CONTEXT_SETTINGS_REF | arglSetupForCurrentContext (const ARParam *cparam, AR_PIXEL_FORMAT pixelFormat) |
Initialise the arg library for the current OpenGL context. More... | |
int | arglSetupDebugMode (ARGL_CONTEXT_SETTINGS_REF contextSettings, ARHandle *arHandle) |
Provide an ARHandle structure from which to extract information about debug mode. More... | |
void | arglCleanup (ARGL_CONTEXT_SETTINGS_REF contextSettings) |
Free memory used by arg associated with the specified context. More... | |
void | arglDispImage (ARGL_CONTEXT_SETTINGS_REF contextSettings, int32_t viewport[4]) |
Display an ARVideo image, by drawing it using OpenGL. More... | |
int | arglDistortionCompensationSet (ARGL_CONTEXT_SETTINGS_REF contextSettings, int enable) |
Set compensation for camera lens distortion in arglDispImage to off or on. More... | |
int | arglDistortionCompensationGet (ARGL_CONTEXT_SETTINGS_REF contextSettings, int *enable) |
Enquire as to the enable state of camera lens distortion compensation in arglDispImage. More... | |
int | arglSetPixelZoom (ARGL_CONTEXT_SETTINGS_REF contextSettings, float zoom) |
Set the current video image drawing scalefactor. More... | |
int | arglGetPixelZoom (ARGL_CONTEXT_SETTINGS_REF contextSettings, float *zoom) |
Retrieve the current video image drawing scalefactor. More... | |
int | arglPixelFormatSet (ARGL_CONTEXT_SETTINGS_REF contextSettings, AR_PIXEL_FORMAT format) |
Set the format of pixel data which will be passed to arglDispImage*() More... | |
int | arglPixelFormatGet (ARGL_CONTEXT_SETTINGS_REF contextSettings, AR_PIXEL_FORMAT *format, int *size) |
Get the format of pixel data in which arglDispImage*() is expecting data to be passed. More... | |
void | arglSetRotate90 (ARGL_CONTEXT_SETTINGS_REF contextSettings, int rotate90) |
Set or unset a 90 degree rotation in all OpenGL drawing performed by ARGL. More... | |
int | arglGetRotate90 (ARGL_CONTEXT_SETTINGS_REF contextSettings) |
Find out whether ARGL is rotating all OpenGL drawing by 90 degrees. More... | |
void | arglSetFlipH (ARGL_CONTEXT_SETTINGS_REF contextSettings, int flipH) |
int | arglGetFlipH (ARGL_CONTEXT_SETTINGS_REF contextSettings) |
void | arglSetFlipV (ARGL_CONTEXT_SETTINGS_REF contextSettings, int flipV) |
int | arglGetFlipV (ARGL_CONTEXT_SETTINGS_REF contextSettings) |
int | arglPixelBufferSizeSet (ARGL_CONTEXT_SETTINGS_REF contextSettings, int bufWidth, int bufHeight) |
Specify a desired pixel buffer size larger than the camera image size. More... | |
int | arglPixelBufferSizeGet (ARGL_CONTEXT_SETTINGS_REF contextSettings, int *bufWidth, int *bufHeight) |
Query the size of pixel data buffers expected by arglPixelBufferDataUpload(). More... | |
int | arglPixelBufferDataUploadBiPlanar (ARGL_CONTEXT_SETTINGS_REF contextSettings, ARUint8 *bufDataPtr0, ARUint8 *bufDataPtr1) |
Upload a buffer of pixel data to an OpenGL texture for later use by arglDispImage(). More... | |
int | arglGLCapabilityCheck (ARGL_CONTEXT_SETTINGS_REF contextSettings, const uint16_t minVersion, const unsigned char *extension) |
Checks for the presence of an OpenGL capability by version or extension. More... | |
void arglCleanup | ( | ARGL_CONTEXT_SETTINGS_REF | contextSettings | ) |
Free memory used by arg associated with the specified context.
Should be called after no more argl* functions are needed, in order to prevent memory leaks etc.
The library can be setup again for the context at a later time by calling arglSetupForCurrentContext() again.
contextSettings | A reference to ARGL's settings for an OpenGL context, as returned by arglSetupForCurrentContext(). If NULL, arglCleanup performs no operation. |
void arglDispImage | ( | ARGL_CONTEXT_SETTINGS_REF | contextSettings, |
int32_t | viewport[4] | ||
) |
Display an ARVideo image, by drawing it using OpenGL.
This function draws an image from an ARVideo source to the current OpenGL context. This operation is most useful in video see-through augmented reality applications for drawing the camera view as a background image, but can also be used in other ways.
An undistorted image is drawn with the lower-left corner of the bottom-left-most pixel at OpenGL screen coordinates (0,0), and the upper-right corner of the top-right-most pixel at OpenGL screen coodinates (x * zoom, y * zoom), where x and y are the values of the fields cparam->xsize and cparam->ysize (see below) and zoom is the value of the parameter zoom (also see below). If cparam->dist_factor indicates that an un-warping correction should be applied, the actual coordinates will differ from the values specified here.
OpenGL state: Drawing is performed with depth testing and lighting disabled, and thus leaves the the depth buffer (if any) unmodified. If pixel transfer is by texturing and the drawing is done in replacement texture environment mode. The depth test enable and lighting enable state and the texture environment mode are NOT restored before the function returns.
contextSettings | A reference to ARGL's settings for the current OpenGL context, as returned by arglSetupForCurrentContext() for this context. It is the callers responsibility to make sure that the current context at the time arglDisplayImage() is called matches that under which contextSettings was created. |
viewport | OpenGL-style viewport to be applied prior to drawing, or NULL in which case the viewport will not be set prior to drawing. |
int arglDistortionCompensationGet | ( | ARGL_CONTEXT_SETTINGS_REF | contextSettings, |
int * | enable | ||
) |
Enquire as to the enable state of camera lens distortion compensation in arglDispImage.
By default, arglDispImage compensates for the distortion of the camera's acquired image caused by the lens when it draws. This function enquires as to whether arglDispImage is currently doing compensation or not.
contextSettings | A reference to ARGL's settings for the current OpenGL context, as returned by arglSetupForCurrentContext() for this context. |
enable | Pointer to an integer value which will be set to TRUE if distortion compensation is enabled in the specified context, or FALSE if it is disabled. |
int arglDistortionCompensationSet | ( | ARGL_CONTEXT_SETTINGS_REF | contextSettings, |
int | enable | ||
) |
Set compensation for camera lens distortion in arglDispImage to off or on.
By default, arglDispImage compensates for the distortion of the camera's acquired image caused by the lens when it draws. By calling this function with enabled = FALSE, this compensation will be disabled in the specified drawing context. It may be re-enabled at any time. This function is useful if you need to draw an image, but do not know the extent of the camera's lens distortion (such as during distortion calibration). While distortion compensation is disabled, the dist_factor[] array in a the camera cparam structure passed to arglDispImage is ignored.
contextSettings | A reference to ARGL's settings for the current OpenGL context, as returned by arglSetupForCurrentContext() for this context. |
enable | TRUE to enabled distortion compensation, FALSE to disable it. The default state for new contexts is enable = TRUE. |
int arglGetFlipH | ( | ARGL_CONTEXT_SETTINGS_REF | contextSettings | ) |
int arglGetFlipV | ( | ARGL_CONTEXT_SETTINGS_REF | contextSettings | ) |
int arglGetPixelZoom | ( | ARGL_CONTEXT_SETTINGS_REF | contextSettings, |
float * | zoom | ||
) |
Retrieve the current video image drawing scalefactor.
zoom | The amount to scale the video image up or down. To draw the video image double size, use a zoom value of 2.0. To draw the video image half size use a zoom value of 0.5. |
int arglGetRotate90 | ( | ARGL_CONTEXT_SETTINGS_REF | contextSettings | ) |
Find out whether ARGL is rotating all OpenGL drawing by 90 degrees.
On some OpenGL ES devices, it may be desirable to rotate all OpenGL drawing by 90 degrees in the window coordinate system, in order to swap the horizontal and vertical axes of the device. This may be a higher performance solution than manually swapping rows and columns of submitted data.
This function queries the current state of whether such a rotation is being performed by ARGL or not.
contextSettings | A reference to ARGL's settings for the current OpenGL context, as returned by arglSetupForCurrentContext() for this context. |
int arglGLCapabilityCheck | ( | ARGL_CONTEXT_SETTINGS_REF | contextSettings, |
const uint16_t | minVersion, | ||
const unsigned char * | extension | ||
) |
Checks for the presence of an OpenGL capability by version or extension.
Checks for the presence of an OpenGL capability by version or extension. The test returns true if EITHER the OpenGL driver's OpenGL implementation version meets or exceeds a minimum value (passed in in minVersion) OR if an OpenGL extension identifier passed in as a character string is non-NULL, and is found in the current driver's list of supported extensions.
contextSettings | A reference to ARGL's settings for the current OpenGL context, as returned by arglSetupForCurrentContext() for this context. |
minVersion | A binary-coded decimal (i.e. version 1.0 is represented as 0x0100) version number. If minVersion is zero, (i.e. there is no version of OpenGL with this extension in core) the version test will always fail, and the result will only be true if the extension string test passes. |
extension | A string with an extension name to search the drivers extensions string for. E.g. "GL_EXT_texture". If NULL, the extension name test will always fail, and the result will only be true if the version number test passes. |
uint16_t arglOpenGLVersion | ( | ) |
int arglPixelBufferDataUploadBiPlanar | ( | ARGL_CONTEXT_SETTINGS_REF | contextSettings, |
ARUint8 * | bufDataPtr0, | ||
ARUint8 * | bufDataPtr1 | ||
) |
Upload a buffer of pixel data to an OpenGL texture for later use by arglDispImage().
ARGL provides the ability to perform distortion-compensated texturing of a camera video image into the OpenGL context, for the purpose of video-see through augmented reality. This function uploads the camera image data to an OpenGL texture, ready for later drawing using the function arglDispImage().
If a pointer to an ARParam structure has been passed in to function arglSetupDebugMode, then a check will be made whether debug mode is enabled, and if it is, then the buffer pointed to by this function will be ignored, and instead the debug image will be loaded for texturing.
contextSettings | A reference to ARGL's settings for the current OpenGL context, as returned by arglSetupForCurrentContext() for this context. |
bufDataPtr0 | A pointer to the pixel buffer, which is a block of memory from which texture data will be read. |
The layout of pixel data in the memory pointed to by bufDataPtr is assumed to be specified by the value of pixelFormat in the ARHandle submitted to arglSetupForCurrentContext(), but can be changed by calling arglPixelFormatSet() and/or arglPixelBufferSizeSet().
By default, the pixel buffer is assumed to be tightly packed, row-major array of dimensions equal to the calibrated camera image size (as passed in the fields arParam.xsize and arParam.ysize of the ARHandle submitted to arglSetupForCurrentContext().
The pixel data buffer submitted may, under some circumstances be allowed to be larger than the values of the calibrated camera image size (i.e. padded). See the discussion section of the documentation for function arglPixelBufferSizeSet() for more information.
This may only occur when the underlying OpenGL ES impementation does not support non-power-of-two textures. For the Apple iPhone family, this applies to the iPhone, the iPhone 3G, the iPod Touch 1st and 2nd Generation. The iPhone 3GS and the iPod Touch 3rd Generation support non-power-of-two textures, and thus padding of the pixel data buffer is not supported on these devices. If padding is desired, the desired buffer size must be submitted using arglPixelBufferSizeSet(). Check that the result from this function is TRUE before attempting to upload such a padded buffer.
bufDataPtr1 | NULL for single-plane (interleaved) textures, otherwise for bi-planar textures, a pointer to the pixel buffer, which is a block of memory from which texture data will be read for the second plane containing the CbCr components. This plane must have dimensions of half the size of plane 0, and 2-bytes per pixel (1 byte Cb, 1 byte Cr). |
int arglPixelBufferSizeGet | ( | ARGL_CONTEXT_SETTINGS_REF | contextSettings, |
int * | bufWidth, | ||
int * | bufHeight | ||
) |
Query the size of pixel data buffers expected by arglPixelBufferDataUpload().
See function arglPixelBufferSizeSet() for a full discussion.
contextSettings | A reference to ARGL's settings for the current OpenGL context, as returned by arglSetupForCurrentContext() for this context. |
bufWidth | A pointer to int, which will be filled out with the buffer width, in pixels, or NULL if this value is not required. |
bufHeight | A pointer to int, which will be filled out with the buffer height, in pixels, or NULL if this value is not required.. |
int arglPixelBufferSizeSet | ( | ARGL_CONTEXT_SETTINGS_REF | contextSettings, |
int | bufWidth, | ||
int | bufHeight | ||
) |
Specify a desired pixel buffer size larger than the camera image size.
By default, the pixel buffer accepted by function arglPixelBufferDataUpload() is assumed to be tightly packed, row-major array of dimensions equal to the calibrated camera image size (as passed in the fields arParam.xsize and arParam.ysize of the ARHandle submitted to arglSetupForCurrentContext().
The pixel data buffer submitted may, under some circumstances be allowed to be larger than the values of the calibrated camera image size (i.e. padded). This may only occur when the underlying OpenGL ES impementation does not support non-power-of-two textures. For the Apple iPhone family, this applies to the iPhone, the iPhone 3G, the iPod Touch 1st and 2nd Generation. The iPhone 3GS and the iPod Touch 3rd Generation support non-power-of-two textures, and thus padding of the pixel data buffer is not supported on these devices. If padding is desired, the desired buffer size must be submitted using this function. Check that the result from this function is TRUE before attempting to upload such a padded buffer.
contextSettings | A reference to ARGL's settings for the current OpenGL context, as returned by arglSetupForCurrentContext() for this context. |
bufWidth | The desired buffer width, in pixels. |
bufHeight | The desired buffer height, in pixels. |
int arglPixelFormatGet | ( | ARGL_CONTEXT_SETTINGS_REF | contextSettings, |
AR_PIXEL_FORMAT * | format, | ||
int * | size | ||
) |
Get the format of pixel data in which arglDispImage*() is expecting data to be passed.
This function enquires as to the current format of pixel data being expected by the arglDispImage*() functions. The default format is determined by the value passed to arglSetupForCurrentContext.
contextSettings | A reference to ARGL's settings for the current OpenGL context, as returned by arglSetupForCurrentContext() for this context. |
format | A symbolic constant for the pixel format in use. See AR_PIXEL_FORMAT in ar.h for a list of all possible formats. |
size | The number of bytes of memory occupied per pixel, for the given format. |
int arglPixelFormatSet | ( | ARGL_CONTEXT_SETTINGS_REF | contextSettings, |
AR_PIXEL_FORMAT | format | ||
) |
Set the format of pixel data which will be passed to arglDispImage*()
(description) In arg, the format of the pixels (i.e. the arrangement of components within each pixel) can be changed at runtime. Use this function to inform arg the format the pixels being passed to arglDispImage*() functions are in. This setting applies only to the context passed in parameter contextSettings. The default format is determined by the value passed to arglSetupForCurrentContext. Usually, image data is passed in directly from images generated by ARVideo, and so you should ensure that ARVideo is generating pixels of the same format.
contextSettings | A reference to ARGL's settings for the current OpenGL context, as returned by arglSetupForCurrentContext() for this context. |
format | A symbolic constant for the pixel format being set. See AR_PIXEL_FORMAT in ar.h for a list of all possible formats. |
void arglSetFlipH | ( | ARGL_CONTEXT_SETTINGS_REF | contextSettings, |
int | flipH | ||
) |
void arglSetFlipV | ( | ARGL_CONTEXT_SETTINGS_REF | contextSettings, |
int | flipV | ||
) |
int arglSetPixelZoom | ( | ARGL_CONTEXT_SETTINGS_REF | contextSettings, |
float | zoom | ||
) |
Set the current video image drawing scalefactor.
zoom | The amount to scale the video image up or down. To draw the video image double size, use a zoom value of 2.0. To draw the video image half size use a zoom value of 0.5. |
void arglSetRotate90 | ( | ARGL_CONTEXT_SETTINGS_REF | contextSettings, |
int | rotate90 | ||
) |
Set or unset a 90 degree rotation in all OpenGL drawing performed by ARGL.
On some OpenGL ES devices, it may be desirable to rotate all OpenGL drawing by 90 degrees in the window coordinate system, in order to swap the horizontal and vertical axes of the device. This may be a higher performance solution than manually swapping rows and columns of submitted data.
This function enables or disables such an axis swap in ARGL with very little performance cost, by introducing a 90-degree rotation into the OpenGL projection matrix.
By default, 90 degree rotation is DISABLED.
contextSettings | A reference to ARGL's settings for the current OpenGL. context, as returned by arglSetupForCurrentContext() for this context. |
rotate90 | Set to TRUE or 1 to enable 90 degree rotation, FALSE to disable. |
int arglSetupDebugMode | ( | ARGL_CONTEXT_SETTINGS_REF | contextSettings, |
ARHandle * | arHandle | ||
) |
Provide an ARHandle structure from which to extract information about debug mode.
This provides support for the debug mode in libAR. If arg has been compiled with debug mode support, the passed in ARHandle is used as the source of whether debug mode is enabled or disabled. If enabled, the binarized debug image will be drawn instead of the input image.
arHandle | A pointer to an ARHandle structure from which to extract debug info, or NULL if debug functionality is not required. Default is NULL. |
ARGL_CONTEXT_SETTINGS_REF arglSetupForCurrentContext | ( | const ARParam * | cparam, |
AR_PIXEL_FORMAT | pixelFormat | ||
) |
Initialise the arg library for the current OpenGL context.
This function performs required setup of the arg library for the current OpenGL context and must be called before any other argl*() functions are called for this context.
An OpenGL context holds all of the state of the OpenGL machine, including textures and display lists etc. There will usually be one OpenGL context for each window displaying OpenGL content.
Other argl*() functions whose operation depends on OpenGL state will require an ARGL_CONTEXT_SETTINGS_REF. This is just so that they can keep track of per-context variables.
You should call arglCleanup() passing in the ARGL_CONTEXT_SETTINGS_REF when you have finished with the library for this context.
cparam | Pointer to a set of ARToolKit camera parameters for the current video source. The size of the source image is taken from the fields xsize and ysize of the ARParam structure pointed to. Also, the field dist_factor of the ARParam structure pointed to will be taken as the amount to un-warp the supplied image. |
Prior to ARToolKit v5.1.5, the ARParam structure pointed to had to remain valid in memory for the duration of the ARGL_CONTEXT_SETTINGS_REF's usage. As of ARToolKit v5.1.5, the ARParam structure pointed to is copied, and no longer need be maintained.
pixelFormat | The type and format of pixels of the images to be drawn by the arg library. This value can be changed later by using arglPixelFormatSet() |