![]() |
Parolin 0.7.9 6796
Console (soon DLLs) to do a tar like job
|
#include <stddef.h>#include <stdio.h>#include <stdlib.h>#include <string.h>#include <emscripten/emscripten.h>#include <emscripten/html5.h>#include <GLES2/gl2.h>#include <GLES2/gl2ext.h>#include "../zstddeclib.c"#include "testcard-zstd.inl"Data Structures | |
| struct | vec2 |
| struct | posTex2d |
Macros | |
| #define | DXT1_256x256 32768 |
| #define | GL_VERT_POSXY_ID 0 |
| #define | GL_VERT_TXUV0_ID 1 |
Functions | |
| size_t | ZSTD_decompress (void *dst, size_t dstLen, const void *src, size_t srcLen) |
| int | main () |
Emscripten example of using the single-file zstddeclib. Draws a rotating textured quad with data from the in-line Zstd compressed DXT1 texture (DXT1 being hardware compression, further compressed with Zstd).
Compile using:
| #define DXT1_256x256 32768 |
Uncompressed size of srcZstd.
| #define GL_VERT_POSXY_ID 0 |
Vertex position index.
| #define GL_VERT_TXUV0_ID 1 |
Vertex UV0 index.
| int main | ( | void | ) |
Creates the GL context, shaders and quad data, decompresses the Zstd data and 'uploads' the resulting texture.
As a (naive) comparison, removing Zstd and building with "-Os -g0 s WASM=1 -lGL emscripten.c" results in a 15kB WebAssembly file; re-adding Zstd increases the Wasm by 26kB.
| size_t ZSTD_decompress | ( | void * | dst, |
| size_t | dstLen, | ||
| const void * | src, | ||
| size_t | srcLen ) |
For the case where the decompression library hasn't been included we add a dummy function to fake the process and stop the buffers being optimised out.