Skip to content

Instantly share code, notes, and snippets.

@TatsuyaOGth
Created November 4, 2015 12:31
Show Gist options
  • Save TatsuyaOGth/11520a295c55dda87aad to your computer and use it in GitHub Desktop.
Save TatsuyaOGth/11520a295c55dda87aad to your computer and use it in GitHub Desktop.
common utility file for my openFrameworks project
#pragma once
#include "ofMain.h"
/**
* Logger util
*/
#define __FILE_AND_LINE__ ofSplitString(ofToString(__FILE__), "/").back()+"|line:"+ofToString(__LINE__)
#define LOG_NOTICE ofLogNotice(__FILE_AND_LINE__)
#define LOG_WARNING ofLogWarning(__FILE_AND_LINE__)
#define LOG_ERROR ofLogError(__FILE_AND_LINE__)
#define LOG_DEBUG ofLogNotice("[DEBUG]frame:"+ofToString(ofGetFrameNum())+"|"+__FILE_AND_LINE__)
/**
* mouse test
*/
static float getTestMouseX(float min = 0.0, float max = 1.0, bool log = false)
{
float v = ofMap((float)ofGetMouseX() / (float)ofGetWidth(), 0, 1, min, max, true);
if (log) LOG_DEBUG << "DEBUG MOUSE X " << v;
return v;
}
static float getTestMouseY(float min = 0.0, float max = 1.0, bool log = false)
{
float v = ofMap((float)ofGetMouseY() / (float)ofGetHeight(), 0, 1, min, max, true);
if (log) LOG_DEBUG << "DEBUG MOUSE Y " << v;
return v;
}
#define TEST_MOUSE_X(min,max) getTestMouseX(min,max)
#define TEST_MOUSE_Y(min,max) getTestMouseY(min,max)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment