LibGame  v0.4.0
The LG Game Engine - Copyright (C) 2024 ETMSoftware
lg_background.c File Reference

Functions

int lg_draw_bg (int mode, int param_x, int param_y, const char *path)
 
void lg_clear_bg (uint8_t red, uint8_t green, uint8_t blue)
 
void lg_clear_bg_full (uint8_t red, uint8_t green, uint8_t blue, uint8_t alpha, GLbitfield mask)
 
void lg_bg_info ()
 
int lg_read_and_render_screen_back ()
 

Detailed Description

 === Draw background, and these sorts of things ===

Function Documentation

◆ lg_draw_bg()

int lg_draw_bg ( int  mode,
int  param_x,
int  param_y,
const char *  path 
)

Draw (full or windowed) background - load (once) or draw or free

=== ONLY ONE INSTANCE at a time ===

Should be able to handle, at least, TWO INSTANCES -> bg = lg_bg_new(), lg_bg_draw(), ...

  • if mode == LG_NEW, scale_x/y = param_x/y
  • if mode == LG_ON, shift_x/y = param_x/y

Would be convenient to be able to zoom in LG_ON mode

Parameters
modeLG_NEW or LG_ON
param_xSee above
param_ySee above
pathPath to image file
Returns
LG_OK if OK, LG_ERROR otherwise

◆ lg_clear_bg()

void lg_clear_bg ( uint8_t  red,
uint8_t  green,
uint8_t  blue 
)

Clear/paint with glClear(GL_COLOR_BUFFER_BIT) the viewport with colors - alpha = 255

NOTE: if followed by lg_swap_fb() without delay, and if a complete swap is needed, you may want to use glFinish() afterwards

Parameters
red
green
blue

◆ lg_clear_bg_full()

void lg_clear_bg_full ( uint8_t  red,
uint8_t  green,
uint8_t  blue,
uint8_t  alpha,
GLbitfield  mask 
)

glClear() everything then clear/paint the viewport with colors and mask

NOTE: if followed by lg_swap_fb() without delay, and if a complete swap is needed, you may want to use glFinish() afterwards

GLbitfield is 32-bit

Parameters
red
green
blue
alpha
maskBitwise OR of GL_COLOR_BUFFER_BIT, GL_DEPTH_BUFFER_BIT, GL_STENCIL_BUFFER_BIT

◆ lg_bg_info()

void lg_bg_info ( )

Print out background texture info, if set and valid

◆ lg_read_and_render_screen_back()

int lg_read_and_render_screen_back ( )

(Self-explanatory enough)

Returns
LG_OK if OK, LG_ERROR otherwise