Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 72 lines (51 sloc) 1.91 kB
bbfa1d3 @elliotwoods first commit
authored
1 # ofxAssets
2
3 ## Introduction
4
5 ofxAssets is an openFrameworks addon for simple access to assets inside your data folder.
6
7 ## Usage
8
a3e91a5 @elliotwoods update readme and addons.make in example
authored
9 ### Include source and headers
10 Setup the addon with your project (e.g. drag the ofxAssets src files into your XCode project).
11
12 ### Put assets into an assets folder
13
14 Assets go inside `data/assets`
15
16 ```
17 appFolder/
18 appFolder/data/assets/images - places images here (png, jpg, jpeg)
19 appFolder/data/assets/shaders - place any shaders here (vert, frag, geom)
20 appFolder/data/assets/fonts - place any font files here (ttf)
21 ```
22
23 ### Use ofxAssets in your code
24
572bf09 @elliotwoods Update README.md
authored
25 #### header
a3e91a5 @elliotwoods update readme and addons.make in example
authored
26 ```c++
27 #include “ofxAssets.h”
28 using namespace ofxAssets; // this is optional
29 ```
30
572bf09 @elliotwoods Update README.md
authored
31 #### source
32
a3e91a5 @elliotwoods update readme and addons.make in example
authored
33 ```c++
34 //example
35 void testApp::draw() {
36
37 // quick access to assets
c6b0e11 @elliotwoods Update README.md
authored
38 image("imageName").draw(10,10);
39 font("fontName", 30).drawString("...", 10, 10);
40 shader("shaderName").begin();
a3e91a5 @elliotwoods update readme and addons.make in example
authored
41
42 // if you don’t put ‘using namespace ofxAssets’ at the top of your source or header, then use:
c6b0e11 @elliotwoods Update README.md
authored
43 ofxAssets::image("imageName").draw(10,10);
a3e91a5 @elliotwoods update readme and addons.make in example
authored
44 }
45 ```
46
47 You can also reload the asset register (e.g. you edit an image externally and what to see it updated in your app) using
48
49 ```c++
50 AssetRegister::refresh()
51 ```
52
53 ## Notes
e837b55 @elliotwoods Update README.md
authored
54
55 ### Don't write the extension into your code
56 If your asset filename is `background.png`, then you access this asset without the extension, e.g. `image("background")`.
57
58 ### Shaders are merged
59 If `phong.vert` and `phong.frag` both exist in your `assets/shaders` folder, then they will all be merged into one shader asset `shader("phong")`. This is of course true for any combinationn of fragment vertex and geometry shader files. Your filesystem is not affected by this 'merging'.
60
61 ### References
62 The functions:
63 * `image(string)`
64 * `font(string, int)`
65 * `shader(string)`
66
67 All return non-const references to instances of relevent types, i.e.:
68 * `ofImage`
69 * `ofTrueTypeFont`
70 * `ofShader`
71
72 respectively.
Something went wrong with that request. Please try again.