Nov
28
Getting Started with Open Frameworks
Posted by | Posted in C++, Frameworks, Open Frameworks | Posted on 28-11-2009
I have been playing around with C++ and OF lately, getting familiar with the what I'm dealing with, which is pretty heavy. What can I say, C++ is hard. Here is an OF "hello world" program. It just prints "Hello OF" in red letters, but it will also give you an idea of how you can use OF. This is just a basic example derived from the examples in OF itself, but stripped down for clarity. The class is called testApp and this is the .h file for it:
#ifndef _TEST_APP #define _TEST_APP #include "ofMain.h" class testApp : public ofBaseApp { public: testApp(); void setup(); void update(); void draw(); void keyPressed (int key); void keyReleased(int key); void mouseMoved(int x, int y ); void mouseDragged(int x, int y, int button); void mousePressed(int x, int y, int button); void mouseReleased(int x, int y, int button); void windowResized(int w, int h); } #endif
and here is the implementation file:
#include "testApp.h" testApp::testApp(){ } void testApp::setup(){} void testApp::update(){} void testApp::draw() { ofSetColor(0xFF0000); ofDrawBitmapString("Hello OF", 100, 100); } void testApp::keyPressed (int key){} void testApp::keyReleased(int key){} void testApp::mouseMoved(int x, int y ){} void testApp::mouseDragged(int x, int y, int button){} void testApp::mousePressed(int x, int y, int button){} void testApp::mouseReleased(int x, int y, int button){} void testApp::windowResized(int w, int h){}
