FB Graphics
FBGraphics (FBG) : Simple C 16, 24, 32 bpp generic graphics library with parallelism support and custom backend.
Data Structures | Functions | Variables
fbg_glfw.h File Reference
#include <GL/glew.h>
#include <GLFW/glfw3.h>
#include "fbgraphics.h"

Go to the source code of this file.

Data Structures

struct  _fbg_glfw_context
 GLFW wrapper data structure. More...
 

Functions

struct _fbgfbg_glfwSetup (int width, int height, int components, const char *title, int monitor, int fullscreen)
 initialize a FB Graphics OpenGL context (GLFW library) More...
 
void fbg_glfwClear ()
 OpenGL clear. More...
 
void fbg_glfwUpdateBuffer (struct _fbg *fbg)
 this update FBG disp_buffer with the actual rendered OpenGL content More...
 
int fbg_glfwShouldClose (struct _fbg *fbg)
 Query the user requested (window close etc) close status. More...
 
void fbg_glfwFullscreen (struct _fbg *fbg, int enable)
 Switch to fullscreen or windowed mode. More...
 
void fbg_glfwResize (struct _fbg *fbg, unsigned int new_width, unsigned new_height)
 Display resize. More...
 
GLuint fbg_glfwCreateTextureFromImage (struct _fbg *fbg, struct _fbg_img *img)
 create a non-interpolated (NEAREST) GL texture from a FBG image More...
 
GLuint fbg_glfwCreateTexture (GLuint width, GLuint height, GLint internal_format)
 create an empty non-interpolated (NEAREST) GL texture More...
 
GLuint fbg_glfwCreateVAO (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 VAO from indexed data, support for vertices, UVs, normals and colors More...
 
GLuint fbg_glfwCreateVAOvu (GLsizeiptr data_count, const GLvoid *data)
 create a VAO from vertices + UV data packed into a single array More...
 
GLuint fbg_glfwCreateFBO (GLuint texture)
 create a FBO More...
 
GLuint fbg_glfwCreateShader (GLenum type, const GLchar *source)
 create a single shader More...
 
GLuint fbg_glfwCreateShaderFromFile (GLenum type, const char *filename)
 create a shader from the content of a file More...
 
GLuint fbg_glfwCreateProgram (GLuint vertex_shader, GLuint fragment_shader, GLuint geometry_shader)
 create a vertex and/or fragment program More...
 
GLenum fbg_glfwCreateProgramFromFiles (const char *vs, const char *fs, const char *gs)
 create a vertex and/or fragment/geometry program from a file More...
 
GLenum fbg_glfwCreateProgramFromString (const char *vs, const char *fs, const char *gs)
 create a vertex and/or fragment/geometry program from a string More...
 

Variables

const GLfloat fbg_glfwQuad []
 Simple quad geometry (vertices + UV) More...
 
const char * fbg_glfwSimpleVs
 Simple vertex shader (screen quad, vertices + UV) More...
 
const char * fbg_glfwSimpleFs
 Simple textured fragment shader. More...
 

Data Structure Documentation

◆ _fbg_glfw_context

struct _fbg_glfw_context

GLFW wrapper data structure.

Definition at line 37 of file fbg_glfw.h.

Data Fields
GLuint fbg_texture FBG texture (updated at each frames)
GLuint fbg_vao FBG VAO.
GLFWmonitor * monitor GLFW monitor.
GLenum simple_program Simple GLSL program (screen-aligned textured quad)
int update_buffer tell wether fbg_glfw should update fbg disp_buffer after rendering
GLFWwindow * window GLFW window.

Function Documentation

◆ fbg_glfwClear()

void fbg_glfwClear ( )

OpenGL clear.

◆ fbg_glfwCreateFBO()

GLuint fbg_glfwCreateFBO ( GLuint  texture)

create a FBO

Parameters
textureGL texture id
Returns
GL FBO id

◆ fbg_glfwCreateProgram()

GLuint fbg_glfwCreateProgram ( GLuint  vertex_shader,
GLuint  fragment_shader,
GLuint  geometry_shader 
)

create a vertex and/or fragment program

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

◆ fbg_glfwCreateProgramFromFiles()

GLenum fbg_glfwCreateProgramFromFiles ( const char *  vs,
const char *  fs,
const char *  gs 
)

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

Parameters
vsvertex shader file
fsfragment shader file
gsgeometry shader file
Returns
GL shader id

◆ fbg_glfwCreateProgramFromString()

GLenum fbg_glfwCreateProgramFromString ( const char *  vs,
const char *  fs,
const char *  gs 
)

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

Parameters
vsvertex shader string
fsfragment shader string
gsgeometry shader string
Returns
GL shader id

◆ fbg_glfwCreateShader()

GLuint fbg_glfwCreateShader ( GLenum  type,
const GLchar *  source 
)

create a single shader

Parameters
typeGL shader type
sourceshader code
Returns
GL shader id

◆ fbg_glfwCreateShaderFromFile()

GLuint fbg_glfwCreateShaderFromFile ( 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_glfwCreateTexture()

GLuint fbg_glfwCreateTexture ( 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_glfwCreateTextureFromImage()

GLuint fbg_glfwCreateTextureFromImage ( 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_glfwCreateVAO()

GLuint fbg_glfwCreateVAO ( 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 VAO 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
GL VAO id

◆ fbg_glfwCreateVAOvu()

GLuint fbg_glfwCreateVAOvu ( GLsizeiptr  data_count,
const GLvoid *  data 
)

create a VAO 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 VAO id

◆ fbg_glfwFullscreen()

void fbg_glfwFullscreen ( struct _fbg fbg,
int  enable 
)

Switch to fullscreen or windowed mode.

Parameters
fbgpointer to a FBG context / data structure
enableBoolean indicating windowed or fullscreen

◆ fbg_glfwResize()

void fbg_glfwResize ( struct _fbg fbg,
unsigned int  new_width,
unsigned  new_height 
)

Display resize.

Parameters
fbgpointer to a FBG context / data structure
new_widthnew display width
new_heightnew display height

◆ fbg_glfwSetup()

struct _fbg* fbg_glfwSetup ( int  width,
int  height,
int  components,
const char *  title,
int  monitor,
int  fullscreen 
)

initialize a FB Graphics OpenGL context (GLFW library)

Parameters
widthwindow width
heightwindow height
componentsfbg context color components (4 for RGBA or 3 for RGB)
titlewindow title
monitormonitor id (0 = primary display)
fullscreen0 = windowed, 1 = fullscreen, 2 = windowed full screen
Returns
FBG data structure pointer

◆ fbg_glfwShouldClose()

int fbg_glfwShouldClose ( 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_glfwUpdateBuffer()

void fbg_glfwUpdateBuffer ( 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_glfwQuad

const GLfloat fbg_glfwQuad[]

Simple quad geometry (vertices + UV)

◆ fbg_glfwSimpleFs

const char* fbg_glfwSimpleFs

Simple textured fragment shader.

◆ fbg_glfwSimpleVs

const char* fbg_glfwSimpleVs

Simple vertex shader (screen quad, vertices + UV)