armadillu / ofxEasyRetina

OF addon to enable retina graphics on iOS app without modifying the original appearance.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ofxEasyRetina

Simple OpenFrameworks addon allows you to enable retina graphics on iOS without modifying the original appearance of the app. In OpenFrameworks, when you enable retina on your device, the canvas size is doubled, ofGetWidth() and ofGetHeight() are doubled too, everything ends up looking tiny.

image

With ofxEasyRetina, everything is upscaled as expected, just with twice the resolution. Your touch input will also behave as expected, and so will ofGetWidth() and ofGetHeight();

image

PD: This is quite an ugly hack, but it makes it very easy to make retina compatible an exising non-retina project.

How to use

	//enable retina before you create the window, in main.m ///////////////////
	
	int main(){

		ofAppiPhoneWindow * iOSWindow = new ofAppiPhoneWindow();
		iOSWindow->enableRetinaSupport(); //enable retina!
		ofSetupOpenGL(iOSWindow, 480, 320, OF_FULLSCREEN);
		ofRunApp(new testApp);
	}

	//include these two files in testApp.h ////////////////////////////////////
	
	#include "ofxEasyRetina.h"
	#include "ofxiOSEAGLView+retinaPatch.h"

	class testApp : public ofxiPhoneApp{
		public:
    		void setup();
			void update();
	        void draw();
	
			ofxEasyRetina retina; //declare an ofxEasyRetina instance
	};
	
	//Setup the screen before drawing in testApp.mm ///////////////////////////
	
	void testApp::draw(){
		retina.setupScreenOrtho(); //make ofxEasyRetina setup your screen
		
		//done! draw your stuff!!
	}

To Do

  • tested on OF0073, and not much!

About

OF addon to enable retina graphics on iOS app without modifying the original appearance.


Languages

Language:Objective-C 91.7%Language:C++ 8.3%