uncrustify

This commit is contained in:
jrkb 2023-09-24 21:08:54 +02:00
parent 0b8fb261fa
commit fa1d70e6a5
4 changed files with 189 additions and 178 deletions

View file

@ -88,6 +88,7 @@
# Note: Leave a leading space when adding list items with the += operator
################################################################################
# PROJECT_DEFINES =
PROJECT_DEFINES = OFX_PROFILER=1
################################################################################
# PROJECT CFLAGS

View file

@ -1,12 +1,13 @@
#include "ofApp.h"
#include "ofAppRunner.h"
//--------------------------------------------------------------
void ofApp::setup() {
OFX_PROFILER_BEGIN_SESSION("test","result.json");
void ofApp::setup(){
OFX_PROFILER_BEGIN_SESSION("test", "result.json");
OFX_PROFILER_FUNCTION();
ofBackgroundHex(0x57554c);
ofSetFrameRate(60);
//ofSetFrameRate(60);
ofSetVerticalSync(true);
@ -18,17 +19,17 @@ void ofApp::setup() {
}
//--------------------------------------------------------------
void ofApp::update() {
void ofApp::update(){
OFX_PROFILER_FUNCTION();
// add points all the time
if(points.size() < 500000) {
for (int i=0; i<30; i++) {
addPoint(ofGetWidth()/2, ofGetHeight()/2);
if(points.size() < 500000 || ofGetFrameRate() > 30){
for(int i = 0; i < 300; i++){
addPoint(ofGetWidth() / 2, ofGetHeight() / 2);
}
}
// move all the points around
for (unsigned int i=0; i<points.size(); i++) {
for(unsigned int i = 0; i < points.size(); i++){
speeds[i].y += 0.04; // some grav
points[i] += speeds[i];
@ -36,42 +37,49 @@ void ofApp::update() {
// move from the mouse
glm::vec2 mouseVec = glm::vec2(ofGetMouseX(), ofGetMouseY()) - points[i];
if(glm::length(mouseVec) < 100) {
if(glm::length(mouseVec) < 100){
mouseVec = glm::normalize(mouseVec);
speeds[i] -= mouseVec;
}
// wrap the screenhttps://profiler.firefox.com/from-file/calltree/?v=4
if(points[i].x > ofGetWidth()) points[i].x = 1;
if(points[i].x < 0) points[i].x = ofGetWidth()-1;
if(points[i].y > ofGetHeight()) points[i].y = 1;
if(points[i].y < 0) points[i].y = ofGetHeight()-1;
if(points[i].x > ofGetWidth()){
points[i].x = 1;
}
if(points[i].x < 0){
points[i].x = ofGetWidth() - 1;
}
if(points[i].y > ofGetHeight()){
points[i].y = 1;
}
if(points[i].y < 0){
points[i].y = ofGetHeight() - 1;
}
}
}
//--------------------------------------------------------------
void ofApp::draw() {
void ofApp::draw(){
OFX_PROFILER_FUNCTION();
// draw the points the slow way
if(mode == 1) {
if(mode == 1){
OFX_PROFILER_SCOPE("mode 1");
#ifdef TARGET_OPENGLES
ofSetColor(255);
ofDrawBitmapString("OpenGL immediate mode not available in OpenGL ES. Press 2 or 3.",ofGetWidth() / 2.0f - 300,ofGetHeight() / 2.0f);
ofDrawBitmapString("OpenGL immediate mode not available in OpenGL ES. Press 2 or 3.", ofGetWidth() / 2.0f - 300, ofGetHeight() / 2.0f);
#else
ofSetColor(255);
glBegin(GL_POINTS);
for (unsigned int i=0; i<points.size(); i++) {
for(unsigned int i = 0; i < points.size(); i++){
glVertex2f(points[i].x, points[i].y);
}
glEnd();
#endif
}
// a bit faster
else if(mode == 2) {
else if(mode == 2){
OFX_PROFILER_SCOPE("mode 2");
ofSetColor(255);
@ -80,9 +88,8 @@ void ofApp::draw() {
glDrawArrays(GL_POINTS, 0, (int)points.size());
glDisableClientState(GL_VERTEX_ARRAY);
}
// super fast (vbo)
else if(mode == 3) {
else if(mode == 3){
OFX_PROFILER_SCOPE("mode 3");
ofSetColor(255);
vbo.setVertexData(&points[0], (int)points.size(), GL_DYNAMIC_DRAW);
@ -94,34 +101,40 @@ void ofApp::draw() {
ofSetColor(0);
ofDrawRectangle(0, 0, 250, 90);
ofSetColor(255);
ofDrawBitmapString("Mode "+ofToString(mode), 20, 20);
ofDrawBitmapString("FPS "+ofToString(ofGetFrameRate(), 0), 20, 40);
ofDrawBitmapString("Total Points "+ofToString((int)points.size()), 20, 60);
ofDrawBitmapString("Mode " + ofToString(mode), 20, 20);
ofDrawBitmapString("FPS " + ofToString(ofGetFrameRate(), 0), 20, 40);
ofDrawBitmapString("Total Points " + ofToString((int)points.size()), 20, 60);
}
//--------------------------------------------------------------
void ofApp::exit() {
void ofApp::exit(){
OFX_PROFILER_END_SESSION();
}
//--------------------------------------------------------------
void ofApp::keyPressed(int key) {
void ofApp::keyPressed(int key){
if(key == '1') mode = 1;
if(key == '2') mode = 2;
if(key == '3') mode = 3;
if(key == '1'){
mode = 1;
}
if(key == '2'){
mode = 2;
}
if(key == '3'){
mode = 3;
}
// clear all the points
if(key == 'c') {
if(key == 'c'){
points.clear();
speeds.clear();
}
// add crazy amount
if(key == 'z') {
for (int i=0; i<400000; i++) {
if(key == 'z'){
for(int i = 0; i < 400000; i++){
addPoint(ofRandomWidth(), ofRandomHeight());
}
}
@ -134,14 +147,14 @@ void ofApp::keyReleased(int key){
}
//--------------------------------------------------------------
void ofApp::mouseMoved(int x, int y ){
void ofApp::mouseMoved(int x, int y){
}
//--------------------------------------------------------------
void ofApp::mouseDragged(int x, int y, int button){
// add a bunch as you drag
for (int i=0; i<400; i++) {
for(int i = 0; i < 400; i++){
addPoint(x, y);
}
}

View file

@ -1,21 +1,19 @@
#pragma once
#define OFX_PROFILER 1
#include "ofMain.h"
#include "ofxProfiler.h"
class ofApp : public ofBaseApp{
class ofApp : public ofBaseApp {
public:
public:
void setup();
void update();
void draw();
void exit();
void keyPressed (int key);
void keyPressed(int key);
void keyReleased(int key);
void mouseMoved(int x, int y );
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);
@ -25,7 +23,7 @@ public:
void dragEvent(ofDragInfo dragInfo);
void gotMessage(ofMessage msg);
void addPoint(float x, float y) {
void addPoint(float x, float y){
points.push_back(glm::vec2(x, y));
speeds.push_back(glm::vec2(ofRandom(-1, 1), ofRandom(-1, 1)));
}

View file

@ -148,7 +148,6 @@ class InstrumentationTimer {
};
}
#define OFX_PROFILER 1
// Resolve which function signature macro will HZ_PROFILE_BEGIN_SESSIONbe used. Note that this only
// is resolved when the (pre)compiler starts, so the syntax highlighting
// could mark the wrong one in your editor!