GoldFish Engine
Quite simple and lightweight game engine
Loading...
Searching...
No Matches
gf_graphic.h File Reference

Graphic interface. More...

#include <gf_pre.h>
#include <gf_macro.h>
#include <gf_type/graphic.h>
#include <gf_type/draw.h>
#include <gf_type/texture.h>

Go to the source code of this file.

Macros

#define GF_GRAPHIC_2D   2
 Dimension parameter for 2D.
 
#define GF_GRAPHIC_3D   3
 Dimension parameter for 3D.
 
#define GF_SET_COLOR(color, red, green, blue, alpha)
 Macro to set color safely and shorter.
 

Functions

void gf_graphic_clear (gf_draw_t *draw)
 Clear the screen.
 
void gf_graphic_begin_2d (gf_draw_t *draw)
 Start 2D mode.
 
void gf_graphic_end_2d (gf_draw_t *draw)
 End 2D mode.
 
void gf_graphic_draw_texture_polygon (gf_draw_t *draw, gf_texture_t *texture, gf_graphic_color_t color, int dim, int npair,...)
 Draw polygon with texture.
 
void gf_graphic_fill_polygon (gf_draw_t *draw, gf_graphic_color_t color, int dim, int npair,...)
 Draw polygon.
 
void gf_graphic_perspective (gf_draw_t *draw, double fovy, double znear, double zfar)
 Set perspective.
 
void gf_graphic_set_camera (gf_draw_t *draw)
 Set camera.
 
double gf_graphic_text_width (gf_draw_t *draw, double size, const char *text)
 Calculate text width.
 
void gf_graphic_text (gf_draw_t *draw, double x, double y, double size, const char *text, gf_graphic_color_t color)
 Draw text.
 
void gf_graphic_fill_rect (gf_draw_t *draw, double x, double y, double w, double h, gf_graphic_color_t color)
 Draw filled rectangle.
 
void gf_graphic_draw_texture_2d (gf_draw_t *draw, double x, double y, double w, double h, gf_texture_t *texture, gf_graphic_color_t color)
 Draw rectangle with texture.
 

Detailed Description

Graphic interface.

Definition in file gf_graphic.h.

Macro Definition Documentation

◆ GF_GRAPHIC_2D

#define GF_GRAPHIC_2D   2

Dimension parameter for 2D.

Definition at line 26 of file gf_graphic.h.

◆ GF_GRAPHIC_3D

#define GF_GRAPHIC_3D   3

Dimension parameter for 3D.

Definition at line 32 of file gf_graphic.h.

◆ GF_SET_COLOR

#define GF_SET_COLOR (   color,
  red,
  green,
  blue,
  alpha 
)
Value:
color.r = (red); \
color.g = (green); \
color.b = (blue); \
color.a = (alpha)

Macro to set color safely and shorter.

Parameters
colorgf_graphic_color_t

Definition at line 39 of file gf_graphic.h.

Function Documentation

◆ gf_graphic_begin_2d()

void gf_graphic_begin_2d ( gf_draw_t draw)
extern

Start 2D mode.

Definition at line 22 of file gf_graphic.c.

◆ gf_graphic_clear()

void gf_graphic_clear ( gf_draw_t draw)
extern

Clear the screen.

Definition at line 26 of file gf_graphic.c.

◆ gf_graphic_draw_texture_2d()

void gf_graphic_draw_texture_2d ( gf_draw_t draw,
double  x,
double  y,
double  w,
double  h,
gf_texture_t texture,
gf_graphic_color_t  color 
)
extern

Draw rectangle with texture.

Definition at line 57 of file gf_graphic_common.c.

◆ gf_graphic_draw_texture_polygon()

void gf_graphic_draw_texture_polygon ( gf_draw_t draw,
gf_texture_t texture,
gf_graphic_color_t  color,
int  dim,
int  npair,
  ... 
)
extern

Draw polygon with texture.

Definition at line 28 of file gf_graphic.c.

◆ gf_graphic_end_2d()

void gf_graphic_end_2d ( gf_draw_t draw)
extern

End 2D mode.

Definition at line 24 of file gf_graphic.c.

◆ gf_graphic_fill_polygon()

void gf_graphic_fill_polygon ( gf_draw_t draw,
gf_graphic_color_t  color,
int  dim,
int  npair,
  ... 
)
extern

Draw polygon.

Definition at line 30 of file gf_graphic.c.

◆ gf_graphic_fill_rect()

void gf_graphic_fill_rect ( gf_draw_t draw,
double  x,
double  y,
double  w,
double  h,
gf_graphic_color_t  color 
)
extern

Draw filled rectangle.

Definition at line 19 of file gf_graphic_common.c.

◆ gf_graphic_perspective()

void gf_graphic_perspective ( gf_draw_t draw,
double  fovy,
double  znear,
double  zfar 
)
extern

Set perspective.

Parameters
drawDrawing interface
fovyFOV
znearDistance from viewer to the near clipping plane
zfarDistance from viewer to the far clipping plane

Definition at line 32 of file gf_graphic.c.

◆ gf_graphic_set_camera()

void gf_graphic_set_camera ( gf_draw_t draw)
extern

Set camera.

Parameters
drawDrawing interface

Definition at line 34 of file gf_graphic.c.

◆ gf_graphic_text()

void gf_graphic_text ( gf_draw_t draw,
double  x,
double  y,
double  size,
const char *  text,
gf_graphic_color_t  color 
)
extern

Draw text.

Definition at line 21 of file gf_graphic_common.c.

◆ gf_graphic_text_width()

double gf_graphic_text_width ( gf_draw_t draw,
double  size,
const char *  text 
)
extern

Calculate text width.

Returns
Text width

Definition at line 41 of file gf_graphic_common.c.