libgui 2.01
libgui is a GUI library for the GameCube, Wii, and Wii U
 
Loading...
Searching...
No Matches
demo.cpp

Reference application wiring: creates the Platform, sizes the image decode scratch buffer, sets up the font and string table, starts audio and the storage device-checking thread, runs the menus, then joins background threads and exits.

Reference application wiring: creates the Platform, sizes the image decode scratch buffer, sets up the font and string table, starts audio and the storage device-checking thread, runs the menus, then joins background threads and exits. Start your own app from this file.

/****************************************************************************
* libgui Template
* Daryl Borth 2009-2026
* demo.cpp
* Basic template/demonstration of libgui capabilities. For a
* full-featured app using many more extensions, check out Snes9x GX.
***************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#ifdef __WIIU__
#include "drivers/wut/WutPlatform.h"
#elif defined(HW_DOL)
#include "drivers/ogc/gamecube/GameCubePlatform.h"
#else
#include "drivers/ogc/wii/WiiPlatform.h"
#endif
#include "menu.h"
#include "filelist.h"
#include "demo.h"
#include "filebrowser.h"
#include "libgui/Gui.h"
#include "drivers/Thread.h"
struct SSettings Settings;
#ifdef __WIIU__
static WutPlatform platformInstance;
#elif defined(HW_DOL)
static GameCubePlatform platformInstance;
#else
static WiiPlatform platformInstance;
#endif
Platform* platform = &platformInstance;
#if defined(HW_RVL) || defined(HW_DOL)
#define IMAGE_DECODE_SCRATCH_SIZE ((640 * 480 * 4) + (480 * sizeof(void*)))
#else
#define IMAGE_DECODE_SCRATCH_SIZE ((1920 * 1080 * 4) + (1080 * sizeof(void*)))
#endif
void DefaultSettings()
{
Settings.LoadMethod = METHOD_AUTO;
Settings.SaveMethod = METHOD_AUTO;
sprintf (Settings.Folder1,"libgui/first folder");
sprintf (Settings.Folder2,"libgui/second folder");
sprintf (Settings.Folder3,"libgui/third folder");
Settings.AutoLoad = AUTO_SOME;
Settings.AutoSave = AUTO_SOME;
sprintf(Settings.Smb.host, "192.168.0.100");
sprintf(Settings.Smb.share, "Files");
sprintf(Settings.Smb.user, "Demo");
sprintf(Settings.Smb.password, "password");
}
int main(int, char **)
{
PlatformConfig platformConfig;
platformConfig.canvasWidth = 640;
platformConfig.canvasHeight = 480;
#ifdef __WIIU__
platformConfig.assetScaleX = 3.0f;
platformConfig.assetScaleY = 2.25f;
#endif
platform->init(platformConfig);
GuiImageData::setDecodeScratch(malloc(IMAGE_DECODE_SCRATCH_SIZE), IMAGE_DECODE_SCRATCH_SIZE);
fontSystem = new GuiTextRenderer(font_ttf, font_ttf_size, platform->getVideo()->getGlyphRenderer(), platform->getVideo()->getUIScale());
textTranslator = new GuiTextTranslator();
textTranslator->loadLanguage(en_lang, en_lang_size);
platform->getAudio()->start();
DefaultSettings();
InitDeviceCheckingThread();
MainMenu(MENU_SETTINGS);
// the menu's shapes are gone: give back the meshes they shared, and the video backend's copies
platform->requestExit();
}
Umbrella header for the platform-agnostic libgui core.
GameCube (HW_DOL) Platform: same driver set as WiiPlatform except for file system,...
static void setDecodeScratch(void *buffer, unsigned int size)
Sets the scratch buffer that every decode (the PNG-decoding constructors, and reload()) will stage it...
static void flush()
Frees every mesh nothing is holding, including the backend's copies (call when leaving the menu to gi...
FreeType2-based glyph shaping/caching.
Hashed msgid -> UTF-8 string table loaded from a single binary .lang blob (see loadLanguage()).
Composition root for a platform.
Definition Platform.h:66
static void JoinAll()
Requests every currently-registered, still-running Thread stop (per its own wake callback,...
Definition Thread.cpp:78
Wii Platform, built on the shared GC/Wii driver set (OgcVideoDriver, OgcAudioDriver,...
Definition WiiPlatform.h:28
Wii U Platform: ProcUI application lifecycle plus the wut driver set.
Definition WutPlatform.h:23
Settings passed to Platform::init().
Definition Platform.h:50
int canvasHeight
Design canvas height in pixels (eg.
Definition Platform.h:52
float assetScaleX
Horizontal ratio of source art pixels to design-canvas pixels.
Definition Platform.h:56
int canvasWidth
Design canvas width in pixels (eg.
Definition Platform.h:51
float assetScaleY
Vertical counterpart of assetScaleX.
Definition Platform.h:58