├── README.md ├── docs ├── Makefile ├── make.bat └── source │ ├── api.rst │ ├── conf.py │ ├── guide.rst │ └── index.rst └── src └── tinylib.h /README.md: -------------------------------------------------------------------------------- 1 | Tiny Lib 2 | -------- 3 | 4 | A cross platform, one header only creative coding library. 5 | 6 | See [Read The Docs](http://tiny-lib.readthedocs.org) for the documentation. -------------------------------------------------------------------------------- /docs/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line. 5 | SPHINXOPTS = 6 | SPHINXBUILD = sphinx-build 7 | PAPER = 8 | BUILDDIR = build 9 | 10 | # User-friendly check for sphinx-build 11 | ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1) 12 | $(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/) 13 | endif 14 | 15 | # Internal variables. 16 | PAPEROPT_a4 = -D latex_paper_size=a4 17 | PAPEROPT_letter = -D latex_paper_size=letter 18 | ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source 19 | # the i18n builder cannot share the environment and doctrees with the others 20 | I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source 21 | 22 | .PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext 23 | 24 | help: 25 | @echo "Please use \`make ' where is one of" 26 | @echo " html to make standalone HTML files" 27 | @echo " dirhtml to make HTML files named index.html in directories" 28 | @echo " singlehtml to make a single large HTML file" 29 | @echo " pickle to make pickle files" 30 | @echo " json to make JSON files" 31 | @echo " htmlhelp to make HTML files and a HTML help project" 32 | @echo " qthelp to make HTML files and a qthelp project" 33 | @echo " devhelp to make HTML files and a Devhelp project" 34 | @echo " epub to make an epub" 35 | @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" 36 | @echo " latexpdf to make LaTeX files and run them through pdflatex" 37 | @echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx" 38 | @echo " text to make text files" 39 | @echo " man to make manual pages" 40 | @echo " texinfo to make Texinfo files" 41 | @echo " info to make Texinfo files and run them through makeinfo" 42 | @echo " gettext to make PO message catalogs" 43 | @echo " changes to make an overview of all changed/added/deprecated items" 44 | @echo " xml to make Docutils-native XML files" 45 | @echo " pseudoxml to make pseudoxml-XML files for display purposes" 46 | @echo " linkcheck to check all external links for integrity" 47 | @echo " doctest to run all doctests embedded in the documentation (if enabled)" 48 | 49 | clean: 50 | rm -rf $(BUILDDIR)/* 51 | 52 | html: 53 | $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html 54 | @echo 55 | @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." 56 | 57 | dirhtml: 58 | $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml 59 | @echo 60 | @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." 61 | 62 | singlehtml: 63 | $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml 64 | @echo 65 | @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." 66 | 67 | pickle: 68 | $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle 69 | @echo 70 | @echo "Build finished; now you can process the pickle files." 71 | 72 | json: 73 | $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json 74 | @echo 75 | @echo "Build finished; now you can process the JSON files." 76 | 77 | htmlhelp: 78 | $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp 79 | @echo 80 | @echo "Build finished; now you can run HTML Help Workshop with the" \ 81 | ".hhp project file in $(BUILDDIR)/htmlhelp." 82 | 83 | qthelp: 84 | $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp 85 | @echo 86 | @echo "Build finished; now you can run "qcollectiongenerator" with the" \ 87 | ".qhcp project file in $(BUILDDIR)/qthelp, like this:" 88 | @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/TinyLib.qhcp" 89 | @echo "To view the help file:" 90 | @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/TinyLib.qhc" 91 | 92 | devhelp: 93 | $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp 94 | @echo 95 | @echo "Build finished." 96 | @echo "To view the help file:" 97 | @echo "# mkdir -p $$HOME/.local/share/devhelp/TinyLib" 98 | @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/TinyLib" 99 | @echo "# devhelp" 100 | 101 | epub: 102 | $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub 103 | @echo 104 | @echo "Build finished. The epub file is in $(BUILDDIR)/epub." 105 | 106 | latex: 107 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 108 | @echo 109 | @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." 110 | @echo "Run \`make' in that directory to run these through (pdf)latex" \ 111 | "(use \`make latexpdf' here to do that automatically)." 112 | 113 | latexpdf: 114 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 115 | @echo "Running LaTeX files through pdflatex..." 116 | $(MAKE) -C $(BUILDDIR)/latex all-pdf 117 | @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." 118 | 119 | latexpdfja: 120 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 121 | @echo "Running LaTeX files through platex and dvipdfmx..." 122 | $(MAKE) -C $(BUILDDIR)/latex all-pdf-ja 123 | @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." 124 | 125 | text: 126 | $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text 127 | @echo 128 | @echo "Build finished. The text files are in $(BUILDDIR)/text." 129 | 130 | man: 131 | $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man 132 | @echo 133 | @echo "Build finished. The manual pages are in $(BUILDDIR)/man." 134 | 135 | texinfo: 136 | $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo 137 | @echo 138 | @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo." 139 | @echo "Run \`make' in that directory to run these through makeinfo" \ 140 | "(use \`make info' here to do that automatically)." 141 | 142 | info: 143 | $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo 144 | @echo "Running Texinfo files through makeinfo..." 145 | make -C $(BUILDDIR)/texinfo info 146 | @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo." 147 | 148 | gettext: 149 | $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale 150 | @echo 151 | @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale." 152 | 153 | changes: 154 | $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes 155 | @echo 156 | @echo "The overview file is in $(BUILDDIR)/changes." 157 | 158 | linkcheck: 159 | $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck 160 | @echo 161 | @echo "Link check complete; look for any errors in the above output " \ 162 | "or in $(BUILDDIR)/linkcheck/output.txt." 163 | 164 | doctest: 165 | $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest 166 | @echo "Testing of doctests in the sources finished, look at the " \ 167 | "results in $(BUILDDIR)/doctest/output.txt." 168 | 169 | xml: 170 | $(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml 171 | @echo 172 | @echo "Build finished. The XML files are in $(BUILDDIR)/xml." 173 | 174 | pseudoxml: 175 | $(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml 176 | @echo 177 | @echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml." 178 | -------------------------------------------------------------------------------- /docs/make.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | REM Command file for Sphinx documentation 4 | 5 | if "%SPHINXBUILD%" == "" ( 6 | set SPHINXBUILD=sphinx-build 7 | ) 8 | set BUILDDIR=build 9 | set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% source 10 | set I18NSPHINXOPTS=%SPHINXOPTS% source 11 | if NOT "%PAPER%" == "" ( 12 | set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS% 13 | set I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS% 14 | ) 15 | 16 | if "%1" == "" goto help 17 | 18 | if "%1" == "help" ( 19 | :help 20 | echo.Please use `make ^` where ^ is one of 21 | echo. html to make standalone HTML files 22 | echo. dirhtml to make HTML files named index.html in directories 23 | echo. singlehtml to make a single large HTML file 24 | echo. pickle to make pickle files 25 | echo. json to make JSON files 26 | echo. htmlhelp to make HTML files and a HTML help project 27 | echo. qthelp to make HTML files and a qthelp project 28 | echo. devhelp to make HTML files and a Devhelp project 29 | echo. epub to make an epub 30 | echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter 31 | echo. text to make text files 32 | echo. man to make manual pages 33 | echo. texinfo to make Texinfo files 34 | echo. gettext to make PO message catalogs 35 | echo. changes to make an overview over all changed/added/deprecated items 36 | echo. xml to make Docutils-native XML files 37 | echo. pseudoxml to make pseudoxml-XML files for display purposes 38 | echo. linkcheck to check all external links for integrity 39 | echo. doctest to run all doctests embedded in the documentation if enabled 40 | goto end 41 | ) 42 | 43 | if "%1" == "clean" ( 44 | for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i 45 | del /q /s %BUILDDIR%\* 46 | goto end 47 | ) 48 | 49 | 50 | %SPHINXBUILD% 2> nul 51 | if errorlevel 9009 ( 52 | echo. 53 | echo.The 'sphinx-build' command was not found. Make sure you have Sphinx 54 | echo.installed, then set the SPHINXBUILD environment variable to point 55 | echo.to the full path of the 'sphinx-build' executable. Alternatively you 56 | echo.may add the Sphinx directory to PATH. 57 | echo. 58 | echo.If you don't have Sphinx installed, grab it from 59 | echo.http://sphinx-doc.org/ 60 | exit /b 1 61 | ) 62 | 63 | if "%1" == "html" ( 64 | %SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html 65 | if errorlevel 1 exit /b 1 66 | echo. 67 | echo.Build finished. The HTML pages are in %BUILDDIR%/html. 68 | goto end 69 | ) 70 | 71 | if "%1" == "dirhtml" ( 72 | %SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml 73 | if errorlevel 1 exit /b 1 74 | echo. 75 | echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml. 76 | goto end 77 | ) 78 | 79 | if "%1" == "singlehtml" ( 80 | %SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml 81 | if errorlevel 1 exit /b 1 82 | echo. 83 | echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml. 84 | goto end 85 | ) 86 | 87 | if "%1" == "pickle" ( 88 | %SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle 89 | if errorlevel 1 exit /b 1 90 | echo. 91 | echo.Build finished; now you can process the pickle files. 92 | goto end 93 | ) 94 | 95 | if "%1" == "json" ( 96 | %SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json 97 | if errorlevel 1 exit /b 1 98 | echo. 99 | echo.Build finished; now you can process the JSON files. 100 | goto end 101 | ) 102 | 103 | if "%1" == "htmlhelp" ( 104 | %SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp 105 | if errorlevel 1 exit /b 1 106 | echo. 107 | echo.Build finished; now you can run HTML Help Workshop with the ^ 108 | .hhp project file in %BUILDDIR%/htmlhelp. 109 | goto end 110 | ) 111 | 112 | if "%1" == "qthelp" ( 113 | %SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp 114 | if errorlevel 1 exit /b 1 115 | echo. 116 | echo.Build finished; now you can run "qcollectiongenerator" with the ^ 117 | .qhcp project file in %BUILDDIR%/qthelp, like this: 118 | echo.^> qcollectiongenerator %BUILDDIR%\qthelp\TinyLib.qhcp 119 | echo.To view the help file: 120 | echo.^> assistant -collectionFile %BUILDDIR%\qthelp\TinyLib.ghc 121 | goto end 122 | ) 123 | 124 | if "%1" == "devhelp" ( 125 | %SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp 126 | if errorlevel 1 exit /b 1 127 | echo. 128 | echo.Build finished. 129 | goto end 130 | ) 131 | 132 | if "%1" == "epub" ( 133 | %SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub 134 | if errorlevel 1 exit /b 1 135 | echo. 136 | echo.Build finished. The epub file is in %BUILDDIR%/epub. 137 | goto end 138 | ) 139 | 140 | if "%1" == "latex" ( 141 | %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex 142 | if errorlevel 1 exit /b 1 143 | echo. 144 | echo.Build finished; the LaTeX files are in %BUILDDIR%/latex. 145 | goto end 146 | ) 147 | 148 | if "%1" == "latexpdf" ( 149 | %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex 150 | cd %BUILDDIR%/latex 151 | make all-pdf 152 | cd %BUILDDIR%/.. 153 | echo. 154 | echo.Build finished; the PDF files are in %BUILDDIR%/latex. 155 | goto end 156 | ) 157 | 158 | if "%1" == "latexpdfja" ( 159 | %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex 160 | cd %BUILDDIR%/latex 161 | make all-pdf-ja 162 | cd %BUILDDIR%/.. 163 | echo. 164 | echo.Build finished; the PDF files are in %BUILDDIR%/latex. 165 | goto end 166 | ) 167 | 168 | if "%1" == "text" ( 169 | %SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text 170 | if errorlevel 1 exit /b 1 171 | echo. 172 | echo.Build finished. The text files are in %BUILDDIR%/text. 173 | goto end 174 | ) 175 | 176 | if "%1" == "man" ( 177 | %SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man 178 | if errorlevel 1 exit /b 1 179 | echo. 180 | echo.Build finished. The manual pages are in %BUILDDIR%/man. 181 | goto end 182 | ) 183 | 184 | if "%1" == "texinfo" ( 185 | %SPHINXBUILD% -b texinfo %ALLSPHINXOPTS% %BUILDDIR%/texinfo 186 | if errorlevel 1 exit /b 1 187 | echo. 188 | echo.Build finished. The Texinfo files are in %BUILDDIR%/texinfo. 189 | goto end 190 | ) 191 | 192 | if "%1" == "gettext" ( 193 | %SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale 194 | if errorlevel 1 exit /b 1 195 | echo. 196 | echo.Build finished. The message catalogs are in %BUILDDIR%/locale. 197 | goto end 198 | ) 199 | 200 | if "%1" == "changes" ( 201 | %SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes 202 | if errorlevel 1 exit /b 1 203 | echo. 204 | echo.The overview file is in %BUILDDIR%/changes. 205 | goto end 206 | ) 207 | 208 | if "%1" == "linkcheck" ( 209 | %SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck 210 | if errorlevel 1 exit /b 1 211 | echo. 212 | echo.Link check complete; look for any errors in the above output ^ 213 | or in %BUILDDIR%/linkcheck/output.txt. 214 | goto end 215 | ) 216 | 217 | if "%1" == "doctest" ( 218 | %SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest 219 | if errorlevel 1 exit /b 1 220 | echo. 221 | echo.Testing of doctests in the sources finished, look at the ^ 222 | results in %BUILDDIR%/doctest/output.txt. 223 | goto end 224 | ) 225 | 226 | if "%1" == "xml" ( 227 | %SPHINXBUILD% -b xml %ALLSPHINXOPTS% %BUILDDIR%/xml 228 | if errorlevel 1 exit /b 1 229 | echo. 230 | echo.Build finished. The XML files are in %BUILDDIR%/xml. 231 | goto end 232 | ) 233 | 234 | if "%1" == "pseudoxml" ( 235 | %SPHINXBUILD% -b pseudoxml %ALLSPHINXOPTS% %BUILDDIR%/pseudoxml 236 | if errorlevel 1 exit /b 1 237 | echo. 238 | echo.Build finished. The pseudo-XML files are in %BUILDDIR%/pseudoxml. 239 | goto end 240 | ) 241 | 242 | :end 243 | -------------------------------------------------------------------------------- /docs/source/api.rst: -------------------------------------------------------------------------------- 1 | ************* 2 | API Reference 3 | ************* 4 | 5 | .. highlight:: c++ 6 | 7 | The Tiny Lib api contains a plain functions which are all prefixed with 8 | ``rx_`` and some classes. Below we describe the API per category. 9 | 10 | 11 | Overview 12 | -------- 13 | 14 | *String and conversion utils* 15 | - :cpp:func:`rx_to_float()` 16 | - :cpp:func:`rx_to_int()` 17 | - :cpp:func:`rx_int_to_string()` 18 | - :cpp:func:`rx_float_to_string()` 19 | - :cpp:func:`rx_string_replace()` 20 | - :cpp:func:`rx_split()` 21 | 22 | *File Utils* 23 | - :cpp:func:`rx_get_exe_path()` 24 | - :cpp:func:`rx_to_data_path()` 25 | - :cpp:func:`rx_get_file_mtime()` 26 | - :cpp:func:`rx_is_dir()` 27 | - :cpp:func:`rx_file_exists()` 28 | - :cpp:func:`rx_strip_filename()` 29 | - :cpp:func:`rx_strip_dir()` 30 | - :cpp:func:`rx_create_dir()` 31 | - :cpp:func:`rx_create_path()` 32 | - :cpp:func:`rx_get_file_ext()` 33 | - :cpp:func:`rx_get_files()` 34 | - :cpp:func:`rx_norm_path()` 35 | - :cpp:func:`rx_read_file()` 36 | 37 | *Time Utils* 38 | - :cpp:func:`rx_hrtime()` 39 | - :cpp:func:`rx_millis()` 40 | - :cpp:func:`rx_strftime()` 41 | - :cpp:func:`rx_get_year()` 42 | - :cpp:func:`rx_get_month()` 43 | - :cpp:func:`rx_get_day()` 44 | - :cpp:func:`rx_get_hour()` 45 | - :cpp:func:`rx_get_minute()` 46 | - :cpp:func:`rx_get_time_string()` 47 | - :cpp:func:`rx_get_date_string()` 48 | 49 | *Image Utils* 50 | - :cpp:func:`rx_save_png()` 51 | - :cpp:func:`rx_load_png()` 52 | - :cpp:func:`rx_save_jpg()` 53 | - :cpp:func:`rx_load_jpg()` 54 | 55 | *OpenGL* 56 | - :cpp:func:`rx_create_shader()` 57 | - :cpp:func:`rx_create_shader_from_file()` 58 | - :cpp:func:`rx_create_program_with_attribs()` 59 | - :cpp:func:`rx_get_uniform_location()` 60 | - :cpp:func:`rx_uniform_1i()` 61 | - :cpp:func:`rx_uniform_1f()` 62 | - :cpp:func:`rx_uniform_mat4fv()` 63 | - :cpp:func:`rx_create_png_screenshot()` 64 | - :cpp:func:`rx_create_jpg_screenshot()` 65 | 66 | 67 | 68 | String and conversion utils 69 | --------------------------- 70 | 71 | .. cpp:function:: float rx_to_float(const std::string&) 72 | 73 | Convert a string to a float value. 74 | 75 | .. cpp:function:: int rx_to_int(const std::string&) 76 | 77 | Convert a string to a integer value. 78 | 79 | .. cpp:function:: std::string rx_string_replace(std::string, char from, char to) 80 | 81 | Convert a character in a string into another value 82 | 83 | .. cpp:function:: std::string rx_string_replace(std::string, std::string from, std::string to) 84 | 85 | Convert a string from one value into another. 86 | 87 | .. cpp:function:: std::string rx_int_to_string(const int& v) 88 | 89 | Convert an integer value into a string. 90 | 91 | .. cpp:function:: std::string rx_float_to_string(const float& v) 92 | 93 | Convert a float to a string. 94 | 95 | .. cpp:function:: std::vector rx_split(std::string str, char delim) 96 | 97 | Split a string on the given delimiter and return a ``std::vector`` with the 98 | separate parts. 99 | 100 | File utils 101 | ---------- 102 | 103 | .. cpp:function:: std::string rx_get_exe_path() 104 | 105 | Returns the the full path to the directory where the executable is located. 106 | 107 | .. cpp:function:: std::string rx_to_data_path(const std::string filename) 108 | 109 | Returns a path to what we call a data path. A data path is a directory where you 110 | can store things like textures, shaders, fonts, etc. By default this will return 111 | a path to your executable with ``data/``. 112 | 113 | .. cpp:function:: uint64_t rx_get_file_mtime(std::string filepath) 114 | 115 | Returns the file modification time since unix epoch in nanoseconds. 116 | 117 | .. cpp:function:: bool rx_is_dir(std::string filepath) 118 | 119 | Checks if the given path is an directory 120 | 121 | .. cpp:function:: bool rx_file_exists(std::string filepath) 122 | 123 | Checks if the given filepath exists and returns true if it does, otherwise it 124 | will return false. 125 | 126 | .. cpp:function:: std::string rx_strip_filename(std::string filepath) 127 | 128 | Removes the filename from the given path, returning only the full path. 129 | 130 | .. cpp:function:: std::string rx_strip_dir(std::string filepath) 131 | 132 | Removes the path from the given filepath keeping only the filename. 133 | 134 | .. cpp:function:: bool rx_create_dir(std::string path) 135 | 136 | Create the given (sub) directory. 137 | 138 | .. cpp:function:: bool rx_create_path(std::string filepath) 139 | 140 | Create a complete path. This will create all the given paths that don't exist. 141 | 142 | :: 143 | 144 | rx_create_path(rx_to_data_path("2014/01/16/")); 145 | 146 | 147 | .. cpp:function:: std::string rx_get_file_ext(std::string filename) 148 | 149 | This will return the filename extension, like "jpg", "gif", etc.. 150 | 151 | :: 152 | 153 | std::string ext = rx_get_file_ext("/file/image.jpg"); 154 | printf("%s\n", ext.c_str()); // will print 'jpg' 155 | 156 | .. cpp:function:: std::vector rx_get_files(std::string path, std::string ext = "") 157 | 158 | Get all the files in the given path. You can specify a file extension filter like "jpg", 159 | "gif" etc.. 160 | 161 | .. cpp:function:: std::string rx_norm_path(std::string path) 162 | 163 | Creates a normalized, cross platform path. Always pass in forward slashes; on windows 164 | we will convert these to backslahes: 165 | 166 | :: 167 | 168 | std::string normpath = rx_norm_path("/path/to/my/dir"); 169 | 170 | .. cpp:function:: std::string rx_read_file(std::string filepath) 171 | 172 | Read a file into a string. 173 | 174 | 175 | Time utils 176 | ---------- 177 | 178 | .. cpp:function:: uint64_t rx_hrtime() 179 | 180 | A high resolution timer in nano seconds. 181 | 182 | :: 183 | 184 | // somewhere we have a defined a delay and timeout 185 | uint64_t delay = 1000ull * 1000ull * 1000ull; // 1 second, 1000 millis 186 | uint64_t timeout = rx_hrtime() + delay; 187 | 188 | // then somewhere else you can check if this delay has been reached 189 | uint64_t now = rx_hrtime(); 190 | if(now > timeout) { 191 | // Do something every second. 192 | timeout = rx_hrtime() + delay; // set new delay 193 | } 194 | 195 | .. cpp:function:: float rx_millis() 196 | 197 | Returns the time since the first call to this function in milliseconds. 198 | 199 | 200 | .. cpp:function:: std::string rx_strftime(const std::string fmt) 201 | 202 | Wrapper around ``strftime`` which returns a a time/date. 203 | 204 | :: 205 | 206 | std::string datetime = rx_strftime("%Y/%m/%d"); 207 | printf("%s\n", datetime.c_str()); // prints e.g. 2014/01/16 208 | 209 | 210 | .. cpp:function:: std::string rx_get_year() 211 | 212 | Get the current year with 4 digits, eg. 2014 213 | 214 | .. cpp:function:: std::string rx_get_month() 215 | 216 | Get the current month with 2 digits, [00-11] 217 | 218 | .. cpp:function:: std::string rx_get_day() 219 | 220 | Get the current day of the month with 2 digits, [00-031] 221 | 222 | .. cpp:function:: std::string rx_get_hour() 223 | 224 | Get the current hour with 2 digits, [00-23] 225 | 226 | .. cpp:function:: std::string rx_get_minute() 227 | 228 | Get the current minutes with 2 digits, [00-60] 229 | 230 | .. cpp:function:: std::string rx_get_time_string() 231 | 232 | Returns a string for the current date-time with milli second 233 | accuracy. This function is handy if you want to create unique 234 | filenames for example (as long as there is some time between 235 | each time you call this function to prevent duplicates). 236 | 237 | :: 238 | 239 | std::string time_string = rx_get_time_string(); 240 | printf("%s\n", time_string.c_str()); // prints something like: 2014.01.16_19.01.00_328 241 | 242 | 243 | 244 | Image utils 245 | ----------- 246 | 247 | .. cpp:function:: bool rx_save_png(std::string file, unsigned char* pix, int w, int h, int nchannels, bool flip) 248 | 249 | Save the given pixels to the given file path. 250 | 251 | :: 252 | 253 | int width = 320; 254 | int height = 240; 255 | unsigned char* pix = new unsigned char[width * height * 3]; 256 | 257 | // some pixel data 258 | for(int i = 0; i < width; ++i) { 259 | for(int j = 0; j < height; ++j) { 260 | int dx = j * width * 3 + i * 3; 261 | if(i < (width/2)) { 262 | pix[dx + 0] = 255; 263 | pix[dx + 1] = 255; 264 | pix[dx + 2] = 255; 265 | } 266 | else { 267 | pix[dx + 0] = 0; 268 | pix[dx + 1] = 0; 269 | pix[dx + 2] = 0; 270 | } 271 | } 272 | } 273 | 274 | std::string outfile = rx_to_data_path("test.png"); 275 | 276 | if(rx_save_png(outfile, pix, width, height, 3) == false) { 277 | printf("Error: cannot save PNG: %s\n", outfile.c_str()); 278 | ::exit(EXIT_FAILURE); 279 | } 280 | 281 | 282 | :param string: ``file`` Full file path where to save the image 283 | :param unsigned char*: ``pix`` Pointer to the raw pixels you want to save 284 | :param int: ``w`` The width of the pixel buffer 285 | :param int: ``h`` The height of the pixel buffer 286 | :param int: ``nchannels`` The number of color components (e.g. 1 for grayscale, 3 for RGB) 287 | :param bool: ``flip`` Set to true if you want to flip the image horizontally (handy when using ``glReadPixels()``) 288 | :returns: boolean true on success, else false. 289 | 290 | 291 | .. cpp:function:: bool rx_load_png(std::string file, unsigned char** pix, int& w, int& h, int& nchannels, int* allocated = NULL) 292 | 293 | Load a PNG file from the given filepath and create a pixel buffer, set width, height and nchannels. 294 | See https://gist.github.com/roxlu/9b9d555cf784385d67ba for examples on how to load using the same memory buffer. 295 | 296 | :: 297 | 298 | int w = 0; 299 | int h = 0; 300 | int channels = 0; 301 | unsigned char* pix = NULL; 302 | int allocated = 0; /* when given to rx_load_png, it should contain the number of bytes in `pix`, it will try to reuse or reallocate the pix buffer. */ 303 | int bytes_in_image = 0; 304 | 305 | bytes_in_image = rx_load_png("test.png", &pix, w, h, channels, &allocated); 306 | if (bytes_in_image < 0) { 307 | printf("Error: cannot load the png.\n"); 308 | ::exit(EXIT_FAILURE) 309 | } 310 | 311 | printf("Width: %d\n", w); 312 | printf("Height: %d\n", h); 313 | printf("Color Channels: %d\n", channels); 314 | printf("Bytes in buffer: %d\n", bytes_in_image); 315 | 316 | 317 | 318 | :param string: ``file`` Load the png from this filepath. 319 | :param unsigned char*: ``pix`` (out) We will allocate a ``unsigned char`` buffer for you; you need to delete this buffer yourself! 320 | :param int&: ``w`` (out) Reference to the width result. We will set the width value of the loaded image to ``w``. 321 | :param int&: ``h`` (out) Reference to the height result. We will set the height value of the loaded image to ``h``. 322 | :param int&: ``nchannels`` (out) The number of color channels in the loaded png. 323 | :param int*: ``allocated`` (out,in) The number of bytes in the ``pix`` parameter. When given this must hold the correct value of the buffer size. We will try to reuse or reallocate the buffer. The ``allocated`` param may be 0 (it will just allocate a new buffer then.) 324 | :returns: true on success, else false 325 | 326 | 327 | .. cpp:function:: bool rx_load_jpg(std::string file, unsigned char** pix, int& w, int& height, int& nchannels, int* allocated) 328 | 329 | Loads a JPG file, see ``rx_load_png`` for an example as the function works the same, but only loads a JPG. 330 | See https://gist.github.com/roxlu/9b9d555cf784385d67ba for examples on how to load using the same memory buffer. 331 | 332 | :param string: ``file`` Load the jpg from this filepath. 333 | :param unsigned char*: ``pix`` (out) We will allocate a ``unsigned char`` buffer for you; you need to delete this buffer yourself! 334 | :param int&: ``w`` (out) Reference to the width result. We will set the width value of the loaded image to ``w``. 335 | :param int&: ``h`` (out) Reference to the height result. We will set the height value of the loaded image to ``h``. 336 | :param int&: ``nchannels`` (out) The number of color channels in the loaded jpg. 337 | :param int*: ``allocated`` (out,in) The number of bytes in the ``pix`` parameter. When given this must hold the correct value of the buffer size. We will try to reuse or reallocate the buffer. The ``allocated`` param may be 0 (it will just allocate a new buffer then.) 338 | :returns: true on success, else false 339 | 340 | .. cpp:function:: bool rx_save_jpg(std::string file, unsigned char* pix, int width, int height, int nchannels, int quality = 80, bool flip = false, J_COLOR_SPACE colorSpace, J_DCT_METHOD dctMethod = JDCT_FASTEST) 341 | 342 | :param string: ``file`` Save a jpg to this filepath. 343 | :param unsigned char*: ``pix`` The pixels you want to save. 344 | :param int: ``width`` The width of the ``pix`` buffer. 345 | :param int: ``height`` The height of the ``pix`` buffer. 346 | :param int: ``nchannels`` The number of color channels. (e.g. 3). 347 | :param int: ``quality`` The quality (reasonable values are 65-100, 80 is ok) 348 | :param bool: ``flip`` Flip the given input pixels horizontally (e.g. nice when using ``glReadPixels()``) 349 | :param J_COLOR_SPACE: ``colorSpace`` The JPEG color space that you pass as `pix`, by default ``JCS_RGB``. Other options ``JCS_GRAYSCALE``, ``JCS_YCbCr``, ``JCS_CMYK``, ``JCS_YCCK`` 350 | :param J_DCT_METHOD: ``dctMethod`` DCT/IDCT algorithms, by default ``JDCT_FASTEST``. Other options ``JDCT_ISLOW``, ``JDCT_IFAST``, ``JDCT_FLOAT``, ``JDCT_SLOWEST`` 351 | :returns: true on success else false 352 | 353 | OpenGL 354 | ------ 355 | 356 | .. cpp:function:: GLuint rx_create_shader(GLenum, const char*) 357 | 358 | Creates a shader for the given type and source. 359 | 360 | :: 361 | 362 | static const char* MY_VERTEX_SHADER = "" 363 | "#version 330" 364 | "uniform mat4 u_pm;" 365 | "uniform mat4 u_vm;" 366 | "layout( location = 0 ) in vec4 a_pos;" 367 | "" 368 | "void main() {" 369 | " gl_Position = u_pm * u_vm * a_pos;" 370 | "}" 371 | ""; 372 | 373 | GLuint vert = rx_create_shader(GL_VERTEX_SHADER, MY_VERTEX_SHADER); 374 | 375 | 376 | :param GLenum: What kind of shader to create ``GL_VERTEX_SHADER``, ``GL_FRAGMENT_SHADER`` 377 | :param const char*: Pointer to the shader source 378 | :returns: GLuint, the created shader. 379 | 380 | .. cpp:function:: GLuint rx_create_shader_from_file(GLenum, std::string) 381 | 382 | Creates a shader for the given type and filepath. 383 | 384 | :: 385 | 386 | GLuint vert = rx_create_shader_from_file(GL_VERTEX_SHADER, "my_shader.vert"); 387 | 388 | :param GLenum: What kind of shader to create ``GL_VERTEX_SHADER``, ``GL_FRAGMENT_SHADER`` 389 | :param string: The filepath of the shader to load 390 | 391 | 392 | .. cpp:function:: GLuint rx_create_program(GLuint vert, GLuint frag, bool link = false) 393 | 394 | Create a shader program from the given vertex and fragment shaders. 395 | Set ``link`` to true if you want to link the shader program as well. 396 | Sometimes, especially when using GLSL < 330, you want to bind the attribute 397 | locations in your shader. In this case you'll pass ``link = false``. Otherwise, 398 | when using version 330 you can use the ``layout( location = 0 )`` directives. 399 | 400 | :param GLuint: ``vert`` The vertex shader. 401 | :param GLuint: ``frag`` The fragment shader. 402 | :returns: ``GLuint`` We return the newly created shader program id (not linked). 403 | 404 | .. cpp:function:: GLuint rx_create_program_with_attribs(GLuint vert, GLuint frag, int nattribs, const char** attribs) 405 | 406 | This function is similar to ``rx_create_program`` except that it will bind the 407 | attribute locations for you. The indices of the given ``attribs`` array are used 408 | as bind locations. The example below will bind ``a_pos`` at index 0, ``a_tex`` at 1 and 409 | ``a_col`` at 2. This function will also link the shader. 410 | 411 | :: 412 | 413 | const char* attribs[] = { "a_pos", "a_tex", "a_col" } ; 414 | GLuint prog = rx_create_program_with_attribs(vert, frag, 3, attribs); 415 | 416 | :param GLuint: ``vert`` The vertex shader. 417 | :param GLuint: ``frag`` The fragment shader. 418 | :param int: ``nattribs`` The number of attributes in the ``attribs`` array. 419 | :param const char**: ``attribs`` The attributes that you want to set. 420 | :returns: ``GLuint`` A linked program. 421 | 422 | .. cpp:function:: GLint rx_get_uniform_location(GLuint prog, std::string name) 423 | 424 | Safe way to retrieve uniform locations. When compiled in debug mode, 425 | this function will make sure that the uniform is found and will cause 426 | an assertion if we cannot find the uniform (which often means it's 427 | optimized away and thus not used in the shader). Make sure that your 428 | shader is active (``glUseProgram(prog)``). 429 | 430 | :param GLuint: ``prog`` The shader program. 431 | :param string: ``name`` The name of the uniform for which you want the location. 432 | :returns: ``GLint`` The location of the uniform (-1 on failure). 433 | 434 | .. cpp:function:: void rx_uniform_1i(GLuint prog, std::string name, GLint v) 435 | 436 | This function will set the uniform with the given name to ``v``. This 437 | function is to be used in your setup routines. It's an easy wrapper for 438 | e.g. settings uniform locations for your texture samplers. 439 | 440 | :param GLuint: ``prog`` The program that contains the ``name`` uniform. 441 | :param string: ``name`` The name of the uniform you want to set. 442 | :param GLint: ``v`` The value you want to set. 443 | :returns: void 444 | 445 | 446 | .. cpp:function:: void rx_uniform_1f(GLuint prog, std::string name, GLfloat v) 447 | 448 | Similar to ``rx_uniform_1i`` ecxept you use this to set float values. 449 | 450 | :param GLuint: ``prog`` The program that contains the ``name`` uniform. 451 | :param string: ``name`` The name of the uniform you want to set. 452 | :param GLfloat: ``v`` The value you want to set. 453 | :returns: void 454 | 455 | .. cpp:function:: void rx_uniform_mat4fv(GLuint prog, std::string name, GLint count, GLboolean transpose, GLfloat* value) 456 | 457 | Wrapper around `glUniformMatrix4fv`. This function will set the given matrix. 458 | 459 | :param GLuint: ``prog`` The program that contains the ``name`` uniform. 460 | :param string: ``name`` The name of the uniform you want to set. 461 | :param GLint: ``count`` Number of matrices to set. 462 | :param GLboolean: ``transpose`` Transpose the matrix. 463 | :param const float*: ``value`` Pointer to the matrix. 464 | :returns: void 465 | 466 | 467 | .. cpp:function:: bool rx_create_png_screenshot(std::string filepath) 468 | 469 | Creates a PNG screenshot of the current read buffer with the size of 470 | the current viewport. The image is saved to the given ``filepath``. 471 | Note that this function allocates some static memory so we don't have to 472 | allocate every time you create a screenshot. This does mean that we "leak" 473 | a couple of bytes and that you need to be carefull calling this function from 474 | different threads at the same time. 475 | 476 | **NOTE:** This means that both ``ROXLU_USE_OPENGL`` and ``ROXLU_USE_PNG`` must be 477 | enabled. 478 | 479 | :param string: ``filepath`` The file path where you want to save the screenshot. 480 | :returns: boolean, true on success else false. 481 | 482 | .. cpp:function:: bool rx_create_jpg_screenshot(std::string filepath, int quality) 483 | 484 | Same as ``rx_create_png_screenshot()`` but this creates a JPG image. Writing 485 | JPGs to disk is often faster then writing PNG images. 486 | 487 | **NOTE:** This means that both ``ROXLU_USE_OPENGL`` and ``ROXLU_USE_PNG`` must be 488 | enabled. 489 | 490 | :param string: ``filepath`` The file path where you want to save the screenshot. 491 | :param integer: ``quality`` The quality level for the JPG. 492 | :returns: boolean, true on success else false. 493 | 494 | 495 | Math 496 | ---- 497 | 498 | 499 | 500 | Audio 501 | ----- 502 | -------------------------------------------------------------------------------- /docs/source/conf.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # Tiny Lib documentation build configuration file, created by 4 | # sphinx-quickstart on Wed Mar 12 21:37:21 2014. 5 | # 6 | # This file is execfile()d with the current directory set to its 7 | # containing dir. 8 | # 9 | # Note that not all possible configuration values are present in this 10 | # autogenerated file. 11 | # 12 | # All configuration values have a default; values that are commented out 13 | # serve to show the default. 14 | 15 | import sys 16 | import os 17 | 18 | # If extensions (or modules to document with autodoc) are in another directory, 19 | # add these directories to sys.path here. If the directory is relative to the 20 | # documentation root, use os.path.abspath to make it absolute, like shown here. 21 | #sys.path.insert(0, os.path.abspath('.')) 22 | 23 | # -- General configuration ------------------------------------------------ 24 | 25 | # If your documentation needs a minimal Sphinx version, state it here. 26 | #needs_sphinx = '1.0' 27 | 28 | # Add any Sphinx extension module names here, as strings. They can be 29 | # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom 30 | # ones. 31 | extensions = [] 32 | 33 | # Add any paths that contain templates here, relative to this directory. 34 | templates_path = ['_templates'] 35 | 36 | # The suffix of source filenames. 37 | source_suffix = '.rst' 38 | 39 | # The encoding of source files. 40 | #source_encoding = 'utf-8-sig' 41 | 42 | # The master toctree document. 43 | master_doc = 'index' 44 | 45 | # General information about the project. 46 | project = u'Tiny Lib' 47 | copyright = u'2014, roxlu' 48 | 49 | # The version info for the project you're documenting, acts as replacement for 50 | # |version| and |release|, also used in various other places throughout the 51 | # built documents. 52 | # 53 | # The short X.Y version. 54 | version = '0.1' 55 | # The full version, including alpha/beta/rc tags. 56 | release = '0.1' 57 | 58 | # The language for content autogenerated by Sphinx. Refer to documentation 59 | # for a list of supported languages. 60 | #language = None 61 | 62 | # There are two options for replacing |today|: either, you set today to some 63 | # non-false value, then it is used: 64 | #today = '' 65 | # Else, today_fmt is used as the format for a strftime call. 66 | #today_fmt = '%B %d, %Y' 67 | 68 | # List of patterns, relative to source directory, that match files and 69 | # directories to ignore when looking for source files. 70 | exclude_patterns = [] 71 | 72 | # The reST default role (used for this markup: `text`) to use for all 73 | # documents. 74 | #default_role = None 75 | 76 | # If true, '()' will be appended to :func: etc. cross-reference text. 77 | #add_function_parentheses = True 78 | 79 | # If true, the current module name will be prepended to all description 80 | # unit titles (such as .. function::). 81 | #add_module_names = True 82 | 83 | # If true, sectionauthor and moduleauthor directives will be shown in the 84 | # output. They are ignored by default. 85 | #show_authors = False 86 | 87 | # The name of the Pygments (syntax highlighting) style to use. 88 | pygments_style = 'sphinx' 89 | 90 | # A list of ignored prefixes for module index sorting. 91 | #modindex_common_prefix = [] 92 | 93 | # If true, keep warnings as "system message" paragraphs in the built documents. 94 | #keep_warnings = False 95 | 96 | 97 | # -- Options for HTML output ---------------------------------------------- 98 | 99 | # The theme to use for HTML and HTML Help pages. See the documentation for 100 | # a list of builtin themes. 101 | html_theme = 'default' 102 | 103 | # Theme options are theme-specific and customize the look and feel of a theme 104 | # further. For a list of options available for each theme, see the 105 | # documentation. 106 | #html_theme_options = {} 107 | 108 | # Add any paths that contain custom themes here, relative to this directory. 109 | #html_theme_path = [] 110 | 111 | # The name for this set of Sphinx documents. If None, it defaults to 112 | # " v documentation". 113 | #html_title = None 114 | 115 | # A shorter title for the navigation bar. Default is the same as html_title. 116 | #html_short_title = None 117 | 118 | # The name of an image file (relative to this directory) to place at the top 119 | # of the sidebar. 120 | #html_logo = None 121 | 122 | # The name of an image file (within the static path) to use as favicon of the 123 | # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 124 | # pixels large. 125 | #html_favicon = None 126 | 127 | # Add any paths that contain custom static files (such as style sheets) here, 128 | # relative to this directory. They are copied after the builtin static files, 129 | # so a file named "default.css" will overwrite the builtin "default.css". 130 | html_static_path = ['_static'] 131 | 132 | # Add any extra paths that contain custom files (such as robots.txt or 133 | # .htaccess) here, relative to this directory. These files are copied 134 | # directly to the root of the documentation. 135 | #html_extra_path = [] 136 | 137 | # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, 138 | # using the given strftime format. 139 | #html_last_updated_fmt = '%b %d, %Y' 140 | 141 | # If true, SmartyPants will be used to convert quotes and dashes to 142 | # typographically correct entities. 143 | #html_use_smartypants = True 144 | 145 | # Custom sidebar templates, maps document names to template names. 146 | #html_sidebars = {} 147 | 148 | # Additional templates that should be rendered to pages, maps page names to 149 | # template names. 150 | #html_additional_pages = {} 151 | 152 | # If false, no module index is generated. 153 | #html_domain_indices = True 154 | 155 | # If false, no index is generated. 156 | #html_use_index = True 157 | 158 | # If true, the index is split into individual pages for each letter. 159 | #html_split_index = False 160 | 161 | # If true, links to the reST sources are added to the pages. 162 | #html_show_sourcelink = True 163 | 164 | # If true, "Created using Sphinx" is shown in the HTML footer. Default is True. 165 | #html_show_sphinx = True 166 | 167 | # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. 168 | #html_show_copyright = True 169 | 170 | # If true, an OpenSearch description file will be output, and all pages will 171 | # contain a tag referring to it. The value of this option must be the 172 | # base URL from which the finished HTML is served. 173 | #html_use_opensearch = '' 174 | 175 | # This is the file name suffix for HTML files (e.g. ".xhtml"). 176 | #html_file_suffix = None 177 | 178 | # Output file base name for HTML help builder. 179 | htmlhelp_basename = 'TinyLibdoc' 180 | 181 | 182 | # -- Options for LaTeX output --------------------------------------------- 183 | 184 | latex_elements = { 185 | # The paper size ('letterpaper' or 'a4paper'). 186 | #'papersize': 'letterpaper', 187 | 188 | # The font size ('10pt', '11pt' or '12pt'). 189 | #'pointsize': '10pt', 190 | 191 | # Additional stuff for the LaTeX preamble. 192 | #'preamble': '', 193 | } 194 | 195 | # Grouping the document tree into LaTeX files. List of tuples 196 | # (source start file, target name, title, 197 | # author, documentclass [howto, manual, or own class]). 198 | latex_documents = [ 199 | ('index', 'TinyLib.tex', u'Tiny Lib Documentation', 200 | u'roxlu', 'manual'), 201 | ] 202 | 203 | # The name of an image file (relative to this directory) to place at the top of 204 | # the title page. 205 | #latex_logo = None 206 | 207 | # For "manual" documents, if this is true, then toplevel headings are parts, 208 | # not chapters. 209 | #latex_use_parts = False 210 | 211 | # If true, show page references after internal links. 212 | #latex_show_pagerefs = False 213 | 214 | # If true, show URL addresses after external links. 215 | #latex_show_urls = False 216 | 217 | # Documents to append as an appendix to all manuals. 218 | #latex_appendices = [] 219 | 220 | # If false, no module index is generated. 221 | #latex_domain_indices = True 222 | 223 | 224 | # -- Options for manual page output --------------------------------------- 225 | 226 | # One entry per manual page. List of tuples 227 | # (source start file, name, description, authors, manual section). 228 | man_pages = [ 229 | ('index', 'tinylib', u'Tiny Lib Documentation', 230 | [u'roxlu'], 1) 231 | ] 232 | 233 | # If true, show URL addresses after external links. 234 | #man_show_urls = False 235 | 236 | 237 | # -- Options for Texinfo output ------------------------------------------- 238 | 239 | # Grouping the document tree into Texinfo files. List of tuples 240 | # (source start file, target name, title, author, 241 | # dir menu entry, description, category) 242 | texinfo_documents = [ 243 | ('index', 'TinyLib', u'Tiny Lib Documentation', 244 | u'roxlu', 'TinyLib', 'One line description of project.', 245 | 'Miscellaneous'), 246 | ] 247 | 248 | # Documents to append as an appendix to all manuals. 249 | #texinfo_appendices = [] 250 | 251 | # If false, no module index is generated. 252 | #texinfo_domain_indices = True 253 | 254 | # How to display URL addresses: 'footnote', 'no', or 'inline'. 255 | #texinfo_show_urls = 'footnote' 256 | 257 | # If true, do not generate a @detailmenu in the "Top" node's menu. 258 | #texinfo_no_detailmenu = False 259 | -------------------------------------------------------------------------------- /docs/source/guide.rst: -------------------------------------------------------------------------------- 1 | 2 | ****************** 3 | Programmers Guide 4 | ****************** 5 | 6 | .. highlight:: c++ 7 | 8 | In this guide we will describe how to use Tiny Lib in your project. 9 | 10 | Introduction to Tiny Lib 11 | ------------------------ 12 | 13 | Tiny Lib is a "one header" library. This means that the declarations (the functions, 14 | types, etc..) and the definitions (the actual source code/implementation) are all in 15 | the same file. To make sure that the definitions are compiled we need to inject it 16 | somewhere in your project. 17 | 18 | There are two reasons why we store the definitions and declarations in the same file: 19 | 20 | - This allows you to use this library in your project w/o any complicated compile scripts 21 | - This allows you to use your own openGL wrapper code that includes the GL headers 22 | 23 | How to use Tiny Lib in your project 24 | ----------------------------------- 25 | 26 | As described above we need to inject the definitions somewhere in your code. To do this 27 | you need to define ``ROXLU_IMPLEMENTATION`` in one file (and only one file!) in your project 28 | before including tinylib.h. A common place to do this is in your main.cpp after you've 29 | included all the necessary openGL headers (if you want to make use of the tiny lib opengl 30 | features). Besides defining the ``ROXLU_IMPLEMENTATION`` you need to tell tiny lib what 31 | features you want to use. You can use the following defines: 32 | 33 | - ``ROXLU_USE_MATH`` To enable mat4, mat3, vec4, vec3, vec2, Perlin, Spline 34 | - ``ROXLU_USE_PNG`` To enable loading and saving of PNG files 35 | - ``ROXLU_USE_JPG`` To enable loading of JPG files 36 | - ``ROXLU_USE_OPENGL`` To enable Shader, Program, OBJ, Painter, VertexP, etc.. 37 | - ``ROXLU_USE_CURL`` To enable loading of remote data over http 38 | - ``ROXLU_USE_AUDIO`` To enable audio output 39 | - ``ROXLU_USE_FONT`` To enable PixelFont to draw bitmap strings (with opengl) 40 | - ``ROXLU_USE_ALL`` To enable everything 41 | 42 | Note that some of these defines enable code that are depending on other libraries see 43 | below in the dependencies section. In the following code examples we show you an example 44 | of how to use the ``ROXLU_IMPLEMENTATION`` in your main.cpp file and how to enable features 45 | in a common header (`MyApplication`). 46 | 47 | Example main.cpp:: 48 | 49 | #define GLFW_INCLUDE_GLCOREARB 50 | #include 51 | 52 | #define ROXLU_USE_MATH 53 | #define ROXLU_USE_PNG 54 | #define ROXLU_USE_OPENGL 55 | #define ROXLU_IMPLEMENTATION 56 | #include 57 | 58 | 59 | Example MyApplication.h:: 60 | 61 | #define ROXLU_USE_OPENGL 62 | #define ROXLU_USE_MATH 63 | #include 64 | 65 | class MyApplication() { 66 | 67 | } 68 | 69 | 70 | Dependencies 71 | ------------ 72 | 73 | When you enable certain features there are some dependencies which are listed below: 74 | 75 | ROXLU_USE_CURL 76 | - libcurl_ 77 | 78 | ROXLU_USE_PNG 79 | - libpng_ 80 | 81 | ROXLU_USE_JPG 82 | - libjpeg_ 83 | 84 | ROXLU_USE_AUDIO 85 | - libcubeb_ 86 | - libsndfile_ 87 | 88 | On Mac you need to link with the following libraries and frameworks: 89 | 90 | - pthreads 91 | - AudioUnit framework 92 | - CoreAudio framework 93 | - AudioToolbox framework 94 | 95 | On Linux you need to link with the following libraries: 96 | 97 | - pthread 98 | - dl 99 | - asound 100 | - z 101 | - vorbis 102 | - vorbisenc 103 | - FLAC 104 | - ogg 105 | 106 | .. _libcurl: http://curl.haxx.se/libcurl/ 107 | .. _libpng: http://www.libpng.org/pub/png/libpng.html 108 | .. _libjpeg: http://libjpeg.sourceforge.net/ 109 | .. _libcubeb: https://github.com/kinetiknz/cubeb 110 | .. _libsndfile: http://www.mega-nerd.com/libsndfile/ 111 | -------------------------------------------------------------------------------- /docs/source/index.rst: -------------------------------------------------------------------------------- 1 | .. Tiny Lib documentation master file, created by 2 | sphinx-quickstart on Wed Mar 12 21:37:21 2014. 3 | You can adapt this file completely to your liking, but it should at least 4 | contain the root `toctree` directive. 5 | 6 | Tiny Lib 7 | ========= 8 | Tiny Lib is a one file, header only cross platform creative coding "library" 9 | aimed at OpenGL development. Tiny Lib tries to stay tiny but to support as 10 | much as features that one needs for common creative coding tasks. Tiny Lib 11 | provides features for: 12 | 13 | - OpenGL: shaders, vertex types, debug drawing, OBJ loading 14 | - Image loading and saving: for JPG and PNG 15 | - Math: mat4, mat3, vec4, vec3, vec2, Perlin noise, Spline 16 | - Curl: loading http pages 17 | - Utils: string to number (and visa versa), file loading, time utils, file and directory support 18 | 19 | Contents: 20 | 21 | .. toctree:: 22 | :maxdepth: 2 23 | 24 | guide 25 | api 26 | 27 | 28 | * :ref:`genindex` 29 | * :ref:`search` 30 | --------------------------------------------------------------------------------