libacfutils
A general purpose library of utility functions designed to make it easier to develop addons for the X-Plane flight simulator.
|
Go to the source code of this file.
Functions | |
lacf_gl_pic_t * | lacf_gl_pic_new (const char *path) |
lacf_gl_pic_t * | lacf_gl_pic_new_from_dir (const char *dirpath, const char *filename) |
void | lacf_gl_pic_destroy (lacf_gl_pic_t *pic) |
bool_t | lacf_gl_pic_load (lacf_gl_pic_t *pic) |
void | lacf_gl_pic_unload (lacf_gl_pic_t *pic) |
int | lacf_gl_pic_get_width (lacf_gl_pic_t *pic) |
int | lacf_gl_pic_get_height (lacf_gl_pic_t *pic) |
GLuint | lacf_gl_pic_get_tex (lacf_gl_pic_t *pic) |
void | lacf_gl_pic_draw (lacf_gl_pic_t *pic, vect2_t pos, vect2_t size, float alpha) |
void | lacf_gl_pic_draw_custom (lacf_gl_pic_t *pic, vect2_t pos, vect2_t size, GLuint prog) |
A simple subsystem that provides the ability to load and draw PNG images in an OpenGL context.
Use lacf_gl_pic_new() or lacf_gl_pic_new_from_dir() to load a gl_pic object from disk. When done with the image, use lacf_gl_pic_destroy() to free all resources associated with the pic.
To draw the image, use lacf_gl_pic_draw() or lacf_gl_pic_draw_custom().
Definition in file lacf_gl_pic.h.
void lacf_gl_pic_destroy | ( | lacf_gl_pic_t * | pic | ) |
Destroys and frees the memory associated with a gl_pic_t which was previously returned by lacf_gl_pic_new() or lacf_gl_pic_new_from_dir().
Definition at line 139 of file lacf_gl_pic.c.
Draws the image using the current X-Plane projection and modelview matrices. This makes it possible to use to draw either gauges into the panel texture, or windows during a window draw callback.
pos | Position of the lower left corner of the image relative to the coordinate system origin. |
size | The size of the image for drawing. You can pass NULL_VECT2 here to make the image draw using its native size. |
alpha | Floating point value 0-1 for partial alpha compositing. This is passed to the fragment shader in a uniform, to let the fragment shader perform partial alpha blending. |
Definition at line 251 of file lacf_gl_pic.c.
Draws the image using a custom OpenGL program. You can use this function to perform custom image compositing using your own shaders.
pos | Position of the lower left corner of the image relative to the coordinate system origin. |
size | The size of the image for drawing. You can pass NULL_VECT2 here to make the image draw using its native size. |
prog | The OpenGL program to use for drawing. You must bind this program before calling this function using glUseProgram(). The program must take the same inputs as glutils_draw_quads() for vertex positions. |
Definition at line 293 of file lacf_gl_pic.c.
int lacf_gl_pic_get_height | ( | lacf_gl_pic_t * | pic | ) |
Definition at line 214 of file lacf_gl_pic.c.
GLuint lacf_gl_pic_get_tex | ( | lacf_gl_pic_t * | pic | ) |
Definition at line 228 of file lacf_gl_pic.c.
int lacf_gl_pic_get_width | ( | lacf_gl_pic_t * | pic | ) |
Definition at line 200 of file lacf_gl_pic.c.
bool_t lacf_gl_pic_load | ( | lacf_gl_pic_t * | pic | ) |
A newly initialized gl_pic_t is normally lazy-loaded and no disk I/O is performed until the image is to be drawn. This function allows you to pre-load the image into VRAM before it is needed.
B_TRUE
if loading the image was successful (or the image was loaded already). B_FALSE
if loading the image failed, either due to disk I/O or an issue with the image format on disk. Definition at line 157 of file lacf_gl_pic.c.
lacf_gl_pic_t * lacf_gl_pic_new | ( | const char * | path | ) |
Initializes a new gl_pic_t with a PNG image file on disk.
Definition at line 99 of file lacf_gl_pic.c.
lacf_gl_pic_t * lacf_gl_pic_new_from_dir | ( | const char * | dirpath, |
const char * | filename | ||
) |
This is a convenience front-end function to lacf_gl_pic_new(), which lets you provide a containing directory and image filename separately. This can be useful when the directory is subject to change, but the filename isn't. The function concatenates the path components before passing them on to lacf_gl_pic_new().
Definition at line 120 of file lacf_gl_pic.c.
void lacf_gl_pic_unload | ( | lacf_gl_pic_t * | pic | ) |
If the image was loaded, unloads the image and frees GPU-side VRAM buffers. This can be used to reduce the memory footprint of images you don't plan to use for a longer time. Do not call this function just between each frame. If you plan on drawing the image repeatedly, just keep it loaded. If you do not plan to draw the image for a long time, unloading it can save on VRAM usage.
If the image was unloaded already, this function does nothing.
Definition at line 176 of file lacf_gl_pic.c.