FB Graphics
FBGraphics (FBG) : Simple C 16, 24, 32 bpp generic graphics library with parallelism support and custom backend.
Data Structures | Functions | Variables
fbg_opengl_es2.h File Reference
#include <sys/ioctl.h>
#include <linux/fb.h>
#include <unistd.h>
#include <fcntl.h>
#include <GLES2/gl2.h>
#include <EGL/egl.h>
#include <EGL/eglext.h>
#include "fbgraphics.h"

Go to the source code of this file.

Data Structures

struct  _fbg_gles2_context
 OpenGL ES 2.0 wrapper data structure. More...
 
struct  _fbg_vbo_data
 struct which hold usual VBO data for 3D objects More...
 

Functions

struct _fbgfbg_gles2Setup (const char *fb_device, int components)
 initialize a FB Graphics OpenGL ES 2 (fbdev or RPI direct) context More...
 
void fbg_gles2Clear ()
 OpenGL clear. More...
 
void fbg_gles2UpdateBuffer (struct _fbg *fbg)
 this update FBG disp_buffer with the actual rendered OpenGL content More...
 
int fbg_gles2ShouldClose (struct _fbg *fbg)
 Query the user requested (window close etc) close status. More...
 
GLuint fbg_gles2CreateTextureFromImage (struct _fbg *fbg, struct _fbg_img *img)
 create a non-interpolated (NEAREST) GL texture from a FBG image More...
 
GLuint fbg_gles2CreateTexture (GLuint width, GLuint height, GLint internal_format)
 create an empty non-interpolated (NEAREST) GL texture More...
 
struct _fbg_vbo_datafbg_gles2CreateVBO (GLsizeiptr indices_count, const GLvoid *indices_data, size_t sizeof_indice_type, GLsizeiptr vertices_count, const GLvoid *vertices_data, GLsizeiptr texcoords_count, const GLvoid *texcoords_data, GLsizeiptr normals_count, const GLvoid *normals_data, GLsizeiptr colors_count, const GLvoid *colors_data)
 create a VBO from indexed data, support for vertices, UVs, normals and colors More...
 
void fbg_gles2FreeVBOData (struct _fbg_vbo_data *vbo_data)
 free VBO data (created with fbg_gles2CreateVBO) More...
 
GLuint fbg_gles2CreateVBOvu (GLsizeiptr data_count, const GLvoid *data)
 create a VBO from vertices + UV data packed into a single array More...
 
GLuint fbg_gles2CreateShader (GLenum type, const GLchar *source)
 create a FBO More...
 
GLuint fbg_gles2CreateShaderFromFile (GLenum type, const char *filename)
 create a shader from the content of a file More...
 
GLuint fbg_gles2CreateProgram (GLuint vertex_shader, GLuint fragment_shader)
 create a vertex and/or fragment program More...
 
GLenum fbg_gles2CreateProgramFromFiles (const char *vs, const char *fs)
 create a vertex and/or fragment/geometry program from a file More...
 
GLenum fbg_gles2CreateProgramFromString (const char *vs, const char *fs)
 create a vertex and/or fragment/geometry program from a string More...
 

Variables

const GLfloat fbg_gles2Quad []
 Simple quad geometry (vertices + UV) More...
 
const char * fbg_gles2SimpleVs
 Simple vertex shader (screen quad, vertices + UV) More...
 
const char * fbg_gles2SimpleFs
 Simple textured fragment shader. More...
 

Data Structure Documentation

◆ _fbg_gles2_context

struct _fbg_gles2_context

OpenGL ES 2.0 wrapper data structure.

Definition at line 47 of file fbg_opengl_es2.h.

Data Fields
EGLContext egl_context EGL context.
EGLDisplay egl_display EGL display.
void * egl_image EGL image.
EGLContext egl_surface EGL surface.
GLuint fbg_texture FBG texture (updated at each frames)
GLuint fbg_vbo FBG VBO.
int fd Framebuffer file descriptor.
GLenum simple_program Simple GLSL program (screen-aligned textured quad)
int update_buffer tell wether fbg_gles2 should update fbg disp_buffer after rendering
struct fb_var_screeninfo vinfo Framebuffer device var. informations.

◆ _fbg_vbo_data

struct _fbg_vbo_data

struct which hold usual VBO data for 3D objects

Definition at line 73 of file fbg_opengl_es2.h.

Data Fields
GLuint cbo
GLuint ibo
GLuint nbo
GLuint tbo
GLuint vbo

Function Documentation

◆ fbg_gles2Clear()

void fbg_gles2Clear ( )

OpenGL clear.

◆ fbg_gles2CreateProgram()

GLuint fbg_gles2CreateProgram ( GLuint  vertex_shader,
GLuint  fragment_shader 
)

create a vertex and/or fragment program

Parameters
vertex_shadervertex shader id, can be 0
fragment_shaderfragment shader id, can be 0
Returns
GL shader id

◆ fbg_gles2CreateProgramFromFiles()

GLenum fbg_gles2CreateProgramFromFiles ( const char *  vs,
const char *  fs 
)

create a vertex and/or fragment/geometry program from a file

Parameters
vsvertex shader file
fsfragment shader file
Returns
GL shader id

◆ fbg_gles2CreateProgramFromString()

GLenum fbg_gles2CreateProgramFromString ( const char *  vs,
const char *  fs 
)

create a vertex and/or fragment/geometry program from a string

Parameters
vsvertex shader string
fsfragment shader string
Returns
GL shader id

◆ fbg_gles2CreateShader()

GLuint fbg_gles2CreateShader ( GLenum  type,
const GLchar *  source 
)

create a FBO

Parameters
textureGL texture id
Returns
GL FBO idcreate a single shader
Parameters
typeGL shader type
sourceshader code
Returns
GL shader id

◆ fbg_gles2CreateShaderFromFile()

GLuint fbg_gles2CreateShaderFromFile ( GLenum  type,
const char *  filename 
)

create a shader from the content of a file

Parameters
typeGL shader type
filenamefile to load
Returns
GL shader id

◆ fbg_gles2CreateTexture()

GLuint fbg_gles2CreateTexture ( GLuint  width,
GLuint  height,
GLint  internal_format 
)

create an empty non-interpolated (NEAREST) GL texture

Parameters
widthwidth of the requested texture
heightheight of the requested texture
internal_formatOpenGL format (GL_RGBA etc.)
Returns
GL texture id

◆ fbg_gles2CreateTextureFromImage()

GLuint fbg_gles2CreateTextureFromImage ( struct _fbg fbg,
struct _fbg_img img 
)

create a non-interpolated (NEAREST) GL texture from a FBG image

Parameters
fbgpointer to a FBG context / data structure
imgimage structure pointer
Returns
GL texture id

◆ fbg_gles2CreateVBO()

struct _fbg_vbo_data* fbg_gles2CreateVBO ( GLsizeiptr  indices_count,
const GLvoid *  indices_data,
size_t  sizeof_indice_type,
GLsizeiptr  vertices_count,
const GLvoid *  vertices_data,
GLsizeiptr  texcoords_count,
const GLvoid *  texcoords_data,
GLsizeiptr  normals_count,
const GLvoid *  normals_data,
GLsizeiptr  colors_count,
const GLvoid *  colors_data 
)

create a VBO from indexed data, support for vertices, UVs, normals and colors

Parameters
indices_countindices count
indices_datadata containing indices
sizeof_indice_typesizeof indice type
vertices_countvertices count
vertices_datadata containing vertices
texcoords_countuv count
texcoords_datadata containing uv
normals_countnormals count
normals_datadata containing normals
colors_countcolors count
colors_datadata containing colors
Returns
_fbg_vbo_data data structure containing the VBOs

◆ fbg_gles2CreateVBOvu()

GLuint fbg_gles2CreateVBOvu ( GLsizeiptr  data_count,
const GLvoid *  data 
)

create a VBO from vertices + UV data packed into a single array

Parameters
data_countvertices data count
datadata containing all vertices (set of 3 x float) then all associated UVs (set of 2 x float)
Returns
GL VBO id

◆ fbg_gles2FreeVBOData()

void fbg_gles2FreeVBOData ( struct _fbg_vbo_data vbo_data)

free VBO data (created with fbg_gles2CreateVBO)

Parameters
vbo_datadata structure containing the VBOs

◆ fbg_gles2Setup()

struct _fbg* fbg_gles2Setup ( const char *  fb_device,
int  components 
)

initialize a FB Graphics OpenGL ES 2 (fbdev or RPI direct) context

Parameters
fb_deviceframebuffer device; example : /dev/fb0
componentsfbg context color components (4 for RGBA or 3 for RGB)
Returns
FBG data structure pointer

◆ fbg_gles2ShouldClose()

int fbg_gles2ShouldClose ( struct _fbg fbg)

Query the user requested (window close etc) close status.

Parameters
fbgpointer to a FBG context / data structure
Returns
Boolean indicating close status

◆ fbg_gles2UpdateBuffer()

void fbg_gles2UpdateBuffer ( struct _fbg fbg)

this update FBG disp_buffer with the actual rendered OpenGL content

Parameters
fbgpointer to a FBG context / data structure

Variable Documentation

◆ fbg_gles2Quad

const GLfloat fbg_gles2Quad[]

Simple quad geometry (vertices + UV)

◆ fbg_gles2SimpleFs

const char* fbg_gles2SimpleFs

Simple textured fragment shader.

◆ fbg_gles2SimpleVs

const char* fbg_gles2SimpleVs

Simple vertex shader (screen quad, vertices + UV)