cmftStudio Documentation

repository·master·Indexed 23 days ago

https://github.com/dariomanesku/cmftstudio

Documentation for cmftStudio, including installation guides for Windows and Linux, build instructions for macOS and Linux, and supported file formats for environment maps, textures, and meshes. Also includes technical details on the TinyDir C library for portable directory and file reading, and build configuration options for the project.

Tokens
2K
Snippets
2
Records
13
Agent score
80%

What's inside cmftStudio

  1. Build cmftStudio from source

    master

    To build the project from the source code, clone the repository with submodules and use make.

    git clone --recurse-submodules http://github.com/dariomanesku/cmftStudio.git
    cd cmftStudio
    make

    Platform Specific Build Instructions

    Linux

    Build the debug 64-bit version using:

    make linux-debug64

    To run the application, you must be in the runtime directory so it can find the configuration file:

    cd runtime
    ./../_build/linux64_gcc/bin/cmftStudioDebug

    OS X (Xcode)

    1. Open the Xcode solution located in _projects/xcode4/.
    2. Select your desired build configuration (debug/release, 32/64bit).
    3. To ensure a 64-bit build, set Build Settings -> Architectures -> Standard Architectures (64-bit Intel) (x86_64).
    4. Important: You must manually set the working directory to the runtime/ folder. Go to Product -> Scheme -> Edit Scheme... -> Run cmftDebug -> Options -> Working Directory (Use custom working directory) and specify the runtime/ directory from the cmft root folder.

    OS X (Makefile)

    Build from the root directory using:

    make osx-release64

    (or similar release commands).

  2. Install cmftStudio on Linux

    master

    On Linux, you can install the application to your system using make commands. This will create a desktop shortcut and place the binary in /usr/local/bin/cmftStudio.

    To install:

    sudo make linux-install

    To uninstall:

    sudo make linux-uninstall
  3. Iterate through directory contents with TinyDir

    master

    TinyDir provides two primary methods for reading directory contents: an iterative approach using tinydir_next and a sorted index-based approach using tinydir_open_sorted.

    Iterative Method

    Use tinydir_open to initialize the directory and a while loop checking dir.has_next to traverse files. Use tinydir_readfile to populate a tinydir_file structure with the current entry's metadata, then call tinydir_next to advance the iterator.

    Sorted Index Method

    Use tinydir_open_sorted to load the directory contents into a sorted list. You can then iterate through the directory using a standard for loop up to dir.n_files, accessing specific entries via tinydir_readfile_n using the index i.

    // Iterative Method
    tinydir_dir dir;
    tinydir_open(&dir, "/path/to/dir");
    
    while (dir.has_next)
    {
    	tinydir_file file;
    	tinydir_readfile(&dir, &file);
    
    	printf("%s", file.name);
    	if (file.is_dir)
    	{
    		printf("/");
    	}
    	printf("\n");
    
    	tinydir_next(&dir);
    }
    
    tinydir_close(&dir);
  4. Read sorted directory contents with TinyDir

    master

    To access directory files by index in a sorted order, use tinydir_open_sorted. This method populates the dir.n_files field, allowing you to loop through the directory using a fixed count and retrieve files via tinydir_readfile_n.

    tinydir_dir dir;
    int i;
    tinydir_open_sorted(&dir, "/path/to/dir");
    
    for (i = 0; i < dir.n_files; i++)
    {
    	tinydir_file file;
    	tinydir_readfile_n(&dir, &file, i);
    
    	printf("%s", file.name);
    	if (file.is_dir)
    	{
    		printf("/");
    	}
    	printf("\n");
    }
    
    tinydir_close(&dir);
  5. Configure the cmftStudio project build

    master

    The cmftStudio project is configured as a WindowedApp. It links against bgfx, example-common, and cmft.

    Key configuration details:

    • Debug Directory: Set to CMFTSTUDIO_RUNTIME_DIR.
    • Includes: Includes headers from bx, bgfx, dm, cmft, and the project's own dependency directory.
    • Platform Specifics:
      • *Windows (vs)**: Disables specific MSVC warnings (/wd 4127, /wd 4201, /wd 4345) and handles delay loading for libEGL.dll and libGLESv2.dll in vs2010 configurations.
      • Linux: Links against X11, GL, and pthread.
      • macOS (xcode4/osx): Links against Cocoa.framework and OpenGL.framework, and includes Khronos headers.
    • SDL Integration: If with-sdl is enabled, the ENTRY_CONFIG_USE_SDL=1 define is added and the SDL2 library is linked.
  6. TinyDir API Reference and Limitations

    master

    TinyDir is a lightweight C directory and file reader that wraps dirent for POSIX and FindFirstFile for Windows.

    Core API

    • tinydir_open(dir, path): Opens a directory for iterative reading.
    • tinydir_open_sorted(dir, path): Opens a directory and sorts the contents.
    • tinydir_readfile(dir, file): Reads the next file in the current iteration.
    • tinydir_readfile_n(dir, file, index): Reads a specific file by its index.
    • tinydir_next(dir): Advances the iterator.
    • tinydir_close(dir): Closes the directory handle.

    Data Structures

    • tinydir_dir: Represents the directory handle. Contains has_next (bool) and n_files (int).
    • tinydir_file: Represents a file entry. Contains name (string) and is_dir (bool).

    Known Limitations

    • Not threadsafe: Do not use the same tinydir_dir handle across multiple threads without external synchronization.
    • Limited path and filename sizes: Be aware of buffer constraints for long paths.
    • No wide char support: Does not support Unicode/wide characters (e.g., wchar_t).
  7. cmftStudio keyboard shortcuts and controls

    master

    Use the following controls to navigate the application:

    • Toggle Fullscreen: Ctrl/Meta + F (where supported)
    • Quit Application: Ctrl/Meta + Q
    • Middle Mouse Click (OSX): If you do not have a middle mouse button, use Command + Left click instead.
  8. Supported file formats in cmftStudio

    master

    cmftStudio supports various formats for environment maps, textures, and meshes.

    Environment Maps

    Input/Output Formats: *.dds, *.ktx, *.hdr, *.tga Input/Output Types: cubemap, cube cross, latlong, face list, horizontal and vertical strip.

    Textures

    Input Formats: *.dds, *.ktx, *.pvr

    Meshes

    Input Formats: *.obj, *.bin (bgfx binary format)