add rough examples
This commit is contained in:
parent
2e1d94193c
commit
c4252e6748
10 changed files with 349 additions and 0 deletions
21
example-atlas/src/main.cpp
Normal file
21
example-atlas/src/main.cpp
Normal file
|
@ -0,0 +1,21 @@
|
|||
#include "ofMain.h"
|
||||
#include "ofApp.h"
|
||||
|
||||
//========================================================================
|
||||
int main(){
|
||||
#ifdef OF_TARGET_OPENGLES
|
||||
ofGLESWindowSettings settings;
|
||||
//settings.setSize(1920, 1080);
|
||||
settings.glesVersion = 2;
|
||||
#else
|
||||
ofGLWindowSettings settings;
|
||||
settings.setSize(1920, 1080);
|
||||
settings.setGLVersion(3, 2);
|
||||
#endif
|
||||
ofCreateWindow(settings);
|
||||
|
||||
// this kicks off the running of my app
|
||||
// can be OF_WINDOW or OF_FULLSCREEN
|
||||
// pass in width and height too:
|
||||
ofRunApp(new ofApp());
|
||||
}
|
84
example-atlas/src/ofApp.cpp
Normal file
84
example-atlas/src/ofApp.cpp
Normal file
|
@ -0,0 +1,84 @@
|
|||
#include "ofApp.h"
|
||||
#include "ofGraphicsBaseTypes.h"
|
||||
#include "ofUtils.h"
|
||||
|
||||
//--------------------------------------------------------------
|
||||
void ofApp::setup(){
|
||||
string fontName = "RobotoFlex.ttf";
|
||||
string fontPath = "data/fonts/" + fontName;
|
||||
atlas.setup(fontPath);
|
||||
atlasImage = atlas.getAtlasImage();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
void ofApp::update(){
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
void ofApp::draw(){
|
||||
ofBackground(ofColor::black);
|
||||
ofPushMatrix();
|
||||
ofTranslate(
|
||||
ofMap(sin(ofGetElapsedTimeMillis() * 0.0001), -1, 1, 0, ofGetWidth() - atlasImage.getWidth()),
|
||||
ofMap(cos(ofGetElapsedTimeMillis() * 0.0001), -1, 1, 0, ofGetHeight() - atlasImage.getHeight()),
|
||||
0);
|
||||
atlasImage.draw(0, 0);
|
||||
ofPopMatrix();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
void ofApp::keyPressed(int key){
|
||||
if(key == 's'){
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
void ofApp::keyReleased(int key){
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
void ofApp::mouseMoved(int x, int y){
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
void ofApp::mouseDragged(int x, int y, int button){
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
void ofApp::mousePressed(int x, int y, int button){
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
void ofApp::mouseReleased(int x, int y, int button){
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
void ofApp::mouseEntered(int x, int y){
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
void ofApp::mouseExited(int x, int y){
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
void ofApp::windowResized(int w, int h){
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
void ofApp::gotMessage(ofMessage msg){
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
void ofApp::dragEvent(ofDragInfo dragInfo){
|
||||
|
||||
}
|
30
example-atlas/src/ofApp.h
Normal file
30
example-atlas/src/ofApp.h
Normal file
|
@ -0,0 +1,30 @@
|
|||
#pragma once
|
||||
|
||||
#include "Atlas.h"
|
||||
#include "ofMain.h"
|
||||
#include "ofxMsdfgen.h"
|
||||
|
||||
using namespace msdfgen;
|
||||
|
||||
class ofApp : public ofBaseApp {
|
||||
|
||||
public:
|
||||
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 mouseEntered(int x, int y);
|
||||
void mouseExited(int x, int y);
|
||||
void windowResized(int w, int h);
|
||||
void dragEvent(ofDragInfo dragInfo);
|
||||
void gotMessage(ofMessage msg);
|
||||
|
||||
ofxMsdfgen::Atlas atlas;
|
||||
ofImage atlasImage;
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue