Quantcast
Channel: beginners - openFrameworks
Viewing all articles
Browse latest Browse all 4929

ofxFontStash in a multi-window setup

$
0
0

@thomasgeissl wrote:

Hello,
I am using @armadillu's ofxFontStash and having problems drawing strings in a multi-window setup.
It works fine, if I use a single window.
Any ideas?

#include "ofMain.h"
#include "ofxFontStash.h"

#define TWO_WINDOWS

class ofApp : public ofBaseApp{

	public:
		void setup(){
			ofSetFrameRate(60);
			_font.loadFont("OpenSans-CondLight.ttf", 100);
		}
		void draw(){
			_font.draw("lorem ipsum", 100, 100, 100);
			ofDrawRectangle(ofGetWidth()/3, ofGetHeight()/3, ofGetWidth()/3, ofGetHeight()/3);
		}
		ofxFontStash _font;
};

int main(){
#ifndef TWO_WINDOWS
	ofSetupOpenGL(1024, 768, OF_WINDOW);         // <-------- setup the GL context
	ofRunApp(new ofApp);
#endif

#ifdef TWO_WINDOWS
	ofGLFWWindowSettings mainWindowSettings;
	mainWindowSettings.setGLVersion(3, 2);
	mainWindowSettings.windowMode = OF_WINDOW;
	mainWindowSettings.monitor = 0;
	auto mainWindow = ofCreateWindow(mainWindowSettings);

	ofGLFWWindowSettings secondWindowSettings;
	secondWindowSettings.setGLVersion(3, 2);
	secondWindowSettings.windowMode = OF_WINDOW;
	secondWindowSettings.monitor = 0;
	secondWindowSettings.shareContextWith = mainWindow;
	auto secondWindow = ofCreateWindow(secondWindowSettings);


	auto mainAppPtr = std::make_shared <ofApp>();
	auto secondAppPtr = std::make_shared <ofApp>();

	ofRunApp(mainWindow, mainAppPtr);
	ofRunApp(secondWindow, secondAppPtr);

	ofRunMainLoop();
#endif
}

Posts: 2

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 4929

Trending Articles