ofxAppUtils


#1

Here’s a pair of utility addons I’m throwing out there. As always feel free to fork and make pull requests via Github.

ofxLogger

As my advanced logger was causing problems within OF 007 and has been removed for now, I’ve spun it out as an addon for use and testing. I have used it in a few projects and not had any problems so far. You’re fine as long as you don’t try to call it in a destructor since the main logger object is in a singleton object and, as such, you can never know when it will be destroyed.

https://github.com/danomatika/openFrameworks

This is a wrapper around the Poco::Logger which provides:

  • C++ stream operator (automatic string conversion, no ofToString needed!)

  • handy log level named calls: ofxLog, ofxLogVerbose, ofxLogWarning, etc

  • file logging, including automatic trimming and rotation

  • switchable log channels between console and/or file (could be extended for logging over a socket, etc)

  • automatic header with timestamp, millis, frame num

  • user level log topics for log filtering

You use it like so:

[tt]ofxLog() << “a string” << 100 << 20.234f;[/tt]

Additionally, there is an ofxBitmapString which provides a C++ ostream interface to ofDrawBitmap string. I grew tired of having to add a stringstream every time I wanted to draw some text, so this does it for you.

Use like so:

[tt]ofxBitmapString(10, 10) << “a string” << 100 << 20.234f;[/tt]

ofxAppUtils

This is a bunch of OpenFrameworks utility code from my last project that might be useful.

https://github.com/danomatika/ofxAppUtils

ofxAppUtils is a set utilites for application development including:

[list]

  • ofxApp: an ofBaseApp extension with built in screen scaling, projection mapping transforms, quad warping, and an ofxControlPanel

  • ofxScene: a mini ofBaseApp for writing stand alone scenes

  • ofxSceneManager: handles a list of scenes using a std::map

  • ofxTransformer: open gl transformer for origin translation, screen scaling, mirroring, and quad warping

  • ofxQuadWarper: an open gl matrix quad warper (useful for oblique projection mapping)

  • ofxTimer: a simple millis timer

[/list]


#2

I updated ofAppUtils so that you use the ofBaseApp callbacks functions directly (as opposed to the old method of renaming them). Another big update is that *all* the ofBaseApp functions are handled down to the scene level which should make combining several apps into a multiscene app relatively trivial.


#3

ofxAppUtils has been updated again:

  • ofxControlPanel is now optional, add a define to the build: OFX_APP_UTILS_NO_CONTROL_PANEL

  • ofxApp built in control panel auto draw can now be disabled and the panel drawn manually

  • ofxApp render area auto aspect and auto centering now finally work correctly

  • added auto fps string rendering options: enable/disable, set text color, draw manually

  • ofxTimer: added resetAlarm and copy operations

  • added ofxParticle & ofxParticleSystem classes

Also, ofxAppUtils is now licensed under the BSD Simplified license.


#4

Yet another update:

  • added ofxBitmapString (ofDrawBitmapString stream wrapper) from ofxLogger

  • auto transforms can now be disabled and performed manually

  • quad warp editor is finally 1:1 (now more dragging from screen corners)

  • added ability to disable auto sceneManager update and draw calls


#5

Hi,

I have a simple question about ofxScene.

My case is that I have bunch of images and bunch of images calculated and updated in the main testApp.h,
and my question is how to draw these images in a separate scene.

I can see that I have access to the images just here:

MaskingScene(testApp &app) : ofxScene((ofxApp&) app, “Particles”) {

if referenced as - app.my_images, but not in the draw method of the scene.

Thank you in advance!
Miro


#6

You cast the ofxApp& reference back to a testApp& reference:

  
testApp& myApp = dyamic_cast<testApp&>(app);  

This is noted farther down in both scene files. Also, I removed the explicit ofxApp reference from ofxSceneManager and ofxScene, so you’e not forced to work this way. The example scenes still do this, but using a testApp& reference directly, thus avoiding the cast.


#7

Hey all,

After being prompted via email, I updated the AppUtils to play nicely on iOS. Everything works and calling runAppWithAppUtils() now dosen’t bork … I also created a new iOS example and added projects files for Windows and Linux.

PS Some bugs were fixed too.


#8

ofxAppUtils now updated so that ofxControlPanel is not required by default:

the OFX_APP_UTILS_NO_CONTROL_PANEL define is now OFX_APP_UTILS_USE_CONTROL_PANEL

I’m moving forward to eventually remove the ofxControlPanel requirement code and perhaps replace it with ofxUI.

Also, ofxGetAppPtr() (note the “x”) has been added which returns the correct pointer to the running app, where as ofGetAppPtr() does not since the app is inside a wrapper class when you use ofRunAppWithAPpUtils(). The examples have been updated to reflect this.


#9

ofxAppUtils is now updated for OF 0.8.0. The previous stable version can be found in the 0.7.4 tag.


#10

Hey danomatika,

Thanks for the excellent addon. I was looking all over the placed for very similar utilities for Cinder, and found this for oF. Ended up deciding to switch my entire project over to oF just so I could use this addon.

Best,
S


#11

I’m looking for someone interested in helping maintain this addon. Any takers?


#13

@danomatika, how would i go about including the transform panel (as a panel or group) to my main gui, defined in ofApp.h, rather than to the gui defined in ofxTransformPanel.h?
ofApp *mainApp = (ofApp *)ofxGetAppPtr(); only works from scene header files but not from the ofxTransformPanel.h


#14

The transformer panel is already an ofxGui panel. As in the example, you should be able to create it and pass in a reference to the transformer you want it to control as well as set a custom panel name.

If you want to add all the settings to your own panel, you’ll need to do that manually. Look inside the ofxTransformPanel class.


#15

I’ve updated ofxAppUtils to use Semantic Versioning. There is now a changelog and ofxAppUtils-specific version tags to replace the previous tags which were based on OF versions.