Progmar Marcin Załęczny

Language:
We are using cookies in the page. If you use the page you agree for the cookies.      Close

VGE Resources Manager

Operating system: Ubuntu 20.04+

VGE Resources application gives to you possibility of creating and managing resources in your applications: image files, text files, audio files and binary files. It was created with developing video games on mind but also is useful for standard desktop applications - everywhere where is need to pack multiple files into single binaries.

Application also contains library which can be used to load resources in the your own programs written in C or C++.
There are available too three sample programs demonstrating how to use the libraray - first in console, second in GTK+ 3.0 and third in Vulkan+XCB.

New functionality in version: v1.1

  • Added preview of font files.
  • Added handlers for playing uncompressed *.wav files.

 

Listing below presents the shortest possible use case of the library. Lines related to library use (loading and releasing buffers) are written in strong.

#include <stdlib.h>
#include <stdio.h>
#include "../lib/vge-resources/include/vge-resources.h"

int main(int argc, char *argv[]) {
    char *buffer;
    size_t buffer_size;

    if (get_resource_by_name("resources.db", "test.txt", &buffer, &buffer_size, -1) == 0) {
        printf("Text from the resources: %s\n", buffer);
        printf("Returned size: %lu\n", buffer_size);
        printf("strlen of the text: %lu\n", strlen(buffer));
        printf("last byte: %d\n", buffer[buffer_size]);
        free(buffer);
    }

    return 0;
}

And a simplest example of windowed application:

#include <glib.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <gtk/gtk.h>
#include "../lib/vge-resources/include/vge-resources.h"

int main(int argc, char *argv[]) {
    gchar *buffer;
    gsize buffer_size;
    GdkPixbufLoader *loader;
    GdkPixbuf *pixbuf;
    GtkWidget *window, *scrolled_window;
    GtkWidget *image;

    gtk_init (&argc, &argv);

    if (get_resource_by_name("resources_gtk.db", "mms_img31238.jpg", &buffer, &buffer_size, -1) == 0) {
        loader = gdk_pixbuf_loader_new();
        gdk_pixbuf_loader_write(loader, buffer, buffer_size, NULL);
        pixbuf = gdk_pixbuf_loader_get_pixbuf(loader);
        free(buffer);

        window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
        gtk_window_set_default_size(GTK_WINDOW(window), 900, 700);
        scrolled_window = gtk_scrolled_window_new(NULL, NULL);
        image = gtk_image_new_from_pixbuf(pixbuf);
        gtk_container_add(GTK_CONTAINER(window), scrolled_window);
        gtk_container_add(GTK_CONTAINER(scrolled_window), image);
        gtk_widget_show_all(GTK_WIDGET(window));
        g_signal_connect(window, "destroy", gtk_main_quit, NULL);
        gtk_main();
    }

    return 0;
}

Third example attached to the program's tarball is demo of using animation and resources in app written in Vulcan SDK. Because of the sources length I do not insert it to this website.