Merge branch 'working'
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Sean Barrett · committed by Sean Barrett · parents f9ab452, 2d412f0 · Browse files · 16 files·+255 added−19 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
16 files+255 added−19 removed
- tests:+13 added−1 removed
- other:+242 added−18 removed
Provenance
- Commit
7ed3bb2- Tree
b9d5c37- Author
Sean Barrett <sean@nothings.org>- Committer
Sean Barrett <sean@nothings.org>- Parent 1
f9ab452- Parent 2
2d412f0
16 files changed+255 added−19 removed
added:docs/git_how.txt+11 added
1+git checkout working2+-- do work3+git add ...4+git commit5+6+to upload:7+8+git checkout master9+git pull ; usually unnecessary10+git merge working11+git pushmodified:tests/image_test.c+1 added-1 removed
10 unmodified lines11 unsigned char *data = stbi_load(argv[1], &w, &h, 0, 4);12 if (data)13 stbi_write_png("c:/x/result.png", w, h, 4, data, w*4);14 return 0;15-}15+}modified:tests/stb.dsw+12 added
13 unmodified lines14 }}}15 16 ###############################################################################17 18+Project: "make_readme"=..\tools\make_readme\make_readme.dsp - Package Owner=<4>19+20+Package=<5>21+{{{22+}}}23+24+Package=<4>25+{{{26+}}}27+28+###############################################################################29+30 Project: "stb"=.\stb.dsp - Package Owner=<4>31 32 Package=<5>33 {{{35 unmodified linesadded:tools/make_readme.c+45 added
1+#define STB_DEFINE2+#include "../stb.h"3+4+int main(int argc, char **argv)5+{6+ int i;7+ int hlen, flen, listlen;8+ char *header = stb_file("README.header.md", &hlen);9+ char *footer = stb_file("README.footer.md", &flen);10+ char **list = stb_stringfile("README.list", &listlen);11+12+ FILE *f = fopen("../README.md", "wb");13+ fwrite(header, 1, hlen, f);14+15+ for (i=0; i < listlen; ++i) {16+ int num,j;17+ char **tokens = stb_tokens_stripwhite(list[i], "|", &num);18+ FILE *g = fopen(stb_sprintf("../%s", tokens[0]), "rb");19+ char buffer[256], *s1, *s2;20+ fread(buffer, 1, 256, g);21+ fclose(g);22+ buffer[255] = 0;23+ s1 = strchr(buffer, '-');24+ if (!s1) stb_fatal("Couldn't find '-' before version number in %s", tokens[0]);25+ s2 = strchr(s1+2, '-');26+ if (!s2) stb_fatal("Couldn't find '-' after version number in %s", tokens[0]);27+ *s2 = 0;28+ s1 += 1;29+ s1 = stb_trimwhite(s1);30+ if (*s1 == 'v') ++s1;31+ fprintf(f, "**%s** | %s", tokens[0], s1);32+ s1 = stb_trimwhite(tokens[1]);33+ s2 = stb_dupreplace(s1, " ", " ");34+ fprintf(f, " | %s", s2);35+ free(s2);36+ for (j=2; j < num; ++j)37+ fprintf(f, " | %s", tokens[j]);38+ fprintf(f, "\n");39+ }40+41+ fwrite(footer, 1, flen, f);42+ fclose(f);43+44+ return 0;45+}added:tools/make_readme.dsp+88 added
1+# Microsoft Developer Studio Project File - Name="make_readme" - Package Owner=<4>2+# Microsoft Developer Studio Generated Build File, Format Version 6.003+# ** DO NOT EDIT **4+5+# TARGTYPE "Win32 (x86) Console Application" 0x01036+7+CFG=make_readme - Win32 Debug8+!MESSAGE This is not a valid makefile. To build this project using NMAKE,9+!MESSAGE use the Export Makefile command and run10+!MESSAGE 11+!MESSAGE NMAKE /f "make_readme.mak".12+!MESSAGE 13+!MESSAGE You can specify a configuration when running NMAKE14+!MESSAGE by defining the macro CFG on the command line. For example:15+!MESSAGE 16+!MESSAGE NMAKE /f "make_readme.mak" CFG="make_readme - Win32 Debug"17+!MESSAGE 18+!MESSAGE Possible choices for configuration are:19+!MESSAGE 20+!MESSAGE "make_readme - Win32 Release" (based on "Win32 (x86) Console Application")21+!MESSAGE "make_readme - Win32 Debug" (based on "Win32 (x86) Console Application")22+!MESSAGE 23+24+# Begin Project25+# PROP AllowPerConfigDependencies 026+# PROP Scc_ProjName ""27+# PROP Scc_LocalPath ""28+CPP=cl.exe29+RSC=rc.exe30+31+!IF "$(CFG)" == "make_readme - Win32 Release"32+33+# PROP BASE Use_MFC 034+# PROP BASE Use_Debug_Libraries 035+# PROP BASE Output_Dir "Release"36+# PROP BASE Intermediate_Dir "Release"37+# PROP BASE Target_Dir ""38+# PROP Use_MFC 039+# PROP Use_Debug_Libraries 040+# PROP Output_Dir "Release"41+# PROP Intermediate_Dir "Release"42+# PROP Target_Dir ""43+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c44+# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c45+# ADD BASE RSC /l 0x409 /d "NDEBUG"46+# ADD RSC /l 0x409 /d "NDEBUG"47+BSC32=bscmake.exe48+# ADD BASE BSC32 /nologo49+# ADD BSC32 /nologo50+LINK32=link.exe51+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I38652+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I38653+54+!ELSEIF "$(CFG)" == "make_readme - Win32 Debug"55+56+# PROP BASE Use_MFC 057+# PROP BASE Use_Debug_Libraries 158+# PROP BASE Output_Dir "Debug"59+# PROP BASE Intermediate_Dir "Debug"60+# PROP BASE Target_Dir ""61+# PROP Use_MFC 062+# PROP Use_Debug_Libraries 163+# PROP Output_Dir "Debug"64+# PROP Intermediate_Dir "Debug"65+# PROP Target_Dir ""66+# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c67+# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c68+# ADD BASE RSC /l 0x409 /d "_DEBUG"69+# ADD RSC /l 0x409 /d "_DEBUG"70+BSC32=bscmake.exe71+# ADD BASE BSC32 /nologo72+# ADD BSC32 /nologo73+LINK32=link.exe74+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept75+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept76+77+!ENDIF 78+79+# Begin Target80+81+# Name "make_readme - Win32 Release"82+# Name "make_readme - Win32 Debug"83+# Begin Source File84+85+SOURCE=.\make_readme.c86+# End Source File87+# End Target88+# End Projectadded:tools/mr.bat+1 added
1+debug\make_readmeadded:tools/README.footer.md+65 added
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
FAQ---
#### What's the license?
These libraries are in the public domain (or the equivalent where that is notpossible). You can do anything you want with them. You have no legal obligationto do anything else, although I appreciate attribution.
#### If I wrap an stb library in a new library, does the new library have to be public domain?
No.
#### A lot 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; noattribution requirement). They may be less featureful, slower,and/or use more memory. If you're already using an equivalentlibrary, there's probably no good reason to switch.
#### 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 semi-robustway of namespacing the filenames and source function names.
#### Will you add more image types to stb_image.c?
If people submit them, I generally add them, but the goal of stb_imageis less for applications like image viewer apps (which need to supportevery type of image under the sun) and more for things like games whichcan choose what images to use, so I may decline to add them if they'retoo rare or if the size of implementation vs. apparent benefit is too low.
#### Are there other single-file public-domain libraries out there?
Yes. I'll put a list here when people remind me what they are.
#### 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?
Because more people will use it. Because it's not viral, peopleare not obligated to give back, so you could argue that it hurtsthe *development* of it, and then because it doesn't develop aswell it's not as good, and then because it's not as good, in thelong run maybe fewer people will use it. I have total respect forthat opinion, but I just don't believe it myself for most software.
#### Why C?
Primarily, because I use C, not C++. But it does also make it easierfor 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 factorsfor me than later versions of MSVC.
added:tools/README.header.md+7 added
1234567stb===
single-file public domain libraries for C/C++
library | lastest version | category | description--------------------- | ---- | -------- | --------------------------------added:tools/README.list+10 added
1+stb_vorbis.c | audio | decode ogg vorbis files from file/memory to float/16-bit signed output2+stb_image.c | graphics | image loading/decoding from file/memory: JPG, PNG, TGA, BMP, PSD, GIF, HDR, PIC3+stb_truetype.h | graphics | parse, decode, and rasterize characters from truetype fonts4+stb_image_write.h | graphics | image writing to disk: PNG, TGA, BMP5+stb_textedit.h | UI | guts of a text editor for games etc implementing them from scratch6+stb_dxt.h | 3D graphics | Fabian "ryg" Giesen's real-time DXT compressor7+stb_perlin.h | 3D graphics | revised Perlin noise (3D input, 1D output)8+stb_c_lexer.h | parsing | simplify writing parsers for C-like languages9+stb_divide.h | math | more useful 32-bit modulus e.g. "euclidean divide"10+stb.h | misc | helper functions for C, mostly redundant in C++; basically author's personal stuffmodified:README.md+9 added-9 removed
3 unmodified lines4 single-file public domain libraries for C/C++5 6 library | lastest version | category | description7 --------------------- | ---- | -------- | --------------------------------8-**stb_vorbis.c** | 1.0 | audio | decode ogg vorbis files from file/memory to float/16-bit signed output9-**stb_image.c** | 1.35 | graphics | image loading/decoding from file/memory: JPG, PNG, TGA, BMP, PSD, GIF, HDR, PIC10-**stb_truetype.h** | 0.8 | graphics | parse, decode, and rasterize characters from truetype fonts8+**stb_vorbis.c** | 1.0 | audio | decode ogg vorbis files from file/memory to float/16-bit signed output9+**stb_image.c** | 1.35 | graphics | image loading/decoding from file/memory: JPG, PNG, TGA, BMP, PSD, GIF, HDR, PIC10+**stb_truetype.h** | 0.8 | graphics | parse, decode, and rasterize characters from truetype fonts11 **stb_image_write.h** | 0.93 | graphics | image writing to disk: PNG, TGA, BMP12-**stb_textedit.h** | 1.2 | UI | guts of a text editor for games etc implementing them from scratch13-**stb_dxt.h** | 1.04 | 3D graphics | Fabian "ryg" Giesen's real-time DXT compressor14-**stb_perlin.h** | 0.2 | 3D graphics | revised Perlin noise (3D input, 1D output)15-**stb_c_lexer.h** | 0.04 | parsing | simplify writing parsers for C-like languages16-**stb_divide.h** | 0.91 | math | more useful 32-bit modulus e.g. "euclidean divide"17-**stb.h** | 2.23 | misc | helper functions for C, mostly redundant in C++; basically author's personal stuff12+**stb_textedit.h** | 1.2 | UI | guts of a text editor for games etc implementing them from scratch13+**stb_dxt.h** | 1.04 | 3D graphics | Fabian "ryg" Giesen's real-time DXT compressor14+**stb_perlin.h** | 0.2 | 3D graphics | revised Perlin noise (3D input, 1D output)15+**stb_c_lexer.h** | 0.04 | parsing | simplify writing parsers for C-like languages16+**stb_divide.h** | 0.91 | math | more useful 32-bit modulus e.g. "euclidean divide"17+**stb.h** | 2.23 | misc | helper functions for C, mostly redundant in C++; basically author's personal stuff18 19 FAQ20 ---21 61 unmodified linesmodified:stb_c_lexer.h+1 added-1 removed
1-// stb_c_lexer.h 0.04 -- public domain Sean Barrett 20131+// stb_c_lexer.h - v0.04 - public domain Sean Barrett 20132 // lexer for making little C-like languages with recursive-descent parsers3 //4 // This file provides both the interface and the implementation.5 // To instantiate the implementation,801 unmodified linesmodified:stb_image_write.h+1 added-1 removed
1-/* stbiw-0.93 - public domain - http://nothings.org/stb/stb_image_write.h1+/* stb_image_write - v0.93 - public domain - http://nothings.org/stb/stb_image_write.h2 writes out PNG/BMP/TGA images to C stdio - Sean Barrett 20103 no warranty implied; use at your own risk4 5 508 unmodified linesmodified:stb_image.c+1 added-1 removed
1-/* stbi-1.35 - public domain JPEG/PNG reader - http://nothings.org/stb_image.c1+/* stb_image - v1.35 - public domain JPEG/PNG reader - http://nothings.org/stb_image.c2 when you control the images you're loading3 no warranty implied; use at your own risk4 5 QUICK NOTES:4673 unmodified linesmodified:stb_perlin.h+1 added-1 removed
1-// stb_perlin.h -- perlin noise -- v0.21+// stb_perlin.h - v0.2 - perlin noise2 // public domain single-file C implementation by Sean Barrett3 //4 // to create the implementation,5 // #define STB_PERLIN_IMPLEMENTATION170 unmodified linesmodified:stb_vorbis.c+1 added-1 removed
1-// Ogg Vorbis audio decoder -- public domain -- version 1.01+// Ogg Vorbis audio decoder - v1.0 - public domain2 // http://nothings.org/stb_vorbis/3 //4 // Written by Sean Barrett in 2007, last updated in 20145 // Sponsored by RAD Game Tools.5437 unmodified linesmodified:stb.h+1 added-4 removed
1-/* stb-2.23 - Sean's Tool Box -- public domain -- http://nothings.org/stb.h1+/* stb.h - v2.23 - Sean's Tool Box -- public domain -- http://nothings.org/stb.h2 no warranty is offered or implied; use this code at your own risk3 4 This is a single header file with a bunch of useful utilities5 for getting stuff done in C/C++.6 7- Email bug reports, feature requests, etc. to 'sean' at the same site.8-9-7 Documentation: http://nothings.org/stb/stb_h.html8 Unit tests: http://nothings.org/stb/stb.c9 10 14069 unmodified lines