RAPICAM_3-15-2015
|
#include "RaspiTex.h"
#include "RaspiCLI.h"
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/time.h>
#include <EGL/egl.h>
#include <EGL/eglext.h>
#include <GLES/gl.h>
#include <GLES/glext.h>
#include "RaspiTexUtil.h"
#include "interface/vcos/vcos.h"
#include "interface/mmal/mmal_buffer.h"
#include "interface/mmal/util/mmal_util.h"
#include "interface/mmal/util/mmal_util_params.h"
#include "tga.h"
#include "gl_scenes/mirror.h"
#include "gl_scenes/sobel.h"
#include "gl_scenes/square.h"
#include "gl_scenes/teapot.h"
#include "gl_scenes/yuv.h"
Macros | |
#define | DEFAULT_WIDTH 640 |
#define | DEFAULT_HEIGHT 480 |
#define | CommandGLScene 1 |
#define | CommandGLWin 2 |
Functions | |
int | raspitex_parse_cmdline (RASPITEX_STATE *state, const char *arg1, const char *arg2) |
void | raspitex_display_help () |
int | raspitex_configure_preview_port (RASPITEX_STATE *state, MMAL_PORT_T *preview_port) |
int | raspitex_init (RASPITEX_STATE *state) |
void | raspitex_destroy (RASPITEX_STATE *state) |
void | raspitex_set_defaults (RASPITEX_STATE *state) |
void | raspitex_stop (RASPITEX_STATE *state) |
int | raspitex_start (RASPITEX_STATE *state) |
int | raspitex_capture (RASPITEX_STATE *state, FILE *output_file) |
A simple framework for extending a MMAL application to render buffers via OpenGL.
MMAL buffers are often in YUV colour space and in either a planar or tile format which is not supported directly by V3D. Instead of copying the buffer from the GPU and doing a colour space / pixel format conversion the GL_OES_EGL_image_external is used. This allows an EGL image to be created from GPU buffer handle (MMAL opaque buffer handle). The EGL image may then be used to create a texture (glEGLImageTargetTexture2DOES) and drawn by either OpenGL ES 1.0 or 2.0 contexts.
Notes: 1) GL_OES_EGL_image_external textures always return pixels in RGBA format. This is also the case when used from a fragment shader.
2) The driver implementation creates a new RGB_565 buffer and does the color space conversion from YUV. This happens in GPU memory using the vector processor.
3) Each EGL external image in use will consume GPU memory for the RGB 565 buffer. In addition, the GL pipeline might require more than one EGL image to be retained in GPU memory until the drawing commands are flushed.
Typically 128 MB of GPU memory is sufficient for 720p viewfinder and 720p GL surface. If both the viewfinder and the GL surface are 1080p then 256MB of GPU memory is recommended, otherwise, for non-trivial scenes the system can run out of GPU memory whilst the camera is running.
4) It is important to make sure that the MMAL opaque buffer is not returned to MMAL before the GL driver has completed the asynchronous call to glEGLImageTargetTexture2DOES. Deferring destruction of the EGL image and the buffer return to MMAL until after eglSwapBuffers is the recommended.
See also: http://www.khronos.org/registry/gles/extensions/OES/OES_EGL_image_external.txt
int raspitex_capture | ( | RASPITEX_STATE * | state, |
FILE * | output_file | ||
) |
Writes the next GL frame-buffer to a RAW .ppm formatted file using the specified file-handle.
state | Pointer to the GL preview state. |
outpt_file | Output file handle for the ppm image. |
void raspitex_display_help | ( | ) |
Display help for command line options
int raspitex_parse_cmdline | ( | RASPITEX_STATE * | state, |
const char * | arg1, | ||
const char * | arg2 | ||
) |
Parse a possible command pair - command and parameter
arg1 | Command |
arg2 | Parameter (could be NULL) |
int raspitex_start | ( | RASPITEX_STATE * | state | ) |
Starts the worker / GL renderer thread.
state | Pointer to the GL preview state. |