Thanks to visit codestin.com
Credit goes to lib.rs

#game-cube #wii #tpl #gvr

gvrtex

gvrtex is a library for interfacing with the GVR texture format used on GameCube/Wii

3 releases

new 0.1.2 Sep 19, 2025
0.1.1 Jun 10, 2025
0.1.0 Apr 18, 2025

#395 in Game dev

Codestin Search App Codestin Search App Codestin Search App Codestin Search App Codestin Search App Codestin Search App Codestin Search App

135 downloads per month

MIT and GPL-3.0-or-later

76KB
1.5K SLoC

gvrtex

gvrtex is a Rust library for interfacing with the GVR texture format used in GameCube/Wii games, for example Sonic Riders. It's essentially the same as a regular TPL texture file (the official texture file format for GameCube/Wii), but with GVR headers instead. The image data in the file remains the same as it is for TPL files, so that the game console can read it.

More details on the GVR texture format can be found on the PuyoTools Wiki.

Examples

To encode an image into a GVR file (the supported image formats can be found here):

use gvrtex::error::TextureEncodeError;
use gvrtex::formats::DataFormat;
use gvrtex::TextureEncoder;

fn example(img_path: &str) -> Result<Vec<u8>, TextureEncodeError> {
    let mut encoder = TextureEncoder::new_gcix(DataFormat::Dxt1)?;
    let encoded_file = encoder.encode(img_path)?;
    Ok(encoded_file)
}

To encode a GVR file with a quantized color palette (can be 4-bit indexed or 8-bit indexed):

use gvrtex::error::TextureEncodeError;
use gvrtex::formats::{DataFormat, PixelFormat};
use gvrtex::TextureEncoder;

fn example(img_path: &str) -> Result<Vec<u8>, TextureEncodeError> {
    let mut encoder = TextureEncoder::new_gcix_palettized(PixelFormat::RGB5A3, DataFormat::Index8)?;
    let encoded_file = encoder.encode(img_path)?;
    Ok(encoded_file)
}

To decode a GVR file into the respective image file:

use gvrtex::error::TextureDecodeError;
use gvrtex::TextureDecoder;

fn example(gvr_path: &str, save_path: &str) -> Result<(), TextureDecodeError> {
    // Reads the contents of the file in gvr_path, but doesn't decode it yet.
    let mut decoder = TextureDecoder::new(gvr_path)?;

    // Decode file, saving the result in the decoder
    decoder.decode()?;

    // Save the decoded image to the given path. The image format is derived from the file
    // extension in the path.
    decoder.save(save_path)?;

    Ok(())
}

Credits

  • PuyoTools for the internal encoding and decoding algorithms, as well as information on the GVR file format.

Dependencies

~9.5MB
~194K SLoC