openframeworks / openframeworks/openFrameworks

feature : core add-on ofxAssets

Open
#1,511 18 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

addon development-strategy feature
Dominant language
C++
Stars
10.4k
Forks
2.6k
Avg merge
1d 21h
Merged PRs (30d)
9

Description

hey all!

in a few of my addons i build an asset register to handle:

  • images
  • shaders
  • fonts

The idea is common. That on program start (and whenever you call ofxAssets::rescan()), it scans the data/ folder for assets and builds the dictionaries.

e.g. if my folder structure is like

data/landscape.png
data/phong.vert
data/phong.frag
data/blur.frag
data/verdana.ttf

or sometimes i do...

data/images/landscape.png
data/shaders/phong.vert
data/shaders/phong.frag
data/shaders/blur.frag
data/fonts/verdana.ttf

I can then access these from anywhere in my app as long as i'm including the ofxAssets header:

#include "ofxAssets.h"
using namespace ofxAssets;

void testApp::draw() {
    shader["blur"].begin();
    image["landscape"].draw(10,10);
    shader["blur"].end();
    font["verdana"].drawString("is this API correct?", 10, 10);

    //or if i don't want to add the using namespace clause
    ofxAssets::shader["phong"].setUniform3f("position", myVec3);
}

I'd like to see this as a core add-on as I think it's rather universally useful, the code is beginning to be duplicated in different addons and the API is simple enough to avoid much deliberation. (spoke to soon)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the proposed ofxAssets API in the issue, especially ofxAssets.h and ofxAssets::rescan(). Determine how a core add-on should scan the data/ folder and expose images, shaders, and fonts through the shown dictionaries. Done means the behavior and API are agreed, implemented, and covered by appropriate project tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
computer-graphics
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.