Created
December 11, 2012 15:51
-
-
Save ofTheo/4259544 to your computer and use it in GitHub Desktop.
iosE2ShaderExample - try uncommenting line 13
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "testApp.h" | |
#include "ofGLES2Renderer.h" | |
ofEasyCam cam; | |
//-------------------------------------------------------------- | |
void testApp::setup(){ | |
ofBackground(40); | |
ofSetVerticalSync(false); | |
ofEnableAlphaBlending(); | |
ofSetLogLevel(OF_LOG_VERBOSE); | |
//ofSetOrientation(OF_ORIENTATION_90_LEFT); | |
//we load a font and tell OF to make outlines so we can draw it as GL shapes rather than textures | |
int fontSize = ofGetWidth() / 10; | |
font.loadFont("type/verdana.ttf", fontSize, true, false, true, 0.4, 72); | |
} | |
//-------------------------------------------------------------- | |
void testApp::update(){ | |
} | |
//-------------------------------------------------------------- | |
void testApp::draw(){ | |
cam.begin(); | |
ofPushStyle(); | |
ofSetColor(245, 58, 135); | |
ofFill(); | |
ofShader & currentShader = ofGetGLES2Renderer()->getCurrentShader(); | |
currentShader.setUniform1f("timeValX", ofGetElapsedTimef() * 0.1 ); // we want to pass in some varrying values to animate our type / color | |
currentShader.setUniform1f("timeValY", -ofGetElapsedTimef() * 0.18 ); | |
currentShader.setUniform2f("mouse", mousePoint.x, mousePoint.y); // we also pass in the mouse position | |
ofRectangle rect = font.getStringBoundingBox("openFrameworks", 0, 0); // size of text. | |
int x = ( - rect.width) * 0.5; // position in center screen. | |
int padding = rect.height + 50; // draw the text multiple times. | |
for(int y = -900; y < 900; y+=padding) { | |
font.drawStringAsShapes("openFrameworks", x, y); | |
} | |
ofPopStyle(); | |
cam.end(); | |
} | |
//-------------------------------------------------------------- | |
void testApp::exit(){ | |
} | |
//-------------------------------------------------------------- | |
void testApp::touchDown(ofTouchEventArgs & touch){ | |
// | |
} | |
//-------------------------------------------------------------- | |
void testApp::touchMoved(ofTouchEventArgs & touch){ | |
// we have to transform the coords to what the shader is expecting which is 0,0 in the center and y axis flipped. | |
mousePoint.x = touch.x * 2 - ofGetWidth(); | |
mousePoint.y = ofGetHeight() * 0.5 - touch.y; | |
} | |
//-------------------------------------------------------------- | |
void testApp::touchUp(ofTouchEventArgs & touch){ | |
// | |
} | |
//-------------------------------------------------------------- | |
void testApp::touchDoubleTap(ofTouchEventArgs & touch){ | |
} | |
//-------------------------------------------------------------- | |
void testApp::touchCancelled(ofTouchEventArgs & touch){ | |
} | |
//-------------------------------------------------------------- | |
void testApp::lostFocus(){ | |
} | |
//-------------------------------------------------------------- | |
void testApp::gotFocus(){ | |
} | |
//-------------------------------------------------------------- | |
void testApp::gotMemoryWarning(){ | |
} | |
//-------------------------------------------------------------- | |
void testApp::deviceOrientationChanged(int newOrientation){ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment