RAPICAM_3-15-2015
RaspiTexUtil.c File Reference
#include "RaspiTexUtil.h"
#include "RaspiTex.h"
#include <bcm_host.h>
#include <GLES2/gl2.h>

Functions

void raspitexutil_gl_term (RASPITEX_STATE *raspitex_state)
 
int raspitexutil_create_native_window (RASPITEX_STATE *raspitex_state)
 
void raspitexutil_destroy_native_window (RASPITEX_STATE *raspitex_state)
 
int raspitexutil_create_textures (RASPITEX_STATE *raspitex_state)
 
int raspitexutil_gl_init_1_0 (RASPITEX_STATE *raspitex_state)
 
int raspitexutil_gl_init_2_0 (RASPITEX_STATE *raspitex_state)
 
int raspitexutil_do_update_texture (EGLDisplay display, EGLenum target, EGLClientBuffer mm_buf, GLuint *texture, EGLImageKHR *egl_image)
 
int raspitexutil_update_texture (RASPITEX_STATE *raspitex_state, EGLClientBuffer mm_buf)
 
int raspitexutil_update_y_texture (RASPITEX_STATE *raspitex_state, EGLClientBuffer mm_buf)
 
int raspitexutil_update_u_texture (RASPITEX_STATE *raspitex_state, EGLClientBuffer mm_buf)
 
int raspitexutil_update_v_texture (RASPITEX_STATE *raspitex_state, EGLClientBuffer mm_buf)
 
int raspitexutil_update_model (RASPITEX_STATE *raspitex_state)
 
int raspitexutil_redraw (RASPITEX_STATE *raspitex_state)
 
void raspitexutil_close (RASPITEX_STATE *raspitex_state)
 
void raspitexutil_brga_to_rgba (uint8_t *buffer, size_t size)
 
int raspitexutil_capture_bgra (RASPITEX_STATE *state, uint8_t **buffer, size_t *buffer_size)
 
int raspitexutil_build_shader_program (RASPITEXUTIL_SHADER_PROGRAM_T *p)
 

Variables

VCOS_LOG_CAT_T raspitex_log_category
 

Detailed Description

Provides default implementations for the raspitex_scene_ops functions and general utility functions.

Function Documentation

void raspitexutil_brga_to_rgba ( uint8_t *  buffer,
size_t  size 
)

Performs an in-place byte swap from BGRA to RGBA.

Parameters
bufferThe buffer to modify.
sizeSize of the buffer in bytes.
int raspitexutil_build_shader_program ( RASPITEXUTIL_SHADER_PROGRAM_T p)

Takes a description of shader program, compiles it and gets the locations of uniforms and attributes.

Parameters
pThe shader program state.
Returns
Zero if successful.
int raspitexutil_capture_bgra ( RASPITEX_STATE state,
uint8_t **  buffer,
size_t *  buffer_size 
)

Uses glReadPixels to grab the current frame-buffer contents and returns the result in a newly allocate buffer along with the its size. Data is returned in BGRA format for TGA output. PPM output doesn't require the channel order swap but would require a vflip. The TGA format also supports alpha. The byte swap is not done in this function to avoid blocking the GL rendering thread.

Parameters
statePointer to the GL preview state.
bufferAddress of pointer to set to pointer to new buffer.
buffer_sizeThe size of the new buffer in bytes (out param)
Returns
Zero if successful.
void raspitexutil_close ( RASPITEX_STATE raspitex_state)

Default is a no-op

Parameters
raspitex_stateA pointer to the GL preview state.
int raspitexutil_create_native_window ( RASPITEX_STATE raspitex_state)

Creates a native window for the GL surface using dispmanx

Parameters
raspitex_stateA pointer to the GL preview state.
Returns
Zero if successful, otherwise, -1 is returned.
void raspitexutil_destroy_native_window ( RASPITEX_STATE raspitex_state)

Destroys the pools of buffers used by the GL renderer.

Parameters
raspitex_stateA pointer to the GL preview state.
int raspitexutil_do_update_texture ( EGLDisplay  display,
EGLenum  target,
EGLClientBuffer  mm_buf,
GLuint *  texture,
EGLImageKHR *  egl_image 
)

Advances the texture and EGL image to the next MMAL buffer.

Parameters
displayThe EGL display.
targetThe EGL image target e.g. EGL_IMAGE_BRCM_MULTIMEDIA
mm_bufThe EGL client buffer (mmal opaque buffer) that is used to create the EGL Image for the preview texture.
egl_imagePointer to the EGL image to update with mm_buf.
texturePointer to the texture to update from EGL image.
Returns
Zero if successful.
int raspitexutil_gl_init_1_0 ( RASPITEX_STATE raspitex_state)

Creates an OpenGL ES 1.X context.

Parameters
raspitex_stateA pointer to the GL preview state.
Returns
Zero if successful.
int raspitexutil_gl_init_2_0 ( RASPITEX_STATE raspitex_state)

Creates an OpenGL ES 2.X context.

Parameters
raspitex_stateA pointer to the GL preview state.
Returns
Zero if successful.
void raspitexutil_gl_term ( RASPITEX_STATE raspitex_state)

Deletes textures and EGL surfaces and context.

Parameters
raspitex_statePointer to the Raspi
int raspitexutil_redraw ( RASPITEX_STATE raspitex_state)

Default is a no-op

Parameters
raspitex_stateA pointer to the GL preview state.
Returns
Zero.
int raspitexutil_update_model ( RASPITEX_STATE raspitex_state)

Default is a no-op

Parameters
raspitex_stateA pointer to the GL preview state.
Returns
Zero.
int raspitexutil_update_texture ( RASPITEX_STATE raspitex_state,
EGLClientBuffer  mm_buf 
)

Updates the RGBX texture to the specified MMAL buffer.

Parameters
raspitex_stateA pointer to the GL preview state.
mm_bufThe MMAL buffer.
Returns
Zero if successful.
int raspitexutil_update_u_texture ( RASPITEX_STATE raspitex_state,
EGLClientBuffer  mm_buf 
)

Updates the U plane texture to the specified MMAL buffer.

Parameters
raspitex_stateA pointer to the GL preview state.
mm_bufThe MMAL buffer.
Returns
Zero if successful.
int raspitexutil_update_v_texture ( RASPITEX_STATE raspitex_state,
EGLClientBuffer  mm_buf 
)

Updates the V plane texture to the specified MMAL buffer.

Parameters
raspitex_stateA pointer to the GL preview state.
mm_bufThe MMAL buffer.
Returns
Zero if successful.
int raspitexutil_update_y_texture ( RASPITEX_STATE raspitex_state,
EGLClientBuffer  mm_buf 
)

Updates the Y plane texture to the specified MMAL buffer.

Parameters
raspitex_stateA pointer to the GL preview state.
mm_bufThe MMAL buffer.
Returns
Zero if successful.