Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/vavassor/ad_mipmap
a mipmap generator
https://github.com/vavassor/ad_mipmap
Last synced: about 4 hours ago
JSON representation
a mipmap generator
- Host: GitHub
- URL: https://github.com/vavassor/ad_mipmap
- Owner: Vavassor
- License: cc0-1.0
- Created: 2018-07-13T00:47:33.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-07-13T00:49:37.000Z (over 6 years ago)
- Last Synced: 2024-11-19T10:53:06.434Z (2 months ago)
- Language: C
- Size: 7.81 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# ad_mipmap.h
## Purpose
This is intended for creating mipmaps as part of an pre-run asset build or
as a no-fuss way to generate them that avoids involving any particular
graphics API. However, it will not run as quickly as when using a graphics
API. So, if updating mipmaps during a frame, or generating a substantial
volume at load time, consider another approach.For reference, a GPU-based approach usually involves setting up a source and
target image and using blit commands to copy and downscale from one to the
other.## Building
In exactly one C or C++ file that includes this file, add
#define AD_MIPMAP_IMPLEMENTATION
before the `#include` for this file. This will put the implementation into that
file.## Basic Usage
Fill out a `AdmBitmap` struct with a bitmap and pass it to
`adm_generate_mipmaps`.AdmBitmap bitmap;
bitmap.width = …;
bitmap.height = …;
bitmap.bytes_per_pixel = …;
bitmap.pixels = …;int levels;
AdmBitmap* mipmaps = adm_generate_mipmaps(&levels, &bitmap);`mipmaps` is an array which includes `bitmap` as the first element. Then, once
you're done, `adm_free_mipmaps` deallocates the array (including the original).adm_free_mipmaps(mipmaps, levels);
If you don't want the original to be in the returned array, use
`adm_generate_mipmaps_no_base`.## Memory Allocation
To use another memory allocator instead of `calloc` and `free`, define both of
the following before the `#include` that introduces the implementation.#define ADM_ALLOCATE(bytes, allocator) …
#define ADM_DEALLOCATE(memory, allocator) …## License
This code is public domain under the
[CC0 license](https://creativecommons.org/publicdomain/zero/1.0/).