From 9e566c8b31b302c60381f775f2dace290e7a9937 Mon Sep 17 00:00:00 2001 From: Sean Barrett Date: Wed, 28 May 2014 11:05:17 -0700 Subject: [PATCH 1/4] trailing newline --- tests/image_test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/image_test.c b/tests/image_test.c index acaf33a..d49abdc 100644 --- a/tests/image_test.c +++ b/tests/image_test.c @@ -12,4 +12,4 @@ int main(int argc, char **argv) if (data) stbi_write_png("c:/x/result.png", w, h, 4, data, w*4); return 0; -} \ No newline at end of file +} From fcfcb9bb3f512b3eddfc3ad9f054f5de6b065fc6 Mon Sep 17 00:00:00 2001 From: Sean Barrett Date: Fri, 30 May 2014 14:15:51 -0700 Subject: [PATCH 2/4] generate README.md in part by parsing libraries so that version numbers are in sync --- README.md | 20 +++++----- stb.h | 5 +-- stb_c_lexer.h | 2 +- stb_image.c | 2 +- stb_image_write.h | 2 +- stb_perlin.h | 2 +- stb_vorbis.c | 2 +- tests/stb.dsw | 12 ++++++ tests/stb_cpp.dsp | 2 +- tools/README.footer.md | 65 +++++++++++++++++++++++++++++++ tools/README.header.md | 7 ++++ tools/README.list | 10 +++++ tools/make_readme.c | 45 +++++++++++++++++++++ tools/make_readme.dsp | 88 ++++++++++++++++++++++++++++++++++++++++++ 14 files changed, 244 insertions(+), 20 deletions(-) create mode 100644 tools/README.footer.md create mode 100644 tools/README.header.md create mode 100644 tools/README.list create mode 100644 tools/make_readme.c create mode 100644 tools/make_readme.dsp diff --git a/README.md b/README.md index b9aa121..93f4ffb 100644 --- a/README.md +++ b/README.md @@ -5,16 +5,16 @@ single-file public domain libraries for C/C++ library | lastest version | category | description --------------------- | ---- | -------- | -------------------------------- -**stb_vorbis.c** | 1.0 | audio | decode ogg vorbis files from file/memory to float/16-bit signed output -**stb_image.c** | 1.33 | graphics | image loading/decoding from file/memory: JPG, PNG, TGA, BMP, PSD, GIF, HDR, PIC -**stb_truetype.h** | 0.8 | graphics | parse, decode, and rasterize characters from truetype fonts -**stb_image_write.h** | 0.92 | graphics | image writing to disk: PNG, TGA, BMP -**stb_textedit.h** | 1.1 | UI | guts of a text editor for games etc implementing them from scratch -**stb_dxt.h** | 1.04 | 3D graphics | Fabian "ryg" Giesen's real-time DXT compressor -**stb_perlin.h** | 0.2 | 3D graphics | revised Perlin noise (3D input, 1D output) -**stb_c_lexer.h** | 0.04 | parsing | simplify writing parsers for C-like languages -**stb_divide.h** | 0.91 | math | more useful 32-bit modulus e.g. "euclidean divide" -**stb.h** | 2.23 | misc | helper functions for C, mostly redundant in C++; basically author's personal stuff +**stb_vorbis.c** | 1.0 | audio | decode ogg vorbis files from file/memory to float/16-bit signed output +**stb_image.c** | 1.35 | graphics | image loading/decoding from file/memory: JPG, PNG, TGA, BMP, PSD, GIF, HDR, PIC +**stb_truetype.h** | 0.8 | graphics | parse, decode, and rasterize characters from truetype fonts +**stb_image_write.h** | 0.93 | graphics | image writing to disk: PNG, TGA, BMP +**stb_textedit.h** | 1.2 | UI | guts of a text editor for games etc implementing them from scratch +**stb_dxt.h** | 1.04 | 3D graphics | Fabian "ryg" Giesen's real-time DXT compressor +**stb_perlin.h** | 0.2 | 3D graphics | revised Perlin noise (3D input, 1D output) +**stb_c_lexer.h** | 0.04 | parsing | simplify writing parsers for C-like languages +**stb_divide.h** | 0.91 | math | more useful 32-bit modulus e.g. "euclidean divide" +**stb.h** | 2.23 | misc | helper functions for C, mostly redundant in C++; basically author's personal stuff FAQ --- diff --git a/stb.h b/stb.h index c17246c..f903140 100644 --- a/stb.h +++ b/stb.h @@ -1,12 +1,9 @@ -/* stb-2.23 - Sean's Tool Box -- public domain -- http://nothings.org/stb.h +/* stb.h - v2.23 - Sean's Tool Box -- public domain -- http://nothings.org/stb.h no warranty is offered or implied; use this code at your own risk This is a single header file with a bunch of useful utilities for getting stuff done in C/C++. - Email bug reports, feature requests, etc. to 'sean' at the same site. - - Documentation: http://nothings.org/stb/stb_h.html Unit tests: http://nothings.org/stb/stb.c diff --git a/stb_c_lexer.h b/stb_c_lexer.h index c77e344..380992c 100644 --- a/stb_c_lexer.h +++ b/stb_c_lexer.h @@ -1,4 +1,4 @@ -// stb_c_lexer.h 0.04 -- public domain Sean Barrett 2013 +// stb_c_lexer.h - v0.04 - public domain Sean Barrett 2013 // lexer for making little C-like languages with recursive-descent parsers // // This file provides both the interface and the implementation. diff --git a/stb_image.c b/stb_image.c index 17bb2fe..de0d935 100644 --- a/stb_image.c +++ b/stb_image.c @@ -1,4 +1,4 @@ -/* stbi-1.35 - public domain JPEG/PNG reader - http://nothings.org/stb_image.c +/* stb_image - v1.35 - public domain JPEG/PNG reader - http://nothings.org/stb_image.c when you control the images you're loading no warranty implied; use at your own risk diff --git a/stb_image_write.h b/stb_image_write.h index d0617a9..4ad281a 100644 --- a/stb_image_write.h +++ b/stb_image_write.h @@ -1,4 +1,4 @@ -/* stbiw-0.93 - public domain - http://nothings.org/stb/stb_image_write.h +/* stb_image_write - v0.93 - public domain - http://nothings.org/stb/stb_image_write.h writes out PNG/BMP/TGA images to C stdio - Sean Barrett 2010 no warranty implied; use at your own risk diff --git a/stb_perlin.h b/stb_perlin.h index bdd6843..8ff7419 100644 --- a/stb_perlin.h +++ b/stb_perlin.h @@ -1,4 +1,4 @@ -// stb_perlin.h -- perlin noise -- v0.2 +// stb_perlin.h - v0.2 - perlin noise // public domain single-file C implementation by Sean Barrett // // to create the implementation, diff --git a/stb_vorbis.c b/stb_vorbis.c index 802032e..bb13e36 100644 --- a/stb_vorbis.c +++ b/stb_vorbis.c @@ -1,4 +1,4 @@ -// Ogg Vorbis audio decoder -- public domain -- version 1.0 +// Ogg Vorbis audio decoder - v1.0 - public domain // http://nothings.org/stb_vorbis/ // // Written by Sean Barrett in 2007, last updated in 2014 diff --git a/tests/stb.dsw b/tests/stb.dsw index c1448a5..c07ce5a 100644 --- a/tests/stb.dsw +++ b/tests/stb.dsw @@ -15,6 +15,18 @@ Package=<4> ############################################################################### +Project: "make_readme"=..\tools\make_readme\make_readme.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + Project: "stb"=.\stb.dsp - Package Owner=<4> Package=<5> diff --git a/tests/stb_cpp.dsp b/tests/stb_cpp.dsp index 7ab64f7..28e10cf 100644 --- a/tests/stb_cpp.dsp +++ b/tests/stb_cpp.dsp @@ -65,7 +65,7 @@ LINK32=link.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c -# ADD CPP /nologo /MTd /W3 /GX /Zd /Od /I "..\.." /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /MTd /W3 /GX /Zd /Od /I ".." /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG" BSC32=bscmake.exe diff --git a/tools/README.footer.md b/tools/README.footer.md new file mode 100644 index 0000000..1de705d --- /dev/null +++ b/tools/README.footer.md @@ -0,0 +1,65 @@ + +FAQ +--- + +#### What's the license? + +These libraries are in the public domain (or the equivalent where that is not +possible). You can do anything you want with them. You have no legal obligation +to 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; 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. + +#### 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-robust +way 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_image +is less for applications like image viewer apps (which need to support +every type of image under the sun) and more for things like games which +can choose what images to use, so I may decline to add them if they're +too 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/stb_howto.txt + +#### Why public domain? + +Because more people will use it. Because it's not viral, people +are not obligated to give back, so you could argue that it hurts +the *development* of it, and then because it doesn't develop as +well it's not as good, and then because it's not as good, in the +long run maybe fewer people will use it. I have total respect for +that 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 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. + + + diff --git a/tools/README.header.md b/tools/README.header.md new file mode 100644 index 0000000..66871d2 --- /dev/null +++ b/tools/README.header.md @@ -0,0 +1,7 @@ +stb +=== + +single-file public domain libraries for C/C++ + +library | lastest version | category | description +--------------------- | ---- | -------- | -------------------------------- diff --git a/tools/README.list b/tools/README.list new file mode 100644 index 0000000..5436e74 --- /dev/null +++ b/tools/README.list @@ -0,0 +1,10 @@ +stb_vorbis.c | audio | decode ogg vorbis files from file/memory to float/16-bit signed output +stb_image.c | graphics | image loading/decoding from file/memory: JPG, PNG, TGA, BMP, PSD, GIF, HDR, PIC +stb_truetype.h | graphics | parse, decode, and rasterize characters from truetype fonts +stb_image_write.h | graphics | image writing to disk: PNG, TGA, BMP +stb_textedit.h | UI | guts of a text editor for games etc implementing them from scratch +stb_dxt.h | 3D graphics | Fabian "ryg" Giesen's real-time DXT compressor +stb_perlin.h | 3D graphics | revised Perlin noise (3D input, 1D output) +stb_c_lexer.h | parsing | simplify writing parsers for C-like languages +stb_divide.h | math | more useful 32-bit modulus e.g. "euclidean divide" +stb.h | misc | helper functions for C, mostly redundant in C++; basically author's personal stuff diff --git a/tools/make_readme.c b/tools/make_readme.c new file mode 100644 index 0000000..c327a0f --- /dev/null +++ b/tools/make_readme.c @@ -0,0 +1,45 @@ +#define STB_DEFINE +#include "../stb.h" + +int main(int argc, char **argv) +{ + int i; + int hlen, flen, listlen; + char *header = stb_file("README.header.md", &hlen); + char *footer = stb_file("README.footer.md", &flen); + char **list = stb_stringfile("README.list", &listlen); + + FILE *f = fopen("../README.md", "wb"); + fwrite(header, 1, hlen, f); + + for (i=0; i < listlen; ++i) { + int num,j; + char **tokens = stb_tokens_stripwhite(list[i], "|", &num); + FILE *g = fopen(stb_sprintf("../%s", tokens[0]), "rb"); + char buffer[256], *s1, *s2; + fread(buffer, 1, 256, g); + fclose(g); + buffer[255] = 0; + s1 = strchr(buffer, '-'); + if (!s1) stb_fatal("Couldn't find '-' before version number in %s", tokens[0]); + s2 = strchr(s1+2, '-'); + if (!s2) stb_fatal("Couldn't find '-' after version number in %s", tokens[0]); + *s2 = 0; + s1 += 1; + s1 = stb_trimwhite(s1); + if (*s1 == 'v') ++s1; + fprintf(f, "**%s** | %s", tokens[0], s1); + s1 = stb_trimwhite(tokens[1]); + s2 = stb_dupreplace(s1, " ", " "); + fprintf(f, " | %s", s2); + free(s2); + for (j=2; j < num; ++j) + fprintf(f, " | %s", tokens[j]); + fprintf(f, "\n"); + } + + fwrite(footer, 1, flen, f); + fclose(f); + + return 0; +} \ No newline at end of file diff --git a/tools/make_readme.dsp b/tools/make_readme.dsp new file mode 100644 index 0000000..d235f3a --- /dev/null +++ b/tools/make_readme.dsp @@ -0,0 +1,88 @@ +# Microsoft Developer Studio Project File - Name="make_readme" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=make_readme - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "make_readme.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "make_readme.mak" CFG="make_readme - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "make_readme - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "make_readme - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "make_readme - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# 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:I386 +# 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:I386 + +!ELSEIF "$(CFG)" == "make_readme - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# 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:sept +# 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:sept + +!ENDIF + +# Begin Target + +# Name "make_readme - Win32 Release" +# Name "make_readme - Win32 Debug" +# Begin Source File + +SOURCE=.\make_readme.c +# End Source File +# End Target +# End Project From 5ecae715b0f8529610a34f34358d3695a0f8cf75 Mon Sep 17 00:00:00 2001 From: Sean Barrett Date: Fri, 30 May 2014 14:17:19 -0700 Subject: [PATCH 3/4] batch file to run make_readme --- mr.bat | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 mr.bat diff --git a/mr.bat b/mr.bat new file mode 100644 index 0000000..f86cfed --- /dev/null +++ b/mr.bat @@ -0,0 +1,3 @@ +cd tools +debug\make_readme +cd .. \ No newline at end of file From 2d412f0d6cb21171f89d2a4b5902fff4b0869af9 Mon Sep 17 00:00:00 2001 From: Sean Barrett Date: Fri, 30 May 2014 14:20:16 -0700 Subject: [PATCH 4/4] move stb_how.txt into docs directory --- docs/git_how.txt | 11 +++++++++++ tools/README.footer.md | 2 +- mr.bat => tools/mr.bat | 2 -- 3 files changed, 12 insertions(+), 3 deletions(-) create mode 100644 docs/git_how.txt rename mr.bat => tools/mr.bat (56%) diff --git a/docs/git_how.txt b/docs/git_how.txt new file mode 100644 index 0000000..2256ca6 --- /dev/null +++ b/docs/git_how.txt @@ -0,0 +1,11 @@ +git checkout working +-- do work +git add ... +git commit + +to upload: + +git checkout master +git pull ; usually unnecessary +git merge working +git push diff --git a/tools/README.footer.md b/tools/README.footer.md index 1de705d..d3ddc68 100644 --- a/tools/README.footer.md +++ b/tools/README.footer.md @@ -40,7 +40,7 @@ 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/stb_howto.txt +Yes. https://github.com/nothings/stb/blob/master/docs/stb_howto.txt #### Why public domain? diff --git a/mr.bat b/tools/mr.bat similarity index 56% rename from mr.bat rename to tools/mr.bat index f86cfed..475bc4f 100644 --- a/mr.bat +++ b/tools/mr.bat @@ -1,3 +1 @@ -cd tools debug\make_readme -cd .. \ No newline at end of file