stb single-file public domain libraries for C/C++

Overview

stb

single-file public domain (or MIT licensed) libraries for C/C++

Noteworthy:

Most libraries by stb, except: stb_dxt by Fabian "ryg" Giesen, stb_image_resize by Jorge L. "VinoBS" Rodriguez, and stb_sprintf by Jeff Roberts.

library lastest version category LoC description
stb_vorbis.c 1.20 audio 5563 decode ogg vorbis files from file/memory to float/16-bit signed output
stb_image.h 2.26 graphics 7762 image loading/decoding from file/memory: JPG, PNG, TGA, BMP, PSD, GIF, HDR, PIC
stb_truetype.h 1.24 graphics 5011 parse, decode, and rasterize characters from truetype fonts
stb_image_write.h 1.15 graphics 1690 image writing to disk: PNG, TGA, BMP
stb_image_resize.h 0.96 graphics 2631 resize images larger/smaller with good quality
stb_rect_pack.h 1.00 graphics 628 simple 2D rectangle packer with decent quality
stb_ds.h 0.65 utility 1880 typesafe dynamic array and hash tables for C, will compile in C++
stb_sprintf.h 1.09 utility 1879 fast sprintf, snprintf for C/C++
stretchy_buffer.h 1.04 utility 263 typesafe dynamic array for C (i.e. approximation to vector<>), doesn't compile as C++
stb_textedit.h 1.13 user interface 1404 guts of a text editor for games etc implementing them from scratch
stb_voxel_render.h 0.89 3D graphics 3807 Minecraft-esque voxel rendering "engine" with many more features
stb_dxt.h 1.10 3D graphics 753 Fabian "ryg" Giesen's real-time DXT compressor
stb_perlin.h 0.5 3D graphics 428 revised Perlin noise (3D input, 1D output)
stb_easy_font.h 1.1 3D graphics 305 quick-and-dirty easy-to-deploy bitmap font for printing frame rate, etc
stb_tilemap_editor.h 0.41 game dev 4161 embeddable tilemap editor
stb_herringbone_wa... 0.7 game dev 1221 herringbone Wang tile map generator
stb_c_lexer.h 0.11 parsing 966 simplify writing parsers for C-like languages
stb_divide.h 0.93 math 430 more useful 32-bit modulus e.g. "euclidean divide"
stb_connected_comp... 0.96 misc 1049 incrementally compute reachability on grids
stb.h 2.37 misc 14454 helper functions for C, mostly redundant in C++; basically author's personal stuff
stb_leakcheck.h 0.6 misc 194 quick-and-dirty malloc/free leak-checking
stb_include.h 0.02 misc 295 implement recursive #include support, particularly for GLSL

Total libraries: 22 Total lines of C code: 56774

FAQ

What's the license?

These libraries are in the public domain. You can do anything you want with them. You have no legal obligation to do anything else, although I appreciate attribution.

They are also licensed under the MIT open source license, if you have lawyers who are unhappy with public domain. Every source file includes an explicit dual-license for you to choose from.

Are there other single-file public-domain/open source libraries with minimal dependencies out there?

Yes.

If I wrap an stb library in a new library, does the new library have to be public domain/MIT?

No, because it's public domain you can freely relicense it to whatever license your new library wants to be.

What's the deal with SSE support in GCC-based compilers?

stb_image will either use SSE2 (if you compile with -msse2) or will not use any SIMD at all, rather than trying to detect the processor at runtime and handle it correctly. As I understand it, the approved path in GCC for runtime-detection require you to use multiple source files, one for each CPU configuration. Because stb_image is a header-file library that compiles in only one source file, there's no approved way to build both an SSE-enabled and a non-SSE-enabled variation.

While we've tried to work around it, we've had multiple issues over the years due to specific versions of gcc breaking what we're doing, so we've given up on it. See https://github.com/nothings/stb/issues/280 and https://github.com/nothings/stb/issues/410 for examples.

Some of these libraries seem redundant to existing open source libraries. Are they better somehow?

Generally they're only better in that they're easier to integrate, easier to use, and easier to release (single file; good API; no attribution requirement). They may be less featureful, slower, and/or use more memory. If you're already using an equivalent library, there's probably no good reason to switch.

Can I link directly to the table of stb libraries?

You can use this URL to link directly to that list.

Why do you list "lines of code"? It's a terrible metric.

Just to give you some idea of the internal complexity of the library, to help you manage your expectations, or to let you know what you're getting into. While not all the libraries are written in the same style, they're certainly similar styles, and so comparisons between the libraries are probably still meaningful.

Note though that the lines do include both the implementation, the part that corresponds to a header file, and the documentation.

Why single-file headers?

Windows doesn't have standard directories where libraries live. That makes deploying libraries in Windows a lot more painful than open source developers on Unix-derivates generally realize. (It also makes library dependencies a lot worse in Windows.)

There's also a common problem in Windows where a library was built against a different version of the runtime library, which causes link conflicts and confusion. Shipping the libs as headers means you normally just compile them straight into your project without making libraries, thus sidestepping that problem.

Making them a single file makes it very easy to just drop them into a project that needs them. (Of course you can still put them in a proper shared library tree if you want.)

Why not two files, one a header and one an implementation? The difference between 10 files and 9 files is not a big deal, but the difference between 2 files and 1 file is a big deal. You don't need to zip or tar the files up, you don't have to remember to attach two files, etc.

Why "stb"? Is this something to do with Set-Top Boxes?

No, they are just the initials for my name, Sean T. Barrett. This was not chosen out of egomania, but as a moderately sane way of namespacing the filenames and source function names.

Will you add more image types to stb_image.h?

No. As stb_image use has grown, it has become more important for us to focus on security of the codebase. Adding new image formats increases the amount of code we need to secure, so it is no longer worth adding new formats.

Do you have any advice on how to create my own single-file library?

Yes. https://github.com/nothings/stb/blob/master/docs/stb_howto.txt

Why public domain?

I prefer it over GPL, LGPL, BSD, zlib, etc. for many reasons. Some of them are listed here: https://github.com/nothings/stb/blob/master/docs/why_public_domain.md

Why C?

Primarily, because I use C, not C++. But it does also make it easier for other people to use them from other languages.

Why not C99? stdint.h, declare-anywhere, etc.

I still use MSVC 6 (1998) as my IDE because it has better human factors for me than later versions of MSVC.

Issues
  • Requested libraries

    Requested libraries

    THIS THREAD IS FOR REQUESTING LIBRARIES, NOT FOR ADDITIONS TO OTHER_LIBS.

    Over the years, people have suggested the following ideas for stb libraries. Here are your options for these libraries, where appropriate.

    • ~~lexer~~
    • ~~image resizer~~
    • matrix library -- stb_vec.h is the beginnings of one
    • zip file handler -- consider miniz
    • flac audio decoder
    • adpcm audio decoder
    • Opus audio decoder -- why there is no stb_opus
    • crypto library -- consider TweetNaCl
    • wide-line rendering -- I have a bad version of this coming, need to think about good version
    • triangle-soup raycaster
    • key/value store
    • json parser -- consider one of the 4+ JSON parsers here
    • http -- consider one of the server or client libraries here
    • plotting & graphing -- I need to finish up stb_plot.h
    • unicode text shaping -- (Harfbuzz et al) my best guess from researching is that this isn't sufficiently documented in official Unicode documents (and other English documents) to write it purely from specs; needs language-specific expertise for each supported language
    • software-rendered photoshop layer & filter effects
    • pdb parsing/processing -- the "specification" is primarily source code, so this has the same problem as Opus above
    • C preprocessor -- consider fcpp; also, I actually need this for a C-with-statically-typed-NULL-checking tool I've been working on on-and-off, so I might do it
    • PhysFS-esque pak-file-esque handler with pluggable back-ends
    • JPEG RGBA file format
    • regex matching using stb's boyer-moore-esque SGREP algorithm
    • FFT -- consider KISS FFT
    • arbitrary precision math
    • portable networking
    • portable threading -- consider mts
    • SVD
    • speech synthesizer
    • fbx/obj/blender 3d-model loader -- consider https://github.com/syoyo/tinyobjloader
    • non-linear least squares and general solver, a la http://ceres-solver.org/
    • HAMT or other sophisticated data structure
    • mp3 decoder useful once the patents expire soon-ish
    • html paser/renderer
    new library 
    opened by nothings 46
  • support for seeking in stb_vorbis.c  (payment)

    support for seeking in stb_vorbis.c (payment)

    Someone has currently declared their intent to pursue this. Historically, multiple people have looked at this and given up, though, so it may re-open.

    stb_vorbis is this single-file C library for decoding ogg vorbis files: https://github.com/nothings/stb/blob/master/stb_vorbis.c

    stb_vorbis doesn't have correctly-working seek functionality (e.g. being able to say 'start playback from sample number 31415926').

    The payment for a correct implementation of this feature is 5000 USD. (It may go down again in a few months as the current amount is the sum of several individuals who may drop out if it doesn't get done soon enough.) Please let me know if you are working on it to make sure we don't end up with two people doing it at the same time, as only one correct implementation will be paid out.

    Requirements:

    • seeking must be sample-accurate
    • reasonably efficient (binary search, interpolation search, etc)
    • cannot generate an off-line index or scan the whole file at start
    • changes must be placed in the public domain
    • you can start with the existing non-working implementation of seek (see below) or start from scratch
    • you'll need to learn about both the ogg specification and the vorbis specification to do this (see the link below for some insight why)
    • I (@nothings) am available to provide guidance about what the existing code is doing (aka write better comments)

    Current status in the code:

    • there is a 2007 implementation of seeking in the code which doesn't work. I no longer remember the details of how it doesn't work. I wrote this document about the frustrations of trying to do a performance-optimal implementation: http://nothings.org/stb_vorbis/ogg_seek.txt but at this point I will accept some suboptimality.
    • the "pushdata" API supports an approximate seeking; this is satisfactory for the pushdata API but not for the normal ("pulldata") API. you can just ignore the pushdata case
    4 enhancement help wanted 1 stb_vorbis 
    opened by nothings 25
  • Crash with Floating Point Exception (Code 8) on bitmap load

    Crash with Floating Point Exception (Code 8) on bitmap load

    I've run into a floating point exception (code 8) trying to stbi_load a bitmap image, which loads if I save the image as a png or jpeg. I was able to run the program fine on my Linux distro (Ubuntu 17.04) but not on macOS Sierra.

    This is the image: https://drive.google.com/file/d/0B1z6l9DJ0EySbExqTFpkM0FkWk0/view?usp=sharing

    opened by benwiley4000 20
  • SSE2 jpeg decoding segfaults in mingw 32 bit builds

    SSE2 jpeg decoding segfaults in mingw 32 bit builds

    Hi Sean!

    I received a bug report on one of my libraries that relies on stb_image to do the image decoding. It took me a while to understand what was happening since i couldn't reproduce it, until the user mentioned that it was building for 32bits with mingw32 ( and i was building 64 bit builds ).

    It seems that the jpeg SSE2 decoder is failing strangely, since if i build with VC works just fine. Here's an image of the callstack when fails: fail.

    Here's a project to test the issue.

    I've also tested to cross-compile the project from linux and it also happens. I must say that i know nothing about SSE2 so i really can't help much with the bug. And AFAIK it's a 32bit mingw only problem, no problems so far in 32 or 64 bit builds in linux, and if i remember correctly, no problems in os x neither.

    Edit: I tried compiling with "-msse -msse2" enabled but didn't help.

    Regards

    2 bug 1 stb_image 
    opened by SpartanJ 20
  • stb_image: add png fuzz target

    stb_image: add png fuzz target

    This adds a fuzz target, dictionary and iphone png's for fuzzing the png reader. My plan is to eventually integrate with OSS-Fuzz which would continuously fuzz the code in stb_image.h.

    1 stb_image 
    opened by randy408 19
  • stb_image and stb_image_write: allow to use zlib for png compression

    stb_image and stb_image_write: allow to use zlib for png compression

    I noticed that the zlib compression in stb_image_write was rather poor compared to what the actual zlib library would do. For example saving an rgba image filled with the gray color (128,128,128,255) prodices a png of size 42KB. When I use zlib to compress the data instead of stb algorithm, I get 6.4KB.

    Many projects already use zlib, so I think having the option to use it would be nice, if that is not too much work.

    1 stb_image_write 
    opened by guillaumechereau 17
  • Error compiling stb.h in visual studio

    Error compiling stb.h in visual studio

    Hello I am having problems compiling stb.h Microsoft (R) C/C++ Optimizing Compiler Version 19.10.25019 for x64 stb.h version 2.30 Here are my includes just in case one of them is the problem

    #define STB_DEFINE
    #include "stb.h"
    #include "sdl/include/SDL.h"
    #define STB_IMAGE_IMPLEMENTATION
    #include "stb_image.h"
    #include <stdint.h>
    #include <cmath>
    #include "platform.h"
    
    #include <limits> 
    

    compile script

    
    cl -Od -Zo -Z7 ..\seville\win32_main.cpp -Fmwin32_main.map /link  -incremental:no -opt:ref user32.lib gdi32.lib winmm.lib opengl32.lib ..\seville\sdl\lib\x64\sdl2.lib
    

    here are the errors I get

    Microsoft (R) C/C++ Optimizing Compiler Version 19.10.25019 for x64
    Copyright (C) Microsoft Corporation.  All rights reserved.
    
    win32_main.cpp
    c:\users\computer\games\seville\stb.h(3365): warning C4311: 'type cast': pointer truncation from 'void *' to 'unsigned int'
    c:\users\computer\games\seville\stb.h(3414): warning C4311: 'type cast': pointer truncation from 'unsigned char *' to 'int'
    c:\users\computer\games\seville\stb.h(3740): warning C4311: 'type cast': pointer truncation from 'char *' to 'int'
    c:\users\computer\games\seville\stb.h(3759): warning C4311: 'type cast': pointer truncation from 'char *' to 'int'
    c:\users\computer\games\seville\stb.h(3767): warning C4311: 'type cast': pointer truncation from 'char *' to 'int'
    c:\users\computer\games\seville\stb.h(6528): warning C4312: 'type cast': conversion from 'unsigned int' to 'void *' of greater size
    c:\users\computer\games\seville\stb.h(6530): warning C4312: 'type cast': conversion from 'unsigned int' to 'void *' of greater size
    c:\users\computer\games\seville\stb.h(6963): error C2665: 'swprintf': none of the 2 overloads could convert all the argument types
    C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\corecrt_wstdio.h(1820): note: could be 'int swprintf(wchar_t *const ,const wchar_t *const ,...) throw()'
    C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\corecrt_wstdio.h(1463): note: or       'int swprintf(wchar_t *const ,const ::size_t,const wchar_t *const ,...)'
    c:\users\computer\games\seville\stb.h(6963): note: while trying to match the argument list '(stb__wchar [1024], int, const wchar_t [4], stb__wchar *)'
    c:\users\computer\games\seville\stb.h(6965): error C2665: 'swprintf': none of the 2 overloads could convert all the argument types
    C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\corecrt_wstdio.h(1820): note: could be 'int swprintf(wchar_t *const ,const wchar_t *const ,...) throw()'
    C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\corecrt_wstdio.h(1463): note: or       'int swprintf(wchar_t *const ,const ::size_t,const wchar_t *const ,...)'
    c:\users\computer\games\seville\stb.h(6965): note: while trying to match the argument list '(stb__wchar [1024], int, const wchar_t [5], stb__wchar *)'
    c:\users\computer\games\seville\stb.h(6983): error C2664: 'intptr_t _wfindfirst64(const wchar_t *,_wfinddata64_t *)': cannot convert argument 1 from 'stb__wchar [1024]' to 'const wchar_t *'
    c:\users\computer\games\seville\stb.h(6983): note: Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
    c:\users\computer\games\seville\stb.h(6990): error C2664: 'char *stb__to_utf8(stb__wchar *)': cannot convert argument 1 from 'wchar_t [260]' to 'stb__wchar *'
    c:\users\computer\games\seville\stb.h(6990): note: Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
    c:\users\computer\games\seville\stb.h(7007): error C2664: 'char *stb__to_utf8(stb__wchar *)': cannot convert argument 1 from 'wchar_t [260]' to 'stb__wchar *'
    c:\users\computer\games\seville\stb.h(7007): note: Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
    c:\users\computer\games\seville\stb.h(7045): warning C4477: 'printf' : format string '%08x' requires an argument of type 'unsigned int', but variadic argument 2 has type 'time_t'
    c:\users\computer\games\seville\stb.h(7045): note: consider using '%llx' in the format string
    c:\users\computer\games\seville\stb.h(7045): note: consider using '%Ix' in the format string
    c:\users\computer\games\seville\stb.h(7045): note: consider using '%I64x' in the format string
    c:\users\computer\games\seville\stb.h(7045): warning C4477: 'printf' : format string '%08x' requires an argument of type 'unsigned int', but variadic argument 3 has type '__time64_t'
    c:\users\computer\games\seville\stb.h(7045): note: consider using '%llx' in the format string
    c:\users\computer\games\seville\stb.h(7045): note: consider using '%Ix' in the format string
    c:\users\computer\games\seville\stb.h(7045): note: consider using '%I64x' in the format string
    c:\users\computer\games\seville\stb.h(7634): warning C4311: 'type cast': pointer truncation from 'void *' to 'stb_uint32'
    c:\users\computer\games\seville\stb.h(7641): warning C4311: 'type cast': pointer truncation from 'stb_ps *' to 'int'
    c:\users\computer\games\seville\stb.h(7653): warning C4311: 'type cast': pointer truncation from 'stb_ps *' to 'int'
    c:\users\computer\games\seville\stb.h(7680): warning C4311: 'type cast': pointer truncation from 'stb_ps *' to 'int'
    c:\users\computer\games\seville\stb.h(7681): warning C4311: 'type cast': pointer truncation from 'void *' to 'int'
    c:\users\computer\games\seville\stb.h(7722): warning C4311: 'type cast': pointer truncation from 'void *' to 'int'
    c:\users\computer\games\seville\stb.h(7726): warning C4311: 'type cast': pointer truncation from 'stb_ps *' to 'int'
    c:\users\computer\games\seville\stb.h(7775): warning C4311: 'type cast': pointer truncation from 'void *' to 'stb_uint32'
    c:\users\computer\games\seville\stb.h(7779): warning C4311: 'type cast': pointer truncation from 'void *' to 'stb_uint32'
    c:\users\computer\games\seville\stb.h(7806): warning C4311: 'type cast': pointer truncation from 'void *' to 'int'
    c:\users\computer\games\seville\stb.h(7808): warning C4311: 'type cast': pointer truncation from 'stb_ps *' to 'int'
    c:\users\computer\games\seville\stb.h(7867): warning C4311: 'type cast': pointer truncation from 'void *' to 'stb_uint32'
    c:\users\computer\games\seville\stb.h(7889): warning C4311: 'type cast': pointer truncation from 'stb_ps *' to 'int'
    c:\users\computer\games\seville\stb.h(7922): warning C4311: 'type cast': pointer truncation from 'void *' to 'stb_uint32'
    c:\users\computer\games\seville\stb.h(7943): warning C4311: 'type cast': pointer truncation from 'stb_ps *' to 'int'
    c:\users\computer\games\seville\stb.h(7969): warning C4311: 'type cast': pointer truncation from 'void *' to 'stb_uint32'
    c:\users\computer\games\seville\stb.h(7981): warning C4311: 'type cast': pointer truncation from 'stb_ps *' to 'int'
    c:\users\computer\games\seville\stb.h(8003): warning C4311: 'type cast': pointer truncation from 'void *' to 'stb_uint32'
    c:\users\computer\games\seville\stb.h(8017): warning C4311: 'type cast': pointer truncation from 'stb_ps *' to 'int'
    c:\users\computer\games\seville\stb.h(8039): warning C4311: 'type cast': pointer truncation from 'void *' to 'stb_uint32'
    c:\users\computer\games\seville\stb.h(8050): warning C4311: 'type cast': pointer truncation from 'stb_ps *' to 'int'
    c:\users\computer\games\seville\stb.h(8074): warning C4311: 'type cast': pointer truncation from 'stb_ps *' to 'int'
    c:\users\computer\games\seville\stb.h(9121): warning C4838: conversion from 'int' to 'stb_int16' requires a narrowing conversion
    c:\users\computer\games\seville\stb.h(9121): warning C4838: conversion from 'int' to 'stb_uint16' requires a narrowing conversion
    c:\users\computer\games\seville\stb.h(9834): warning C4311: 'type cast': pointer truncation from 'char *' to 'int'
    c:\users\computer\games\seville\stb.h(9865): warning C4311: 'type cast': pointer truncation from 'char *' to 'int'
    c:\users\computer\games\seville\stb.h(9866): warning C4311: 'type cast': pointer truncation from 'char *' to 'int'
    c:\users\computer\games\seville\stb.h(10623): warning C4838: conversion from 'stb_uint' to 'stb_uchar' requires a narrowing conversion
    c:\users\computer\games\seville\stb.h(12373): warning C4311: 'type cast': pointer truncation from 'void *' to 'stb_uint32'
    c:\users\computer\games\seville\stb.h(12373): warning C4312: 'type cast': conversion from 'stb_uint32' to 'stb__span **' of greater size
    c:\users\computer\games\seville\stb.h(12392): warning C4311: 'type cast': pointer truncation from 'void *' to 'stb_uint32'
    c:\users\computer\games\seville\stb.h(12392): warning C4312: 'type cast': conversion from 'stb_uint32' to 'stb__span *' of greater size
    c:\users\computer\games\seville\stb.h(12473): warning C4311: 'type cast': pointer truncation from 'void *' to 'stb_uint32'
    c:\users\computer\games\seville\stb.h(12551): warning C4312: 'type cast': conversion from 'int' to 'char *' of greater size
    c:\users\computer\games\seville\stb.h(12628): warning C4312: 'type cast': conversion from 'int' to 'void *' of greater size
    c:\users\computer\games\seville\stb.h(12648): warning C4311: 'type cast': pointer truncation from 'void *' to 'stb_uint'
    c:\users\computer\games\seville\stb.h(12661): warning C4311: 'type cast': pointer truncation from 'void *' to 'stb_uint'
    

    Thanks for any help or insight you can give.

    new library 
    opened by powerc9000 16
  • stb_image can't load these png files (but they view OK in any other app)

    stb_image can't load these png files (but they view OK in any other app)

    I saved some png files on OSX. Via the screen capture, but also via resaving the file in Apple's Preview.app. And now the files don't load properly in stb_image.

    stb_fail1 stb_fail2 stb_fail3

    1 stb_image 
    opened by ghost 16
  • stb_image is it thread safe?

    stb_image is it thread safe?

    Hi, I am using stb_image to load texture for my game engine, all works nice and dandy but I am getting what I believe being race conditions inside stbi_load and I would like to know If that function is thread safe. What I am doing is really simple:

    auto data= stbi_load(path,&m_width, &m_height, 0, 0);

    This is at the start of my own Texture::load, that class is allocated on the heap right before calling the load, so no race condition can happen there ,the first line in load() is the stbi_load function you see. From time to time, an assertion from stbi_load (or any nested func call), is being triggered. The assertion is the following:

    Assertion failed: z->size[b] == s, file E:\WORK_IN_PROGRESS\C\libs\Simple-OpenGL-Image-Library\src\stb_image_aug.c, line 1750

    Which looking at the current version i have (to be honest the stb_image i am using came from SOIL, but i have bypassed it completely and called stb_image directly):

    `__forceinline static int zhuffman_decode(zbuf *a, zhuffman *z) { int b,s,k; if (a->num_bits < 16) fill_bits(a); b = z->fast[a->code_buffer & ZFAST_MASK]; if (b < 0xffff) { s = z->size[b]; a->code_buffer >>= s; a->num_bits -= s; return z->value[b]; }

    // not resolved by fast table, so compute it the slow way // use jpeg approach, which requires MSbits at top k = bit_reverse(a->code_buffer, 16); for (s=ZFAST_BITS+1; ; ++s) if (k < z->maxcode[s]) break; if (s == 16) return -1; // invalid code! // code size is s, so: b = (k >> (16-s)) - z->firstcode[s] + z->firstsymbol[s]; assert(z->size[b] == s); a->code_buffer >>= s; a->num_bits -= s; return z->value[b]; }`

    Now anyone know what could be triggering this? If I move just the stbi_func call inside a lock everything works perfectly, so I would be curious to know whats going on and how to prevent the assertion, having texture loading inside a lock is less than ideal and would rather avoid it.

    2 bug 1 stb_image 
    opened by giordi91 16
  • Fix the calculation of the input image shift when using subpixel regions

    Fix the calculation of the input image shift when using subpixel regions

    Includes some more tests which had incorrect results before, but work fine with the included fixes. The test does a subpixel region that slides from [0, 0.5] to [0.5, 1] for both upsampling and downsampling. I think that should cover all of the uses of the subpixel stuff. I'm not bothering with s < 0 or t > 1 because I don't think we ever intended to support that in the first place. At the very least, non-subpixel stuff is unaffected because s0 = t0 = 0 means in_shift = 0.

    2 bug 1 stb library w/no tag 
    opened by BSVino 16
  • stb_vorbis.c fails to compile because of __forceinline (windows cross-compile)

    stb_vorbis.c fails to compile because of __forceinline (windows cross-compile)

    I'm compiling my application in a Debian x64 box, using an Windows cross-compilation toolchain.

    The error message is:

    In file included from ../retroluxury/src/rl_sound.c:25:0:
    ../retroluxury/src/stb_vorbis.c:941:1: error: multiple storage classes in declaration specifiers
     static __forceinline uint32 crc32_update(uint32 crc, uint8 byte)
     ^
    

    followed by four more identical errors at lines 1558, 2042, and 2599.

    __forceinline default definition has extern in it, as the error message shows when I add #define __forceinline to std_vorbis.c:

    In file included from ../retroluxury/src/rl_sound.c:25:0:
    ../retroluxury/src/stb_vorbis.c:565:0: warning: "__forceinline" redefined [enabled by default]
     #define __forceinline
     ^
    In file included from /opt/mingw64/x86_64-w64-mingw32/include/crtdefs.h:10:0,
                     from /opt/mingw64/x86_64-w64-mingw32/include/stdint.h:28,
                     from /opt/mingw64/lib/gcc/x86_64-w64-mingw32/4.9.0/include/stdint.h:9,
                     from ../retroluxury/src/rl_sound.h:6,
                     from ../retroluxury/src/rl_sound.c:1:
    /opt/mingw64/x86_64-w64-mingw32/include/_mingw.h:263:0: note: this is the location of the previous definition
     #define __forceinline extern __inline__ __attribute__((__always_inline__,__gnu_inline__))
     ^
    

    and it clashes with the functions declarations which are static.

    I'm not sure how to fix this without redefining __forceinline in std_vorbis.c.

    2 bug 1 stb_vorbis 
    opened by leiradel 15
  • stb_include: use const-correct interface

    stb_include: use const-correct interface

    stb_include's interface should be const-correct to give the programmer guarantees about their arguments and to prevent the need for an explicit cast to pass const char*s (e.g. string literals) to read-only parameters.

    opened by JuanDiegoMontoya 0
  • stb_truetype: .notdef / Tofublock sometimes ignored

    stb_truetype: .notdef / Tofublock sometimes ignored

    Describe the bug For some fonts, stb_truetype fails to bake the .notdef glyph, which results in font atlases without it. This becomes a possible issue when you hit a non-baked glyph and no fallback is present, which result in SefFaults of the target app.

    This has been documented in Nuklear's Complete font-guide's "always bake the questionmark" chapter.

    E.g.: Baking the FontAwesome font results in a properly baked tofu block. (yummy)

    But even though .notdef is defined in the Google Noto font, no tofu block is found in the final font atlas.

    opened by FrostKiwi 1
  • Use 64-bit integer value for sample offsets

    Use 64-bit integer value for sample offsets

    Fixes #1329

    This PR also includes code for #1295 (to don't re-do the same work another time. If merge this first, please CLOSE THE #1295)

    P.S. Better squish this PR when merging.

    2 bug 1 stb_vorbis 
    opened by Wohlstand 0
  • stb_image: add trailing semicolon in usage example

    stb_image: add trailing semicolon in usage example

    Tiny little one-char change to stop the basic usage example from throwing a missing-semicolon error. This one's bugged me for years, I always end up metaphorically stubbing my toe on it, each time I copy-paste the usage example into my own code.

    Also wasn't sure whereabouts in the credits to put my name, or if such a tiny change even warrants it, let me know :)

    1 stb_image 2 good-no changes needed 3 documentation fix 2 add credit 
    opened by lunasorcery 0
  • stb_vorbis: Replace plain int with int64_t at offset/length related values

    stb_vorbis: Replace plain int with int64_t at offset/length related values

    Is your feature request related to a problem? Please describe. Having the plain signed 32-bit integer causes problems at OGG files with 198 kHz sample rate and over than 3 hours length (examples: several concert footages with the 5+ hours length), because signed 32-bit integer allows addressing ~3 hours of audio with 198 kHz sample rate. I highly recommend replacing it with the 64-bit integer to allow huge files to be played normally. Official Xiph Vorbis uses the int64_t to address sample offsets.

    Describe the solution you'd like Offset related values should use int64_t to extend the maximum range of sample addressing. As this library is never gets compiled as a shared library, there should no ABI breakages with such changes.

    4 enhancement 
    opened by Wohlstand 10
Abseil Common Libraries (C++)

Abseil - C++ Common Libraries The repository contains the Abseil C++ library code. Abseil is an open-source collection of C++ code (compliant to C++11

Abseil 10.5k Jun 21, 2022
Basic Development Environment - a set of foundational C++ libraries used at Bloomberg.

BDE Libraries This repository contains the BDE libraries, currently BSL (Basic Standard Library), BDL (Basic Development Library), BAL (Basic Applicat

Bloomberg 1.4k Jun 27, 2022
C++14 evented IO libraries for high performance networking and media based applications

LibSourcey C++ Networking Evolved LibSourcey is a collection of cross platform C++14 modules and classes that provide developers with an arsenal for r

Sourcey 1.2k Jun 9, 2022
stb single-file public domain libraries for C/C++

stb single-file public domain (or MIT licensed) libraries for C/C++ Noteworthy: image loader: stb_image.h image writer: stb_image_write.h image resize

Sean Barrett 19.2k Jun 28, 2022
Single header lib for JPEG encoding. Public domain. C99. stb style.

tiny_jpeg.h A header-only public domain implementation of Baseline JPEG compression. Features: stb-style header only library. Does not do dynamic allo

Sergio Gonzalez 192 Jun 19, 2022
Single header lib for JPEG encoding. Public domain. C99. stb style.

tiny_jpeg.h A header-only public domain implementation of Baseline JPEG compression. Features: stb-style header only library. Does not do dynamic allo

Sergio Gonzalez 192 Jun 19, 2022
Several single-file, cross-platform, public domain libraries for C/C++ that I use for learning / testing

HTC Several single-file, cross-platform, public domain libraries for C/C++ that I use for learning / testing (Not meant for production code). This is

Chris 8 Jun 28, 2022
A single file, public domain C implementation of aSchroeder reverb.

Introduction This is a reverb implementation based on Freeverb, a public domain reverb written by Jezar at Dreampoint in 2000. The library is written

Philip Bennefall 50 Jun 26, 2022
Single file public domain networking library

zed_net zed_net is a single file, public domain library that provides a simple wrapper around BSD sockets (Winsock 2.2 on Windows), intended primary f

Ian T. Jacobsen 51 Jun 1, 2022
A collection of public domain/unlicense single-file cryptography

simple-crypto A collection of single-file public domain/unlicense cryptographic functions in different programming languages. Feel free to copy-paste

null 5 May 16, 2022
linalg.h is a single header, public domain, short vector math library for C++

linalg.h linalg.h is a single header, public domain, short vector math library for C++. It is inspired by the syntax of popular shading and compute la

Sterling Orsten 724 Jun 23, 2022
The MHS Filesystem- A very simple linked-list based file system designed for recoverability and low data redundancy. Public domain filesystem (Version 1)

MHS Filesystem The MHS filesystem. Features: can be modified to work with any size of disk or sector, even non powers of two! Allocation bitmap stored

DMHSW 7 Feb 10, 2022
Public domain, header-only file to simplify the C programmer's life in their interaction with strings

SCL_String Public domain, header-only file to simplify the C programmer's life in their interaction with strings NOTE: This library is still under con

null 4 May 5, 2022
Public domain cross platform lock free thread caching 16-byte aligned memory allocator implemented in C

rpmalloc - General Purpose Memory Allocator This library provides a public domain cross platform lock free thread caching 16-byte aligned memory alloc

Mattias Jansson 1.5k Jun 27, 2022
Jittey - A public domain text editor written in C and Win32

Jittey (Jacob's Terrific Text Editor) is a single-file basic text editor written in pure C and Win32, there is no real reason to use it, but it

Jakub Šebek 24 Feb 22, 2022
⛳ Simple, extensible, header-only C++17 argument parser released into the public domain.

⛳ flags Simple, extensible, header-only C++17 argument parser released into the public domain. why requirements api get get (with default value) posit

sailormoon 198 Jun 18, 2022
Rpmalloc - Public domain cross platform lock free thread caching 16-byte aligned memory allocator implemented in C

rpmalloc - General Purpose Memory Allocator This library provides a public domain cross platform lock free thread caching 16-byte aligned memory alloc

Mattias Jansson 1.5k Jun 23, 2022
This is a minimal state immediate mode graphical user interface toolkit written in ANSI C and licensed under public domain

This is a minimal state immediate mode graphical user interface toolkit written in ANSI C and licensed under public domain. It was designed as a simple embeddable user interface for application and does not have any dependencies, a default render backend or OS window and input handling but instead provides a very modular library approach by using simple input state for input and draw commands describing primitive shapes as output.

Micha Mettke 13.4k Jun 22, 2022
super duper simple gui for C, wrapping imgui and stb

super duper simle gui for C, wrapping imgui and stb You can use it as a static library with cmake. See the example directory for a complete example. E

Rasmus 11 May 19, 2022
A collection of single-file C libraries. (generic containers, random number generation, argument parsing and other functionalities)

cauldron A collection of single-file C libraries and tools with the goal to be portable and modifiable. Libraries library description arena-allocator.

Camel Coder 31 Jun 17, 2022
A competitive programming helper tool, which packages included libraries into a single file, suitable for online judges.

cpack Cpack is a competitive programming helper tool, which packages the main source file along with included libraries into a single file, suitable f

PetarMihalj 11 Apr 22, 2022
POCO C++ Libraries are powerful cross-platform C++ libraries for building network

The POCO C++ Libraries are powerful cross-platform C++ libraries for building network- and internet-based applications that run on desktop, server, mobile, IoT, and embedded systems.

POCO C++ Libraries 6.2k Jun 21, 2022
A single file, single function, header to make notifications on the PS4 easier

Notifi Synopsis Adds a single function notifi(). It functions like printf however the first arg is the image to use (NULL and any invalid input should

Al Azif 7 Mar 24, 2022
convert elf file to single c/c++ header file

elf-to-c-header Split ELF to single C/C++ header file

Musa Ünal 2 Nov 4, 2021
Collection of cross-platform single-header C libraries for doing a lot of stuff! (Still WIP)

ice_libs Collection of cross-platform single-header C libraries for doing a lot of stuff! (Still WIP) Brief ice_libs is collection of Single-Header C

Rabia Alhaffar 112 May 19, 2022
A collection of std-like single-header C++ libraries

itlib: iboB's Template Libraries A collection of small single-header C++ libraries similar to or extending the C++ standard library. See below for a l

Borislav Stanimirov 72 Jun 20, 2022
Px - Single header C++ Libraries for Thread Scheduling, Rendering, and so on...

px 'PpluX' Single header C++(11/14) Libraries Name Code Description px_sched px_sched.h Task oriented scheduler. See more px_render px_render.h Multit

PpluX 439 Jun 24, 2022