User Tools

Site Tools



Table of Contents


cannot convert parameter 1 from 'char' to 'LPCWSTR'

stackoverflow: in Visual Studio project properties set 'Character Set' to 'not set'.

recent problem with ofVideoPlayer

cheap tricks video

read 16bit raw image into ofImage

ofImage heightmap;
ofFile file("terra8M.raw", ofFile::ReadOnly, true);
ofBuffer raw(file);
int w = 4096, h = 2048, wxh = w*h;    
heightmap.allocate(w, h, OF_IMAGE_COLOR_ALPHA);
int i = 0;
for (int y = 0; y < h; y++) {
  for (int x = 0; x < w; x++) {
    int r = raw.getData()[i++];
    int a = raw.getData()[i++];
    heightmap.setColor(x, y, ofColor(r,0,0,a));

openFrameworks code style guide

loading 16 bits grayscale images seems to be broken after version 008x I modified some code in putBmpIntoPixels to be able to load 16 bits grayscale images:

	if(sizeof(PixelType)==1 &&
		(FreeImage_GetColorType(bmp) == FIC_PALETTE || FreeImage_GetBPP(bmp) < 8
		||  imgType!=FIT_BITMAP)) {
		if(FreeImage_IsTransparent(bmp)) {
			bmpConverted = FreeImage_ConvertTo32Bits(bmp);
// added this to support 16 bit grayscale images
		} else if (FreeImage_GetBPP(bmp)==16) {                     
			bmpConverted = FreeImage_ConvertToType(bmp,FIT_UINT16); 
		} else {
			bmpConverted = FreeImage_ConvertTo24Bits(bmp);
		bmp = bmpConverted;

enable errors to force checking return values



void ofApp::draw(){

Projectgenerator on Linux: error projectgenerator not found

first run

Projectgenerator on Linux: terminate called after throwing an instance of std::regex_error

Command failed: /bin/sh -c "projectGenerator"  -o"/home/globe4d/Documents/of0092" -a" " -p"linux64" "/home/globe4d/Documents/of0092/apps/myApps/mySketch"
terminate called after throwing an instance of 'std::regex_error'
  what():  regex_error
Aborted (core dumped)


ipv 'test' kan ik beter 'ppa' doen zegt peter. daar staat gcc-4.9 ook bij.

sudo add-apt-repository ppa:ubuntu-toolchain-r/ppa   # this one worked for me: ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install g++-4.9
sudo apt-get remove g++-4.8
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.9 60 --slave /usr/bin/g++ g++ /usr/bin/g++-4.9
gcc -v

then run again.

Logitech C920 with IR blocker removed and red filter added. OpenCV code using BackgroundSubtractorMOG2

see logitech


cmdline command:

"/Users/rick/Documents/openFrameworks/of0092/projectGenerator-osx/"  -o"/Users/rick/Documents/openFrameworks/of0092" -a"ofxCv,ofxOpenCv" -p"osx" "/Users/rick/Documents/openFrameworks/of0092/apps/myApps/cvBgTest2"

Segmentation Fault 11 with projectGenerator

I got a Segmentation Fault 11 when I changed the scripts/templates/osx Xcode project. I removed ofApp.cpp and ofApp.h but that resulted in a lot of recursive calls in the xcodeProject.cpp::addInclude function.
I worked around this by manually removing the xml elements of ofApp.h and ofApp.cpp in project.pbxproj within the emptyExample.xcodeproject folder.

extending ofBaseVideoDraws in of009

inherit from ofBaseDrawsVideo class

In XCode when pressing Cmd+8 then click on Clock icon on bottom you get detailed info about build error message. It shows which functions you need to implement:

what means 'const' after method definition?

When you define a method like this in your class:

bool isReady() const

It means that it “will return a bool but it will not change the logic state of your object. So this is your getter.” So by supplying const you promise the compiler you won't change any data inside your class instance.

Member function '...' not viable:

Member function 'drawGlobe' not viable: 'this' argument has type 'const Globe', but function is not marked const


Field type '...' is an abstract class

In openFrameworks 009 the declarations of some ofBase classes has changed. For example when your class inherits from ofBaseDraws you need to add the const term after your function definition:

  float getWidth() const { return 640; }
  float getHeight() const { return 480; }
  void draw(float x, float y) const { /*...*/ }
  void draw(float x, float y, float w, float h) const { /*...*/ }

opencv2/opencv.hpp file not found

When you add ofxCv to your openFrameworks project make sure to also add ofxOpenCv. Because this adds the opencv2 folder to your project.

openFrameworks 009 on ElementaryOS

ArcText (curved text on circular path) with openFrameworks 009

make Debug openFrameworks 009

make Debug


make RunDebug


cd bin
gdb Project_debug

openframeworks 009

  • installing MSYS2 for openFrameworks 009.
    • you might need to set the HOME environment variable to your home folder (C:\Users\YOURUSERNAME) to be able to access your files from the MSYS2 shell.
      * there's a typo in the line cd your_oF_directory/scripts/win_cb/msys2. Remove the win
      cb part.
  • when the tutorial says: “Open a MINGW32 shell” it means run the following batch file (from the Start Menu):
C:\Windows\System32\cmd.exe /A /Q /K C:\msys64\mingw32_shell.bat
  • add c:\msys64\mingw32\bin;c:\msys64\usr\bin to the start of the PATH.
  • OF recommends K-Lite codec for video support.

main.cpp template

#include "ofMain.h"
class ofApp : public ofBaseApp {
  void setup() {
  void update() {
  void draw() {
int main( ){
  ofRunApp(new ofApp());

tools and templates by Gene Kogan

mouse rotating globe with conversion from quaternions to latitude longitude

render and rotate a globe in openFrameworks

good old alpha trail with two FBO's


somehow certain characters 'recently' added to ISO885915 are shown as their predecessor in ISO88591 by openFrameworks ofTrueTypeFont. It looks like the Latin9Encoding::convert function called by ofTrueTypeFont::drawString is causing this problem. Read here about the differences. The only solution I've been able to find so far is to not use ofTrueTypeFont but to use the ofxTrueTypeFontUC addon: See solution below.
The loaded text-file is encoded as UTF-8 by notepad with the BOM character removed.

Nejhmotnejší objekt v naší...
#include "ofxTrueTypeFontUC.h"
class ofApp : public ofBaseApp {
  ofxTrueTypeFontUC font;
  void setup() {
  void draw() {
    string s = ofBufferFromFile("UTF8-without-BOM.txt").getText();

my fork of ofxTrueTypeFontUC

- In 2014 I made a fork of ofxTrueTypeFontUC and added some functions to access the character meshes.
- June 22th 2015: I can't get the original ofxTrueTypeFontUC to compile on of0084 (and some older versions) codeblocks 12.11: fatal error: codecvt: No such file or directory. More people seem to have a similar problem. My 'old' fork of ofxTrueTypeFontUC works but is 15 commits behind at this moment.

Update: ofTrueTypeFont ISO-8859-15

“ In 1999, ISO needed to make the Euro currency symbol available. There were also a few other characters that were desired. So ISO created ISO-8859-15, which is identical to ISO-8859-1 except for 8 characters.” source:

ofTrueTypeFont shows the characters as they were in ISO-8859-1. A fix was added by @kylemcdonald at Jun 15, 2013 to support the euro sign but the other 7 characters that were introduced can be supported the same way by using the following code in ofTrueTypeFont::loadFont.

if (glyph == 0xA4) glyph = 0x20AC;   //  Currency Sign -> Euro Sign
if (glyph == 0xA6) glyph = 0x0160;   //  Broken Bar -> Latin Capital Letter S With Caron
if (glyph == 0xA8) glyph = 0x0161;   //  Diaeresis -> Latin Small Letter S With Caron
if (glyph == 0xB4) glyph = 0x017D;   //  Acute Accent -> Latin Capital Letter Z With Caron
if (glyph == 0xB8) glyph = 0x017E;   //  Cedilla -> Latin Small Letter Z With Caron
if (glyph == 0xBC) glyph = 0x0152;   //  Vulgar Fraction One Quarter -> Latin Capital Ligature OE
if (glyph == 0xBD) glyph = 0x0153;   //  Vulgar Fraction One Half -> Latin Small Ligature OE
if (glyph == 0xBE) glyph = 0x0178;   //  Vulgar Fraction Three Quarters -> Latin Capital Letter Y With 

more characters:

there were more characters with problems but these problems were 'deeper' (probably in the Poco convert from UTF8 to Latin9. We solved it this way:

ě	[
ů	]
č	{
Č	}
ř	<
ň	>
ť	_
if (glyph == '[') glyph = 0x11B;       // e met dakje op de kop
if (glyph == ']') glyph = 0x16F;       // u met rondje
if (glyph == '{') glyph = 0x10D;       // c met dakje op de kop
if (glyph == '}') glyph = 0x10C;       // C met dakje op de kop
if (glyph == '<') glyph = 0x159;       // r met dakje op de kop
if (glyph == '>') glyph = 0x148;       // n met dakje op de kop
if (glyph == '_') glyph = 0x165;       // t met accentje er naast

ftgl font

tr1/memory error

Set 'Buid Settings → Base SDK' to a lower version, for example 10.8

write to a file

ofFile file("tmp.txt",ofFile::WriteOnly);
file << "A" << endl;
file << "B" << endl;

read text file



fbo depthbuffer

nog uitzoeken


Multiline syntax highlighted hardcoded strings in je code.

#define STRINGIFY(A) #A
static string myString = STRINGIFY(
				 bla die bla1
				 bla die bla2
				 bla die bla3
				 bla die bla4
				 bla die bla5);

blending crosshair/bullseye

ofPushMatrix(); //bullseye
ofPopMatrix(); //bullseye

fbo's / ortho projection with WIDTH,HEIGHT

void drawMainScreen() {


int main(int argc, const char** argv){
    for (int i=0; i<argc; i++) {
        vector<string> keyvalue = ofSplitString(argv[i], "=");
        if (keyvalue.size()==2) params[keyvalue[0]] = keyvalue[1];
   // ...

'old' codeblocks version: 10.05



debugging with gdb

see also lldb

You can also running the gcc debugger from terminal:
view plaincopy to clipboardprint?

gdb myFolder/   

personal note:

in ofxBlobsManager::update()

//remember prev pos for existing blobs
for( int i = 0; i < blobs.size(); i++ ) {
	ofxStoredBlobVO& b =;
	b.pCentroid = b.centroid;
	b.pTip = b.tip;
	b.pTail = b.tail;

CL-Eye Test

draggable earth with easing

#include "ofMain.h"
#include "ofAppGlutWindow.h"
class testApp : public ofBaseApp {
    ofImage earth;
    ofQuaternion qTo;
    void setup() {
    void draw() {
        static ofVec3f fromAxis,toAxis;
        static float fromAngle=0,toAngle;
        fromAxis += (toAxis-fromAxis) * .1;
        fromAngle += (toAngle-fromAngle) * .1;
        ofTranslate(ofGetWidth()/2, ofGetHeight()/2);
        ofRotate(fromAngle, fromAxis.x, fromAxis.y, fromAxis.z);
    void mouseDragged(int x, int y, int button){
        ofPoint from(ofGetPreviousMouseX(), ofGetPreviousMouseY());
        ofPoint to(ofGetMouseX(), ofGetMouseY());
        from = toSphere(from / ofGetWidth() - 0.5f);
        to = toSphere(to / ofGetWidth() - 0.5f);
        ofPoint axis = from.crossed(to);
        qTo *= ofQuaternion(axis.x,axis.y,axis.z,;
    ofPoint toSphere(ofPoint v) {  //-0.5 ... +0.5
        float mag = v.x*v.x + v.y*v.y;
        if (mag>1.0f) v.normalize();
        else v.z = sqrt(1.0f - mag);
        return v;
    void quadricSphere(float radius, int resolution) {
        static GLUquadricObj *quadric = gluNewQuadric(); //because it's static, it's created only once
        gluQuadricTexture(quadric, GL_TRUE);
        gluQuadricNormals(quadric, GLU_SMOOTH);
        gluSphere(quadric, radius, resolution, resolution);
int main(){
	ofAppGlutWindow window;
	ofSetupOpenGL(&window, 500, 500, OF_WINDOW);
	ofRunApp(new testApp());

possible bug in ofxCvGrayScaleImage with ofSaveImage or img.saveImage()

work around: convert the ofxCvGrayScaleImage to ofxCvColorImage and then save the color image.

ofImage img;
ofxCvColorImage tmp;
tmp = bg; //bg is the ofxCvGrayScaleImage 

the same for load:

ofImage img;
ofxCvColorImage tmp;
bg = tmp;  //bg is the ofxCvGrayScaleImage 

install_name_tool usage on commandline

install_name_tool -change ./libfmodex.dylib @executable_path/libfmodex.dylib libfmodex.dylib

to get .app running:

install_name_tool -change ./libfmodex.dylib @executable_path/libfmodex.dylib 

openframeworks program crashes on glActiveTexture

Check if glActiveTexture is available:

if(glActiveTexture==NULL) {
      printf("glActiveTexture not supported\n");

This was the case with me running Windows through Parallels on a Mac.


ofSetupScreenOrtho(0,0,OFORIENTATIONUNKNOWN,true,-100,100); ofSetupScreenOrtho();


serial 250000 / 250K baudrate

some nice std::vector functions in ofUtils.h

template<class T>
void ofRandomize(vector<T>& values) {
	random_shuffle(values.begin(), values.end());
template<class T, class BoolFunction>
void ofRemove(vector<T>& values, BoolFunction shouldErase) {
	values.erase(remove_if(values.begin(), values.end(), shouldErase), values.end());
template<class T>
void ofSort(vector<T>& values) {
	sort(values.begin(), values.end());
template <class T>
unsigned int ofFind(const vector<T>& values, const T& target) {
	return distance(values.begin(), find(values.begin(), values.end(), target));
template <class T>
bool ofContains(const vector<T>& values, const T& target) {
	return ofFind(values, target) != values.size();


#include "ofAppGlutWindow.h"
#include "testApp.h"
int main() {
    ofAppGlutWindow window; 
    window.setGlutDisplayString("rgba double samples>=4"); 
    ofSetupOpenGL(&window, 500, 500, OF_WINDOW);
    ofRunApp(new testApp()); 

Ugly ofTrueTypeFont text after rotation

Use drawStringAsShapes instead of drawString

ofImage problems

exiftool -all= image.jpg



#pragma once
#include "ofMain.h"
#include "ofAppGlutWindow.h"
class ofGlutApp : public ofBaseApp {
    ofGlutApp() {
        ofSetupOpenGL(new ofAppGlutWindow(), 500, 500, OF_WINDOW);
openframeworks.txt · Last modified: 2016/07/20 13:56 by rick