FB Graphics
FBGraphics (FBG) : Simple C 16, 24, 32 bpp generic graphics library with parallelism support and custom backend.
fbgraphics.h
Go to the documentation of this file.
1 /*
2  Copyright (c) 2018, 2019, 2020 Julien Verneuil
3  All rights reserved.
4 
5  Redistribution and use in source and binary forms, with or without
6  modification, are permitted provided that the following conditions are met:
7  * Redistributions of source code must retain the above copyright
8  notice, this list of conditions and the following disclaimer.
9  * Redistributions in binary form must reproduce the above copyright
10  notice, this list of conditions and the following disclaimer in the
11  documentation and/or other materials provided with the distribution.
12  * Neither the name of the organization nor the
13  names of its contributors may be used to endorse or promote products
14  derived from this software without specific prior written permission.
15 
16  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19  DISCLAIMED. IN NO EVENT SHALL Julien Verneuil BE LIABLE FOR ANY
20  DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21  (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27 
28 #ifndef FB_GRAPHICS_H
29 #define FB_GRAPHICS_H
30 
31  #include <time.h>
32  #include <sys/time.h>
33  #include <stdint.h>
34  #include <math.h>
35 
36 #ifdef FBG_PARALLEL
37  #include <stdatomic.h>
38  #include <pthread.h>
39 
40 // compatibility layer for liblfds 711 version (because 720 was unreleased at the time of writing this)
41 #ifdef FBG_LFDS
42 #ifdef LFDS711
43  #include "liblfds711.h"
44 
45  #define lfds720_freelist_n_element lfds711_freelist_element
46  #define lfds720_ringbuffer_n_element lfds711_ringbuffer_element
47  #define lfds720_ringbuffer_n_state lfds711_ringbuffer_state
48  #define lfds720_freelist_n_state lfds711_freelist_state
49  #define LFDS720_PAL_ATOMIC_ISOLATION_LENGTH_IN_BYTES LFDS711_PAL_ATOMIC_ISOLATION_IN_BYTES
50  #define lfds720_ringbuffer_n_init_valid_on_current_logical_core lfds711_ringbuffer_init_valid_on_current_logical_core
51  #define lfds720_freelist_n_init_valid_on_current_logical_core lfds711_freelist_init_valid_on_current_logical_core
52  #define LFDS720_FREELIST_N_SET_VALUE_IN_ELEMENT LFDS711_FREELIST_SET_VALUE_IN_ELEMENT
53  #define LFDS720_FREELIST_N_GET_VALUE_FROM_ELEMENT LFDS711_FREELIST_GET_VALUE_FROM_ELEMENT
54  #define lfds720_freelist_n_threadsafe_push lfds711_freelist_push
55  #define lfds720_freelist_n_threadsafe_pop lfds711_freelist_pop
56  #define lfds720_ringbuffer_n_cleanup lfds711_ringbuffer_cleanup
57  #define lfds720_freelist_n_cleanup lfds711_freelist_cleanup
58  #define lfds720_ringbuffer_n_read lfds711_ringbuffer_read
59  #define lfds720_ringbuffer_n_write lfds711_ringbuffer_write
60  #define lfds720_misc_flag lfds711_misc_flag
61  #define LFDS720_MISC_FLAG_RAISED LFDS711_MISC_FLAG_RAISED
62  #define LFDS720_MISC_MAKE_VALID_ON_CURRENT_LOGICAL_CORE_INITS_COMPLETED_BEFORE_NOW_ON_ANY_OTHER_PHYSICAL_CORE LFDS711_MISC_MAKE_VALID_ON_CURRENT_LOGICAL_CORE_INITS_COMPLETED_BEFORE_NOW_ON_ANY_OTHER_LOGICAL_CORE
63  #define lfds720_pal_uint_t lfds711_pal_uint_t
64 #else
65  #include "liblfds720.h"
66 #endif
67 #endif
68 #endif
69 
70 // ### Library structures
71 
73 
74  struct _fbg_rgb {
75  unsigned char r;
76  unsigned char g;
77  unsigned char b;
78  unsigned char a;
79  };
80 
82 
83  struct _fbg_hsl {
84  int h;
85  float s;
86  float l;
87  };
88 
90 
91  struct _fbg_img {
93  unsigned char *data;
94 
96  unsigned int width;
98  unsigned int height;
99  };
100 
102 
103  struct _fbg_font {
108 
113 
115  unsigned char first_char;
116 
118  struct _fbg_img *bitmap;
119  };
120 
122 
123  struct _fbg {
125  int size;
126 
128  unsigned char *disp_buffer;
130 
131  unsigned char *back_buffer;
133  unsigned char *temp_buffer;
134 
137 
140 
142 
143  struct _fbg_rgb fill_color;
144 
146 
147  struct _fbg_rgb text_color;
148 
150 
151  struct _fbg_rgb text_background;
152 
154 
155  unsigned char text_colorkey;
156 
158 
160 
162 
163  struct _fbg_font current_font;
164 
166 
168 
170  int width;
172  int height;
181 
186 
188 #ifdef FBG_PARALLEL
189  atomic_uint_fast16_t fps;
190 #else
191  int16_t fps;
192 #endif
193 
195  char fps_char[10];
196 
198  struct timeval fps_start;
200  struct timeval fps_stop;
201 
203  int frame;
204 
206  int bgr;
207 
209  void (*backend_resize)(struct _fbg *fbg, unsigned int new_width, unsigned int new_height);
211  void (*user_resize)(struct _fbg *fbg, unsigned int new_width, unsigned int new_height);
213  void (*user_flip)(struct _fbg *fbg);
215  void (*user_draw)(struct _fbg *fbg);
217  void (*user_free)(struct _fbg *fbg);
220 
222  //unsigned char *curr_task_buffer;
223 
224 #ifdef FBG_PARALLEL
225  unsigned int parallel_tasks;
227 
229  pthread_t *tasks;
230 
232  struct _fbg_fragment **fragments;
233 
235  pthread_barrier_t *sync_barrier;
236 
238  int task_id;
239 
241  atomic_int state;
242 
245  unsigned int fragment_queue_size;
246 #endif
247  };
248 
249 #ifdef FBG_PARALLEL
250 #ifdef FBG_LFDS
251 
253  struct _fbg_freelist_data {
254  struct lfds720_freelist_n_element freelist_element;
255 
256  unsigned char *buffer;
257  };
258  #endif
259 
261 
262  struct _fbg_fragment {
264  atomic_int state;
265 
267  struct _fbg *fbg;
268 
269 #ifdef FBG_LFDS
270  struct lfds720_ringbuffer_n_element *ringbuffer_element;
273  struct lfds720_ringbuffer_n_state *ringbuffer_state;
274 
276  struct lfds720_freelist_n_state *freelist_state;
277 
279  struct _fbg_freelist_data *fbg_freelist_data;
280 
282  struct _fbg_freelist_data *tmp_fbg_freelist_data;
283 #endif
284 
286  atomic_int sync_wait;
287 
289  void *(*user_fragment_start)(struct _fbg *fbg);
291  void (*user_fragment)(struct _fbg *fbg, void *user_data);
293  void (*user_fragment_stop)(struct _fbg *fbg, void *user_data);
294 
296  void *user_data;
297  };
298 #endif
299 
300 // ### Library functions
301 
303 
317  extern struct _fbg *fbg_customSetup(int width, int height, int components, int initialize_buffers, int allow_resizing, void *user_context, void (*user_draw)(struct _fbg *fbg), void (*user_flip)(struct _fbg *fbg), void (*backend_resize)(struct _fbg *fbg, unsigned int new_width, unsigned int new_height), void (*user_free)(struct _fbg *fbg));
318 
320 
324  extern void fbg_close(struct _fbg *fbg);
325 
327 
332  void fbg_setResizeCallback(struct _fbg *fbg, void (*user_resize)(struct _fbg *fbg, unsigned int new_width, unsigned int new_height));
333 
337 
343  extern void fbg_resize(struct _fbg *fbg, int new_width, int new_height);
344 
349 
355  extern void fbg_pushResize(struct _fbg *fbg, int new_width, int new_height);
356 
358 
363  extern void fbg_fadeDown(struct _fbg *fbg, unsigned char rgb_fade_amount);
364 
366 
371  extern void fbg_fadeUp(struct _fbg *fbg, unsigned char rgb_fade_amount);
372 
374 
379  extern void fbg_clear(struct _fbg *fbg, unsigned char brightness);
380 
382 
389  extern void fbg_fill(struct _fbg *fbg, unsigned char r, unsigned char g, unsigned char b);
390 
392 
398  extern void fbg_getPixel(struct _fbg *fbg, int x, int y, struct _fbg_rgb *color);
399 
401 
410  extern void fbg_pixel(struct _fbg *fbg, int x, int y, unsigned char r, unsigned char g, unsigned char b);
411 
413 
423  extern void fbg_pixela(struct _fbg *fbg, int x, int y, unsigned char r, unsigned char g, unsigned char b, unsigned char a);
424 
426 
432  extern void fbg_fpixel(struct _fbg *fbg, int x, int y);
433 
435 
441  extern void fbg_plot(struct _fbg *fbg, int index, unsigned char value);
442 
444 
455  extern void fbg_rect(struct _fbg *fbg, int x, int y, int w, int h, unsigned char r, unsigned char g, unsigned char b);
456 
458 
470  extern void fbg_recta(struct _fbg *fbg, int x, int y, int w, int h, unsigned char r, unsigned char g, unsigned char b, unsigned char a);
471 
473 
481  extern void fbg_frect(struct _fbg *fbg, int x, int y, int w, int h);
482 
484 
494  extern void fbg_hline(struct _fbg *fbg, int x, int y, int w, unsigned char r, unsigned char g, unsigned char b);
495 
497 
507  extern void fbg_vline(struct _fbg *fbg, int x, int y, int h, unsigned char r, unsigned char g, unsigned char b);
508 
510 
521  extern void fbg_line(struct _fbg *fbg, int x1, int y1, int x2, int y2, unsigned char r, unsigned char g, unsigned char b);
522 
524 
532  extern void fbg_polygon(struct _fbg *fbg, int num_vertices, int *vertices, unsigned char r, unsigned char g, unsigned char b);
533 
535 
542  extern void fbg_background(struct _fbg *fbg, unsigned char r, unsigned char g, unsigned char b);
543 
545 
552  extern void fbg_hslToRGB(struct _fbg_rgb *color, float h, float s, float l);
553 
555 
562  extern void fbg_rgbToHsl(struct _fbg_hsl *color, float r, float g, float b);
563 
564 #ifdef FBG_PARALLEL
565 
571  extern void fbg_draw(struct _fbg *fbg, void (*user_mixing)(struct _fbg *fbg, unsigned char *buffer, int task_id));
572 #else
573 
577  extern void fbg_draw(struct _fbg *fbg);
578 #endif
579 
581 
584  extern void fbg_flip(struct _fbg *fbg);
585 
587 
594  extern struct _fbg_img *fbg_createImage(struct _fbg *fbg, unsigned int width, unsigned int height);
595 
597 
603 #ifndef WITHOUT_PNG
604  extern struct _fbg_img *fbg_loadPNG(struct _fbg *fbg, const char *filename);
605 #endif
606 
608 
614 #ifndef WITHOUT_JPEG
615  extern struct _fbg_img *fbg_loadJPEG(struct _fbg *fbg, const char *filename);
616 #endif
617 
619 
625  extern struct _fbg_img *fbg_loadImage(struct _fbg *fbg, const char *filename);
626 
628 
635  extern void fbg_image(struct _fbg *fbg, struct _fbg_img *img, int x, int y);
636 
638 
648  extern void fbg_imageColorkey(struct _fbg *fbg, struct _fbg_img *img, int x, int y, int cr, int cg, int cb);
649 
651 
662  extern void fbg_imageClip(struct _fbg *fbg, struct _fbg_img *img, int x, int y, int cx, int cy, int cw, int ch);
663 
665 
669  extern void fbg_imageFlip(struct _fbg_img *img);
670 
672 
685  extern void fbg_imageEx(struct _fbg *fbg, struct _fbg_img *img, int x, int y, float sx, float sy, int cx, int cy, int cw, int ch);
686 
688 
692  extern void fbg_freeImage(struct _fbg_img *img);
693 
695 
704  extern struct _fbg_font *fbg_createFont(struct _fbg *fbg, struct _fbg_img *img, int glyph_width, int glyph_height, unsigned char first_char);
705 
707 
712  extern void fbg_textFont(struct _fbg *fbg, struct _fbg_font *font);
713 
715 
722  extern void fbg_textColor(struct _fbg *fbg, unsigned char r, unsigned char g, unsigned char b);
723 
725 
733  extern void fbg_textBackground(struct _fbg *fbg, int r, int g, int b, int a);
734 
736 
741  extern void fbg_textColorKey(struct _fbg *fbg, unsigned char v);
742 
744 
755  extern void fbg_text(struct _fbg *fbg, struct _fbg_font *fnt, char *text, int x, int y, int r, int g, int b);
756 
758 
762  extern void fbg_freeFont(struct _fbg_font *font);
763 
765 
775  extern void fbg_drawFramerate(struct _fbg *fbg, struct _fbg_font *fnt, int task, int x, int y, int r, int g, int b);
776 
778 
783  extern int fbg_getFramerate(struct _fbg *fbg, int task);
784 
786 
790  extern void fbg_drawInto(struct _fbg *fbg, unsigned char *buffer);
791 
793 
798  extern float fbg_randf(float min, float max);
799 
800 #ifdef FBG_PARALLEL
801 
809  extern void fbg_createFragment(struct _fbg *fbg, void *(*fragment_start)(struct _fbg *fbg), void (*fragment)(struct _fbg *fbg, void *user_data), void (*fragment_stop)(struct _fbg *fbg, void *user_data), unsigned int parallel_tasks);
810 #endif
811 
812 // ### Helper functions
814 
819  #define fbg_fade(fbg, fade_amount) fbg_fadeDown(fbg, fade_amount)
820 
822 
829  #define fbg_write(fbg, text, x, y) fbg_text(fbg, &fbg->current_font, text, x, y, fbg->text_color.r, fbg->text_color.g, fbg->text_color.b)
830 
832 
841  #define fbg_imageScale(fbg, img, x, y, sx, sy) fbg_imageEx(fbg, img, x, y, sx, sy, 0, 0, img->width, img->height)
842 
844  #define _FBG_MAX(a,b) ((a) > (b) ? a : b)
845  #define _FBG_MIN(a,b) ((a) < (b) ? a : b)
847  #define _FBG_SGN(x) ((x<0)?-1:((x>0)?1:0))
849 
851  #define _FBG_DEGTORAD(angle_degree) ((angle_degree) * M_PI / 180.0)
852  #define _FBG_RADTODEG(angle_radians) ((angle_radians) * 180.0 / M_PI)
854 
855  #define _FBG_SOURCE_OVER(a,b,c) (c * a + b * (1.f - a))
856 #endif
unsigned char b
Definition: fbgraphics.h:77
void fbg_text(struct _fbg *fbg, struct _fbg_font *fnt, char *text, int x, int y, int r, int g, int b)
draw a text
void fbg_imageClip(struct _fbg *fbg, struct _fbg_img *img, int x, int y, int cx, int cy, int cw, int ch)
draw a clipped image
struct _fbg_font * fbg_createFont(struct _fbg *fbg, struct _fbg_img *img, int glyph_width, int glyph_height, unsigned char first_char)
create a bitmap font from an image
unsigned char first_char
First ASCII character of the bitmap font file.
Definition: fbgraphics.h:115
int text_alpha
Text background alpha value.
Definition: fbgraphics.h:159
void fbg_setResizeCallback(struct _fbg *fbg, void(*user_resize)(struct _fbg *fbg, unsigned int new_width, unsigned int new_height))
register a user resize callback
void(* user_draw)(struct _fbg *fbg)
User-defined draw function.
Definition: fbgraphics.h:215
int initialize_buffers
Wether to allow FBG to allocate its internal buffers.
Definition: fbgraphics.h:139
int components
Display components amount (3 = 24 BPP / 4 = 32 BPP)
Definition: fbgraphics.h:176
unsigned char * back_buffer
Back buffer.
Definition: fbgraphics.h:131
void fbg_drawFramerate(struct _fbg *fbg, struct _fbg_font *fnt, int task, int x, int y, int r, int g, int b)
draw the framerate of a particular parallel task
int glyph_width
Width of a glyph.
Definition: fbgraphics.h:110
void fbg_imageFlip(struct _fbg_img *img)
flip an image vertically
struct _fbg_img * fbg_loadImage(struct _fbg *fbg, const char *filename)
load an image (PNG or JPEG)
RGBA color data structure.
Definition: fbgraphics.h:74
unsigned char a
Definition: fbgraphics.h:78
void fbg_clear(struct _fbg *fbg, unsigned char brightness)
fast grayscale background clearing
void fbg_textColorKey(struct _fbg *fbg, unsigned char v)
set the current text color key
struct _fbg_img * fbg_loadPNG(struct _fbg *fbg, const char *filename)
load a PNG image from a file (lodePNG library)
struct _fbg * fbg_customSetup(int width, int height, int components, int initialize_buffers, int allow_resizing, void *user_context, void(*user_draw)(struct _fbg *fbg), void(*user_flip)(struct _fbg *fbg), void(*backend_resize)(struct _fbg *fbg, unsigned int new_width, unsigned int new_height), void(*user_free)(struct _fbg *fbg))
initialize a FB Graphics context (typically used by a custom rendering backend)
int size
Framebuffer real data length (with BPP)
Definition: fbgraphics.h:125
void fbg_textColor(struct _fbg *fbg, unsigned char r, unsigned char g, unsigned char b)
set the current text color
unsigned char r
Definition: fbgraphics.h:75
void fbg_rect(struct _fbg *fbg, int x, int y, int w, int h, unsigned char r, unsigned char g, unsigned char b)
draw a rectangle
int width
Display width in pixels.
Definition: fbgraphics.h:170
void fbg_fpixel(struct _fbg *fbg, int x, int y)
fast pixel drawing which use the fill color set by fbg_fill()
int new_width
Requested new display width (resize event)
Definition: fbgraphics.h:183
int new_height
Requested new display height (resize event)
Definition: fbgraphics.h:185
void(* user_flip)(struct _fbg *fbg)
User-defined flip function.
Definition: fbgraphics.h:213
int allow_resizing
Wether to allow context resize.
Definition: fbgraphics.h:136
void fbg_fadeDown(struct _fbg *fbg, unsigned char rgb_fade_amount)
background fade to black with controllable factor
int line_length
Internal buffers line length.
Definition: fbgraphics.h:180
int width_n_height
Display lenght in pixels (width * height)
Definition: fbgraphics.h:174
void fbg_background(struct _fbg *fbg, unsigned char r, unsigned char g, unsigned char b)
clear the background with a color
int height
Display height in pixels.
Definition: fbgraphics.h:172
void fbg_recta(struct _fbg *fbg, int x, int y, int w, int h, unsigned char r, unsigned char g, unsigned char b, unsigned char a)
draw a rectangle with alpha transparency
unsigned char * data
RGB image data (bpp depend on framebuffer settings)
Definition: fbgraphics.h:93
void(* user_free)(struct _fbg *fbg)
User-defined free function.
Definition: fbgraphics.h:217
unsigned char * temp_buffer
Temporary buffer.
Definition: fbgraphics.h:133
void fbg_imageColorkey(struct _fbg *fbg, struct _fbg_img *img, int x, int y, int cr, int cg, int cb)
draw an image with colorkeying support (image colorkey value will be ignored)
void(* backend_resize)(struct _fbg *fbg, unsigned int new_width, unsigned int new_height)
Backend resize function.
Definition: fbgraphics.h:209
void fbg_rgbToHsl(struct _fbg_hsl *color, float r, float g, float b)
convert RGB values to HSL color
void fbg_pushResize(struct _fbg *fbg, int new_width, int new_height)
void fbg_flip(struct _fbg *fbg)
flip the buffers
void fbg_close(struct _fbg *fbg)
free up the memory associated with a FB Graphics context and close the framebuffer device ...
void fbg_polygon(struct _fbg *fbg, int num_vertices, int *vertices, unsigned char r, unsigned char g, unsigned char b)
draw a polygon
void fbg_image(struct _fbg *fbg, struct _fbg_img *img, int x, int y)
draw an image
int fbg_getFramerate(struct _fbg *fbg, int task)
get the framerate of a particular task
void fbg_textFont(struct _fbg *fbg, struct _fbg_font *font)
set the current font
int * glyph_coord_y
Pre-computed Y glyphs coordinates.
Definition: fbgraphics.h:107
void fbg_pixel(struct _fbg *fbg, int x, int y, unsigned char r, unsigned char g, unsigned char b)
draw a pixel
struct _fbg_img * bitmap
Associated font image data structure.
Definition: fbgraphics.h:118
void fbg_draw(struct _fbg *fbg)
draw to the screen
float s
Definition: fbgraphics.h:85
void fbg_fadeUp(struct _fbg *fbg, unsigned char rgb_fade_amount)
background fade to white with controllable factor
void * user_context
User-defined context structure.
Definition: fbgraphics.h:219
void fbg_freeImage(struct _fbg_img *img)
free the memory associated with an image
void(* user_resize)(struct _fbg *fbg, unsigned int new_width, unsigned int new_height)
User-defined resize function.
Definition: fbgraphics.h:211
float l
Definition: fbgraphics.h:86
void fbg_fill(struct _fbg *fbg, unsigned char r, unsigned char g, unsigned char b)
set the filling color for fast drawing operations
unsigned int height
Image height in pixels.
Definition: fbgraphics.h:98
int glyph_height
Height of a glyph.
Definition: fbgraphics.h:112
void fbg_freeFont(struct _fbg_font *font)
free the memory associated with a font
unsigned char text_colorkey
Current text color key.
Definition: fbgraphics.h:155
struct _fbg_img * fbg_loadJPEG(struct _fbg *fbg, const char *filename)
load a JPEG image from a file (NanoJPEG library)
void fbg_hslToRGB(struct _fbg_rgb *color, float h, float s, float l)
convert HSL values to RGB color
int comp_offset
Offset to add in case of 32 BPP.
Definition: fbgraphics.h:178
FB Graphics context data structure.
Definition: fbgraphics.h:123
void fbg_pixela(struct _fbg *fbg, int x, int y, unsigned char r, unsigned char g, unsigned char b, unsigned char a)
draw a pixel with alpha component (alpha blending)
void fbg_drawInto(struct _fbg *fbg, unsigned char *buffer)
set an offscreen target for all subsequent fbg context draw calls, it is important to reset back to d...
float fbg_randf(float min, float max)
pseudo random number between min / max
unsigned char g
Definition: fbgraphics.h:76
int16_t fps
Current FPS.
Definition: fbgraphics.h:191
unsigned int width
Image width in pixels.
Definition: fbgraphics.h:96
Bitmap font data structure.
Definition: fbgraphics.h:103
void fbg_vline(struct _fbg *fbg, int x, int y, int h, unsigned char r, unsigned char g, unsigned char b)
draw a vertical line
void fbg_textBackground(struct _fbg *fbg, int r, int g, int b, int a)
set the current text background color (based on colorkey value!)
struct _fbg_img * fbg_createImage(struct _fbg *fbg, unsigned int width, unsigned int height)
create an empty image
HSL color data structure.
Definition: fbgraphics.h:83
int bgr
Flag indicating a BGR framebuffer.
Definition: fbgraphics.h:206
unsigned char * disp_buffer
Front / display buffer.
Definition: fbgraphics.h:128
void fbg_plot(struct _fbg *fbg, int index, unsigned char value)
direct pixel access from index value
Image data structure.
Definition: fbgraphics.h:91
void fbg_imageEx(struct _fbg *fbg, struct _fbg_img *img, int x, int y, float sx, float sy, int cx, int cy, int cw, int ch)
draw an image with support for clipping and scaling (Nearest-neighbor algorithm)
void fbg_hline(struct _fbg *fbg, int x, int y, int w, unsigned char r, unsigned char g, unsigned char b)
draw a horizontal line
void fbg_resize(struct _fbg *fbg, int new_width, int new_height)
void fbg_getPixel(struct _fbg *fbg, int x, int y, struct _fbg_rgb *color)
get the RGB value of a pixel
void fbg_line(struct _fbg *fbg, int x1, int y1, int x2, int y2, unsigned char r, unsigned char g, unsigned char b)
draw a line from two points (Bresenham algorithm)
int compositing
Compositing method (only used with fbg_drawImage for now)
Definition: fbgraphics.h:167
int * glyph_coord_x
Pre-computed X glyphs coordinates.
Definition: fbgraphics.h:105
int frame
Frame counter for the current second.
Definition: fbgraphics.h:203
void fbg_frect(struct _fbg *fbg, int x, int y, int w, int h)
fast rectangle drawing which use the fill color set by fbg_fill()