Tips and Tricks
Table of contents
- Ways to determine the version of VgaGames3
- How to compile a game with required files of VgaGames3 onboard
- How to save a screenshot of the current window
Contents
- Ways to determine the version of VgaGames3
-
Via command-shell
with vgagames3-config --version
or vgagames3-config --version-maior
or vgagames3-config --version-minor
-
On compiling with the definition VGAG3_VERSION
-
On runtime with the function VG3_version()
- How to compile a game with required files of VgaGames3 onboard
If the game shall run on a computer without having installed VgaGames3,
the required VgaGames3-files must be copied locally and shipped with the game.
Call
- vgagames3-config --copylocal
to create a new directory vgag3 and to copy all required files into it.
Execute the game binary always from the parent directory of vgag3
and don't change the directory, e.g. using chdir(),
because the required files will be searched relatively below vgag3.
- How to save a screenshot of the current window
To make a screenshot into a new image, use function VG3_image_clone(),
using the parameters rmem and rsize.
Following function creates a bitmap-file (.bmp) and writes the current window-content into it:#include <stdio.h> #include <stdlib.h> #include <string.h> #include <vgagames3.h> /* make a screenshot of actual window and save it into BMP-file * @param wstruct window-struct * @param filename to save screenshot into */ void make_screenshot(struct vg3_window *wstruct, const char *filename) { char *rmem; size_t rsize; struct vg3_image *img; if (wstruct == NULL || filename == NULL || *filename == '\0') { return; } /* clone window into image and get image data into rmem with size=rsize */ img = VG3_image_clone(wstruct, NULL, NULL, &rmem, &rsize); if (img != NULL) { FILE *ffp; /* write image data into file */ ffp = fopen(filename, "w"); if (ffp != NULL) { fwrite(rmem, 1, rsize, ffp); fclose(ffp); } /* clean up */ free(rmem); VG3_image_unload(wstruct, img); } }